libwz 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/binding.gyp +149 -0
- package/deps/tiny-aes/.github/workflows/c-cpp.yml +27 -0
- package/deps/tiny-aes/CMakeLists.txt +17 -0
- package/deps/tiny-aes/Makefile +61 -0
- package/deps/tiny-aes/README.md +83 -0
- package/deps/tiny-aes/aes.c +572 -0
- package/deps/tiny-aes/aes.h +91 -0
- package/deps/tiny-aes/aes.hpp +12 -0
- package/deps/tiny-aes/conanfile.py +73 -0
- package/deps/tiny-aes/library.json +19 -0
- package/deps/tiny-aes/library.properties +11 -0
- package/deps/tiny-aes/test.c +316 -0
- package/deps/tiny-aes/test.cpp +2 -0
- package/deps/tiny-aes/test_package/CMakeLists.txt +11 -0
- package/deps/tiny-aes/test_package/conanfile.py +17 -0
- package/deps/tiny-aes/unlicense.txt +24 -0
- package/deps/zlib/.cmake-format.yaml +245 -0
- package/deps/zlib/.github/workflows/c-std.yml +268 -0
- package/deps/zlib/.github/workflows/cmake.yml +147 -0
- package/deps/zlib/.github/workflows/configure.yml +146 -0
- package/deps/zlib/.github/workflows/contribs.yml +64 -0
- package/deps/zlib/.github/workflows/fuzz.yml +25 -0
- package/deps/zlib/.github/workflows/msys-cygwin.yml +92 -0
- package/deps/zlib/.github/workflows/others.yml +153 -0
- package/deps/zlib/BUILD.bazel +134 -0
- package/deps/zlib/CMakeLists.txt +310 -0
- package/deps/zlib/ChangeLog +1669 -0
- package/deps/zlib/FAQ +371 -0
- package/deps/zlib/INDEX +67 -0
- package/deps/zlib/LICENSE +22 -0
- package/deps/zlib/MODULE.bazel +9 -0
- package/deps/zlib/Makefile.in +426 -0
- package/deps/zlib/README +115 -0
- package/deps/zlib/README-cmake.md +79 -0
- package/deps/zlib/adler32.c +164 -0
- package/deps/zlib/amiga/Makefile.pup +69 -0
- package/deps/zlib/amiga/Makefile.sas +68 -0
- package/deps/zlib/compress.c +99 -0
- package/deps/zlib/configure +1078 -0
- package/deps/zlib/contrib/CMakeLists.txt +61 -0
- package/deps/zlib/contrib/README.contrib +57 -0
- package/deps/zlib/contrib/ada/CMakeLists.txt +217 -0
- package/deps/zlib/contrib/ada/buffer_demo.adb +106 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADACompiler.cmake.in +23 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADAInformation.cmake +133 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeDetermineADACompiler.cmake +33 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeTestADACompiler.cmake +46 -0
- package/deps/zlib/contrib/ada/cmake/binder_helper.cmake +47 -0
- package/deps/zlib/contrib/ada/cmake/compile_helper.cmake +32 -0
- package/deps/zlib/contrib/ada/cmake/exe_link_helper.cmake +53 -0
- package/deps/zlib/contrib/ada/cmake/shared_link_helper.cmake +52 -0
- package/deps/zlib/contrib/ada/cmake/static_link_helper.cmake +25 -0
- package/deps/zlib/contrib/ada/mtest.adb +156 -0
- package/deps/zlib/contrib/ada/read.adb +156 -0
- package/deps/zlib/contrib/ada/readme.txt +65 -0
- package/deps/zlib/contrib/ada/test.adb +463 -0
- package/deps/zlib/contrib/ada/zlib-streams.adb +225 -0
- package/deps/zlib/contrib/ada/zlib-streams.ads +114 -0
- package/deps/zlib/contrib/ada/zlib-thin.adb +142 -0
- package/deps/zlib/contrib/ada/zlib-thin.ads +450 -0
- package/deps/zlib/contrib/ada/zlib.adb +701 -0
- package/deps/zlib/contrib/ada/zlib.ads +328 -0
- package/deps/zlib/contrib/ada/zlib.gpr +20 -0
- package/deps/zlib/contrib/blast/CMakeLists.txt +166 -0
- package/deps/zlib/contrib/blast/Makefile +14 -0
- package/deps/zlib/contrib/blast/README +4 -0
- package/deps/zlib/contrib/blast/blast-test.c +42 -0
- package/deps/zlib/contrib/blast/blast.c +422 -0
- package/deps/zlib/contrib/blast/blast.h +84 -0
- package/deps/zlib/contrib/blast/blastConfig.cmake.in +18 -0
- package/deps/zlib/contrib/blast/test/CMakeLists.txt +193 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/blast/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test.pk +0 -0
- package/deps/zlib/contrib/blast/test.txt +1 -0
- package/deps/zlib/contrib/blast/tester.cmake +28 -0
- package/deps/zlib/contrib/crc32vx/CMakeLists.txt +67 -0
- package/deps/zlib/contrib/crc32vx/README +9 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx.c +254 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx_hooks.h +9 -0
- package/deps/zlib/contrib/delphi/ZLib.pas +557 -0
- package/deps/zlib/contrib/delphi/ZLibConst.pas +11 -0
- package/deps/zlib/contrib/delphi/readme.txt +76 -0
- package/deps/zlib/contrib/delphi/zlibd32.mak +99 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.build +33 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.chm +0 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.sln +21 -0
- package/deps/zlib/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- package/deps/zlib/contrib/dotzlib/readme.txt +58 -0
- package/deps/zlib/contrib/gcc_gvmat64/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/gcc_gvmat64/gvmat64.S +570 -0
- package/deps/zlib/contrib/infback9/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/infback9/README +1 -0
- package/deps/zlib/contrib/infback9/infback9.c +603 -0
- package/deps/zlib/contrib/infback9/infback9.h +37 -0
- package/deps/zlib/contrib/infback9/inffix9.h +107 -0
- package/deps/zlib/contrib/infback9/inflate9.h +47 -0
- package/deps/zlib/contrib/infback9/inftree9.c +319 -0
- package/deps/zlib/contrib/infback9/inftree9.h +61 -0
- package/deps/zlib/contrib/iostream/test.cpp +24 -0
- package/deps/zlib/contrib/iostream/zfstream.cpp +329 -0
- package/deps/zlib/contrib/iostream/zfstream.h +128 -0
- package/deps/zlib/contrib/iostream2/zstream.h +306 -0
- package/deps/zlib/contrib/iostream2/zstream_test.cpp +25 -0
- package/deps/zlib/contrib/iostream3/CMakeLists.txt +200 -0
- package/deps/zlib/contrib/iostream3/README +35 -0
- package/deps/zlib/contrib/iostream3/TODO +17 -0
- package/deps/zlib/contrib/iostream3/iostream3Config.cmake.in +23 -0
- package/deps/zlib/contrib/iostream3/test/CMakeLists.txt +191 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/iostream3/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test.cc +50 -0
- package/deps/zlib/contrib/iostream3/zfstream.cc +479 -0
- package/deps/zlib/contrib/iostream3/zfstream.h +466 -0
- package/deps/zlib/contrib/minizip/CMakeLists.txt +387 -0
- package/deps/zlib/contrib/minizip/LICENSE.Info-Zip +58 -0
- package/deps/zlib/contrib/minizip/Makefile +33 -0
- package/deps/zlib/contrib/minizip/Makefile.am +45 -0
- package/deps/zlib/contrib/minizip/MiniZip64_Changes.txt +6 -0
- package/deps/zlib/contrib/minizip/MiniZip64_info.txt +69 -0
- package/deps/zlib/contrib/minizip/configure.ac +32 -0
- package/deps/zlib/contrib/minizip/crypt.h +125 -0
- package/deps/zlib/contrib/minizip/ints.h +57 -0
- package/deps/zlib/contrib/minizip/ioapi.c +231 -0
- package/deps/zlib/contrib/minizip/ioapi.h +183 -0
- package/deps/zlib/contrib/minizip/iowin32.c +447 -0
- package/deps/zlib/contrib/minizip/iowin32.h +27 -0
- package/deps/zlib/contrib/minizip/make_vms.com +25 -0
- package/deps/zlib/contrib/minizip/miniunz.c +647 -0
- package/deps/zlib/contrib/minizip/miniunzip.1 +63 -0
- package/deps/zlib/contrib/minizip/minizip.1 +46 -0
- package/deps/zlib/contrib/minizip/minizip.c +511 -0
- package/deps/zlib/contrib/minizip/minizip.pc.in +13 -0
- package/deps/zlib/contrib/minizip/minizip.pc.txt +13 -0
- package/deps/zlib/contrib/minizip/minizipConfig.cmake.in +27 -0
- package/deps/zlib/contrib/minizip/mztools.c +294 -0
- package/deps/zlib/contrib/minizip/mztools.h +37 -0
- package/deps/zlib/contrib/minizip/skipset.h +366 -0
- package/deps/zlib/contrib/minizip/test/CMakeLists.txt +176 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/contrib/minizip/test/find_package_no_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_wrong_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/test_helper.cm +32 -0
- package/deps/zlib/contrib/minizip/unzip.c +1984 -0
- package/deps/zlib/contrib/minizip/unzip.h +442 -0
- package/deps/zlib/contrib/minizip/zip.c +2246 -0
- package/deps/zlib/contrib/minizip/zip.h +371 -0
- package/deps/zlib/contrib/nuget/nuget.csproj +45 -0
- package/deps/zlib/contrib/nuget/nuget.sln +22 -0
- package/deps/zlib/contrib/pascal/example.pas +599 -0
- package/deps/zlib/contrib/pascal/readme.txt +76 -0
- package/deps/zlib/contrib/pascal/zlibd32.mak +99 -0
- package/deps/zlib/contrib/pascal/zlibpas.pas +276 -0
- package/deps/zlib/contrib/puff/CMakeLists.txt +154 -0
- package/deps/zlib/contrib/puff/Makefile +42 -0
- package/deps/zlib/contrib/puff/README +63 -0
- package/deps/zlib/contrib/puff/bin-writer.c +26 -0
- package/deps/zlib/contrib/puff/puff.c +840 -0
- package/deps/zlib/contrib/puff/puff.h +35 -0
- package/deps/zlib/contrib/puff/puffConfig.cmake.in +18 -0
- package/deps/zlib/contrib/puff/pufftest.c +168 -0
- package/deps/zlib/contrib/puff/test/CMakeLists.txt +262 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_exclude_test.cmake.in +26 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/puff/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/tester-cov.cmake +58 -0
- package/deps/zlib/contrib/puff/test/tester.cmake +16 -0
- package/deps/zlib/contrib/puff/zeros.raw +0 -0
- package/deps/zlib/contrib/testzlib/CMakeLists.txt +44 -0
- package/deps/zlib/contrib/testzlib/testzlib.c +275 -0
- package/deps/zlib/contrib/testzlib/testzlib.txt +10 -0
- package/deps/zlib/contrib/vstudio/readme.txt +22 -0
- package/deps/zlib/contrib/zlib1-dll/CMakeLists.txt +196 -0
- package/deps/zlib/contrib/zlib1-dll/readme.txt +21 -0
- package/deps/zlib/crc32.c +983 -0
- package/deps/zlib/crc32.h +9446 -0
- package/deps/zlib/deflate.c +2185 -0
- package/deps/zlib/deflate.h +383 -0
- package/deps/zlib/doc/algorithm.txt +209 -0
- package/deps/zlib/doc/crc-doc.1.0.pdf +0 -0
- package/deps/zlib/doc/rfc1950.txt +619 -0
- package/deps/zlib/doc/rfc1951.txt +955 -0
- package/deps/zlib/doc/rfc1952.txt +675 -0
- package/deps/zlib/doc/txtvsbin.txt +107 -0
- package/deps/zlib/examples/README.examples +54 -0
- package/deps/zlib/examples/enough.c +597 -0
- package/deps/zlib/examples/fitblk.c +233 -0
- package/deps/zlib/examples/gun.c +702 -0
- package/deps/zlib/examples/gzappend.c +504 -0
- package/deps/zlib/examples/gzjoin.c +449 -0
- package/deps/zlib/examples/gzlog.c +1061 -0
- package/deps/zlib/examples/gzlog.h +91 -0
- package/deps/zlib/examples/gznorm.c +474 -0
- package/deps/zlib/examples/zlib_how.html +550 -0
- package/deps/zlib/examples/zpipe.c +206 -0
- package/deps/zlib/examples/zran.c +546 -0
- package/deps/zlib/examples/zran.h +53 -0
- package/deps/zlib/gzclose.c +23 -0
- package/deps/zlib/gzguts.h +216 -0
- package/deps/zlib/gzlib.c +609 -0
- package/deps/zlib/gzread.c +668 -0
- package/deps/zlib/gzwrite.c +700 -0
- package/deps/zlib/infback.c +581 -0
- package/deps/zlib/inffast.c +321 -0
- package/deps/zlib/inffast.h +11 -0
- package/deps/zlib/inffixed.h +94 -0
- package/deps/zlib/inflate.c +1413 -0
- package/deps/zlib/inflate.h +126 -0
- package/deps/zlib/inftrees.c +424 -0
- package/deps/zlib/inftrees.h +64 -0
- package/deps/zlib/make_vms.com +867 -0
- package/deps/zlib/msdos/Makefile.bor +115 -0
- package/deps/zlib/msdos/Makefile.dj2 +104 -0
- package/deps/zlib/msdos/Makefile.emx +69 -0
- package/deps/zlib/msdos/Makefile.msc +112 -0
- package/deps/zlib/msdos/Makefile.tc +100 -0
- package/deps/zlib/os400/README400 +48 -0
- package/deps/zlib/os400/bndsrc +144 -0
- package/deps/zlib/os400/make.sh +383 -0
- package/deps/zlib/os400/zlibfixed.rpgle +578 -0
- package/deps/zlib/os400/zlibfree.rpgle +634 -0
- package/deps/zlib/qnx/package.qpg +141 -0
- package/deps/zlib/test/CMakeLists.txt +318 -0
- package/deps/zlib/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/test/example.c +552 -0
- package/deps/zlib/test/find_package_no_components_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_wrong_components_test.cmake.in +27 -0
- package/deps/zlib/test/infcover.c +672 -0
- package/deps/zlib/test/minigzip.c +592 -0
- package/deps/zlib/treebuild.xml +116 -0
- package/deps/zlib/trees.c +1119 -0
- package/deps/zlib/trees.h +128 -0
- package/deps/zlib/uncompr.c +101 -0
- package/deps/zlib/watcom/watcom_f.mak +43 -0
- package/deps/zlib/watcom/watcom_l.mak +43 -0
- package/deps/zlib/win32/DLL_FAQ.txt +381 -0
- package/deps/zlib/win32/Makefile.bor +109 -0
- package/deps/zlib/win32/Makefile.gcc +177 -0
- package/deps/zlib/win32/Makefile.msc +159 -0
- package/deps/zlib/win32/README-WIN32.txt +103 -0
- package/deps/zlib/win32/VisualC.txt +3 -0
- package/deps/zlib/win32/zlib.def +104 -0
- package/deps/zlib/win32/zlib1.rc +37 -0
- package/deps/zlib/zconf.h.in +551 -0
- package/deps/zlib/zlib.3 +149 -0
- package/deps/zlib/zlib.3.pdf +0 -0
- package/deps/zlib/zlib.h +2057 -0
- package/deps/zlib/zlib.map +116 -0
- package/deps/zlib/zlib.pc.cmakein +14 -0
- package/deps/zlib/zlib.pc.in +14 -0
- package/deps/zlib/zlibConfig.cmake.in +18 -0
- package/deps/zlib/zutil.c +313 -0
- package/deps/zlib/zutil.h +331 -0
- package/dist/index.d.ts +266 -0
- package/dist/index.js +1146 -0
- package/dist/libwz.js +5632 -0
- package/dist/libwz.wasm +0 -0
- package/include/wz/CRC32.h +182 -0
- package/include/wz/PngUtility.h +72 -0
- package/include/wz/PortalType.h +124 -0
- package/include/wz/Properties/WzBinaryProperty.h +70 -0
- package/include/wz/Properties/WzCanvasProperty.h +55 -0
- package/include/wz/Properties/WzConvexProperty.h +34 -0
- package/include/wz/Properties/WzDoubleProperty.h +32 -0
- package/include/wz/Properties/WzFloatProperty.h +30 -0
- package/include/wz/Properties/WzIntProperty.h +30 -0
- package/include/wz/Properties/WzLongProperty.h +30 -0
- package/include/wz/Properties/WzLuaProperty.h +31 -0
- package/include/wz/Properties/WzNullProperty.h +15 -0
- package/include/wz/Properties/WzPngProperty.h +53 -0
- package/include/wz/Properties/WzRawDataProperty.h +46 -0
- package/include/wz/Properties/WzShortProperty.h +31 -0
- package/include/wz/Properties/WzStringProperty.h +32 -0
- package/include/wz/Properties/WzSubProperty.h +35 -0
- package/include/wz/Properties/WzUOLProperty.h +44 -0
- package/include/wz/Properties/WzVectorProperty.h +40 -0
- package/include/wz/Properties/WzVideoProperty.h +43 -0
- package/include/wz/Result.h +58 -0
- package/include/wz/Util/Defines.h +16 -0
- package/include/wz/Util/ListFileParser.h +20 -0
- package/include/wz/Util/WzBinaryReader.h +95 -0
- package/include/wz/Util/WzBinaryWriter.h +72 -0
- package/include/wz/Util/WzBlobDataSource.h +30 -0
- package/include/wz/Util/WzDataSource.h +49 -0
- package/include/wz/Util/WzKeyGenerator.h +28 -0
- package/include/wz/Util/WzMutableKey.h +39 -0
- package/include/wz/Util/WzPath.h +37 -0
- package/include/wz/Util/WzStream.h +86 -0
- package/include/wz/Util/WzTool.h +42 -0
- package/include/wz/WzAESConstant.h +17 -0
- package/include/wz/WzDirectory.h +97 -0
- package/include/wz/WzEnums.h +76 -0
- package/include/wz/WzFile.h +99 -0
- package/include/wz/WzHeader.h +47 -0
- package/include/wz/WzImage.h +97 -0
- package/include/wz/WzImageProperty.h +92 -0
- package/include/wz/WzObject.h +55 -0
- package/include/wz/WzPropertyCollection.h +115 -0
- package/include/wz/wz.h +41 -0
- package/include/wz/wz_api.h +432 -0
- package/package.json +93 -0
- package/src/PngUtility.cpp +328 -0
- package/src/Properties/WzBinaryProperty.cpp +183 -0
- package/src/Properties/WzCanvasProperty.cpp +262 -0
- package/src/Properties/WzConvexProperty.cpp +159 -0
- package/src/Properties/WzDoubleProperty.cpp +12 -0
- package/src/Properties/WzFloatProperty.cpp +17 -0
- package/src/Properties/WzIntProperty.cpp +12 -0
- package/src/Properties/WzLongProperty.cpp +12 -0
- package/src/Properties/WzLuaProperty.cpp +37 -0
- package/src/Properties/WzNullProperty.cpp +11 -0
- package/src/Properties/WzPngProperty.cpp +637 -0
- package/src/Properties/WzRawDataProperty.cpp +116 -0
- package/src/Properties/WzShortProperty.cpp +12 -0
- package/src/Properties/WzStringProperty.cpp +44 -0
- package/src/Properties/WzSubProperty.cpp +129 -0
- package/src/Properties/WzUOLProperty.cpp +136 -0
- package/src/Properties/WzVectorProperty.cpp +22 -0
- package/src/Properties/WzVideoProperty.cpp +115 -0
- package/src/Util/ListFileParser.cpp +48 -0
- package/src/Util/WzBinaryReader.cpp +368 -0
- package/src/Util/WzBinaryWriter.cpp +305 -0
- package/src/Util/WzBlobDataSource.cpp +47 -0
- package/src/Util/WzDataSource.cpp +61 -0
- package/src/Util/WzKeyGenerator.cpp +43 -0
- package/src/Util/WzMutableKey.cpp +59 -0
- package/src/Util/WzStream.cpp +196 -0
- package/src/Util/WzTool.cpp +266 -0
- package/src/WzAESConstant.cpp +12 -0
- package/src/WzDirectory.cpp +669 -0
- package/src/WzEnums.cpp +20 -0
- package/src/WzFile.cpp +450 -0
- package/src/WzImage.cpp +350 -0
- package/src/WzImageProperty.cpp +469 -0
- package/src/WzObject.cpp +174 -0
- package/src/WzPropertyCollection.cpp +84 -0
- package/src/capi/wz_api.cpp +1996 -0
- package/src/node/binding.cpp +1776 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
#include "wz/WzImageProperty.h"
|
|
2
|
+
#include <algorithm>
|
|
3
|
+
#include <cctype>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <vector>
|
|
6
|
+
#include "wz/Properties/WzBinaryProperty.h"
|
|
7
|
+
#include "wz/Properties/WzCanvasProperty.h"
|
|
8
|
+
#include "wz/Properties/WzConvexProperty.h"
|
|
9
|
+
#include "wz/Properties/WzDoubleProperty.h"
|
|
10
|
+
#include "wz/Properties/WzFloatProperty.h"
|
|
11
|
+
#include "wz/Properties/WzIntProperty.h"
|
|
12
|
+
#include "wz/Properties/WzLongProperty.h"
|
|
13
|
+
#include "wz/Properties/WzLuaProperty.h"
|
|
14
|
+
#include "wz/Properties/WzNullProperty.h"
|
|
15
|
+
#include "wz/Properties/WzPngProperty.h"
|
|
16
|
+
#include "wz/Properties/WzRawDataProperty.h"
|
|
17
|
+
#include "wz/Properties/WzShortProperty.h"
|
|
18
|
+
#include "wz/Properties/WzStringProperty.h"
|
|
19
|
+
#include "wz/Properties/WzSubProperty.h"
|
|
20
|
+
#include "wz/Properties/WzUOLProperty.h"
|
|
21
|
+
#include "wz/Properties/WzVectorProperty.h"
|
|
22
|
+
#include "wz/Properties/WzVideoProperty.h"
|
|
23
|
+
#include "wz/Util/WzBinaryReader.h"
|
|
24
|
+
#include "wz/Util/WzBinaryWriter.h"
|
|
25
|
+
#include "wz/WzFile.h"
|
|
26
|
+
#include "wz/WzImage.h"
|
|
27
|
+
|
|
28
|
+
namespace wz {
|
|
29
|
+
|
|
30
|
+
namespace {
|
|
31
|
+
|
|
32
|
+
std::string ToLower(const std::string& s) {
|
|
33
|
+
std::string r = s;
|
|
34
|
+
std::transform(r.begin(), r.end(), r.begin(), [](unsigned char c) {
|
|
35
|
+
return static_cast<char>(std::tolower(c));
|
|
36
|
+
});
|
|
37
|
+
return r;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
bool IsExtendedProperty(const WzImageProperty* prop) {
|
|
41
|
+
if (!prop) return false;
|
|
42
|
+
switch (prop->PropertyType()) {
|
|
43
|
+
case WzPropertyType::SubProperty:
|
|
44
|
+
case WzPropertyType::Canvas:
|
|
45
|
+
case WzPropertyType::Vector:
|
|
46
|
+
case WzPropertyType::Convex:
|
|
47
|
+
case WzPropertyType::Sound:
|
|
48
|
+
case WzPropertyType::UOL:
|
|
49
|
+
return true;
|
|
50
|
+
case WzPropertyType::Raw:
|
|
51
|
+
return prop->IsRawDataProperty() || prop->IsVideoProperty();
|
|
52
|
+
default:
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Result<void> WriteExtendedValue(WzBinaryWriter* writer,
|
|
58
|
+
const WzImageProperty* prop) {
|
|
59
|
+
writer->WriteByte(9);
|
|
60
|
+
|
|
61
|
+
const int64_t beforePos = writer->Position();
|
|
62
|
+
writer->WriteInt32(0);
|
|
63
|
+
auto result = prop->WriteValue(writer);
|
|
64
|
+
if (!result.has_value()) return result;
|
|
65
|
+
|
|
66
|
+
const int64_t newPos = writer->Position();
|
|
67
|
+
const int32_t len = static_cast<int32_t>(newPos - beforePos);
|
|
68
|
+
if (!writer->BaseStream().Seek(beforePos, WzSeekOrigin::Begin)) {
|
|
69
|
+
return std::unexpected(
|
|
70
|
+
Error::IoError("Failed to seek WZ extended property length"));
|
|
71
|
+
}
|
|
72
|
+
writer->WriteInt32(len - 4);
|
|
73
|
+
if (!writer->BaseStream().Seek(newPos, WzSeekOrigin::Begin)) {
|
|
74
|
+
return std::unexpected(
|
|
75
|
+
Error::IoError("Failed to restore WZ extended property position"));
|
|
76
|
+
}
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
} // namespace
|
|
81
|
+
|
|
82
|
+
WzFile* WzImageProperty::WzFileParent() const {
|
|
83
|
+
auto* img = ParentImage();
|
|
84
|
+
return img ? img->WzFileParent() : nullptr;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
WzImage* WzImageProperty::ParentImage() const {
|
|
88
|
+
auto* p = Parent();
|
|
89
|
+
while (p) {
|
|
90
|
+
if (p->ObjectType() == WzObjectType::Image) return static_cast<WzImage*>(p);
|
|
91
|
+
p = p->Parent();
|
|
92
|
+
}
|
|
93
|
+
return nullptr;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void WzImageProperty::MarkParentImageChanged() const {
|
|
97
|
+
auto* img = ParentImage();
|
|
98
|
+
if (img) img->SetChanged(true);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
WzImageProperty* WzImageProperty::GetLinkedWzImageProperty() {
|
|
102
|
+
WzImageProperty* current = this;
|
|
103
|
+
while (current->PropertyType() == WzPropertyType::UOL) {
|
|
104
|
+
auto* uol = static_cast<WzUOLProperty*>(current);
|
|
105
|
+
WzObject* linkValue = uol->LinkValue();
|
|
106
|
+
if (linkValue && linkValue->ObjectType() == WzObjectType::Property) {
|
|
107
|
+
current = static_cast<WzImageProperty*>(linkValue);
|
|
108
|
+
} else {
|
|
109
|
+
return current; // broken link, return last valid
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return current;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
WzImageProperty* WzImageProperty::GetFromPath(const std::string& path) {
|
|
116
|
+
(void)path;
|
|
117
|
+
return nullptr;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
WzImageProperty* WzImageProperty::operator[](const std::string& name) {
|
|
121
|
+
(void)name;
|
|
122
|
+
return nullptr;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void WzImageProperty::SetValue(const std::string& value) {
|
|
126
|
+
(void)value;
|
|
127
|
+
}
|
|
128
|
+
void WzImageProperty::SetValue(int32_t value) {
|
|
129
|
+
(void)value;
|
|
130
|
+
}
|
|
131
|
+
void WzImageProperty::SetValue(int64_t value) {
|
|
132
|
+
(void)value;
|
|
133
|
+
}
|
|
134
|
+
void WzImageProperty::SetValue(float value) {
|
|
135
|
+
(void)value;
|
|
136
|
+
}
|
|
137
|
+
void WzImageProperty::SetValue(double value) {
|
|
138
|
+
(void)value;
|
|
139
|
+
}
|
|
140
|
+
void WzImageProperty::SetValue(const std::vector<uint8_t>& value) {
|
|
141
|
+
(void)value;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
Result<void> WzImageProperty::WriteValue(WzBinaryWriter* writer) const {
|
|
145
|
+
(void)writer;
|
|
146
|
+
return std::unexpected(Error::NotImplemented(
|
|
147
|
+
"WriteValue is not implemented for this property type"));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
Result<void> IPropertyContainer::AddProperties(WzPropertyCollection& props) {
|
|
151
|
+
for (auto& prop : props.TakeItems()) {
|
|
152
|
+
auto result = AddProperty(std::move(prop));
|
|
153
|
+
if (!result.has_value()) return result;
|
|
154
|
+
}
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
Result<void> WzImageProperty::AddProperty(WzImageProperty* prop) {
|
|
159
|
+
if (!prop) {
|
|
160
|
+
return std::unexpected(
|
|
161
|
+
Error::InvalidArgument("Cannot add a null WZ image property"));
|
|
162
|
+
}
|
|
163
|
+
if (prop->Name().empty()) {
|
|
164
|
+
return std::unexpected(
|
|
165
|
+
Error::InvalidArgument("WZ image property name cannot be empty"));
|
|
166
|
+
}
|
|
167
|
+
if (prop->Parent()) {
|
|
168
|
+
return std::unexpected(
|
|
169
|
+
Error::InvalidArgument("WZ image property already has a parent"));
|
|
170
|
+
}
|
|
171
|
+
auto* properties = WzProperties();
|
|
172
|
+
if (!properties) {
|
|
173
|
+
return std::unexpected(
|
|
174
|
+
Error::InvalidArgument("WZ object is not a property container"));
|
|
175
|
+
}
|
|
176
|
+
const std::string lower = ToLower(prop->Name());
|
|
177
|
+
for (auto* existing : *properties) {
|
|
178
|
+
if (existing && ToLower(existing->Name()) == lower) {
|
|
179
|
+
return std::unexpected(Error::InvalidArgument(
|
|
180
|
+
"Duplicate WZ image property name: " + prop->Name()));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
properties->Add(prop);
|
|
184
|
+
MarkParentImageChanged();
|
|
185
|
+
return {};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
Result<void> WzImageProperty::AddProperty(
|
|
189
|
+
std::unique_ptr<WzImageProperty> prop) {
|
|
190
|
+
auto* raw = prop.get();
|
|
191
|
+
auto result = AddProperty(raw);
|
|
192
|
+
if (result.has_value()) {
|
|
193
|
+
(void)prop.release();
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
Result<std::unique_ptr<WzImageProperty>>
|
|
199
|
+
WzImageProperty::RemoveProperty(WzImageProperty* prop) {
|
|
200
|
+
if (!prop) {
|
|
201
|
+
return std::unexpected(
|
|
202
|
+
Error::InvalidArgument("Cannot remove a null WZ image property"));
|
|
203
|
+
}
|
|
204
|
+
auto* properties = WzProperties();
|
|
205
|
+
if (!properties) {
|
|
206
|
+
return std::unexpected(
|
|
207
|
+
Error::InvalidArgument("WZ object is not a property container"));
|
|
208
|
+
}
|
|
209
|
+
auto removed = properties->Remove(prop);
|
|
210
|
+
if (!removed) {
|
|
211
|
+
return std::unexpected(
|
|
212
|
+
Error::NotFound("WZ image property is not owned by this property"));
|
|
213
|
+
}
|
|
214
|
+
MarkParentImageChanged();
|
|
215
|
+
return removed;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
Result<void> WzImageProperty::ClearProperties() {
|
|
219
|
+
auto* properties = WzProperties();
|
|
220
|
+
if (!properties) {
|
|
221
|
+
return std::unexpected(
|
|
222
|
+
Error::InvalidArgument("WZ object is not a property container"));
|
|
223
|
+
}
|
|
224
|
+
if (properties->size() == 0) return {};
|
|
225
|
+
properties->clear();
|
|
226
|
+
MarkParentImageChanged();
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
Result<std::unique_ptr<WzObject>> WzImageProperty::Remove() {
|
|
231
|
+
auto* parent = Parent();
|
|
232
|
+
if (!parent) {
|
|
233
|
+
return std::unexpected(
|
|
234
|
+
Error::NotFound("WZ image property has no removable parent"));
|
|
235
|
+
}
|
|
236
|
+
Result<std::unique_ptr<WzImageProperty>> result;
|
|
237
|
+
if (parent->ObjectType() == WzObjectType::Image) {
|
|
238
|
+
result = static_cast<WzImage*>(parent)->RemoveProperty(this);
|
|
239
|
+
} else if (parent->ObjectType() == WzObjectType::Property) {
|
|
240
|
+
result = static_cast<WzImageProperty*>(parent)->RemoveProperty(this);
|
|
241
|
+
} else {
|
|
242
|
+
return std::unexpected(
|
|
243
|
+
Error::NotFound("WZ image property has no removable parent"));
|
|
244
|
+
}
|
|
245
|
+
if (!result.has_value()) return std::unexpected(result.error());
|
|
246
|
+
return std::unique_ptr<WzObject>(std::move(result.value()));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
Result<WzPropertyCollection> WzImageProperty::ParsePropertyList(
|
|
250
|
+
int64_t offset,
|
|
251
|
+
WzBinaryReader* reader,
|
|
252
|
+
WzObject* parent,
|
|
253
|
+
WzImage* parentImg) {
|
|
254
|
+
int entryCount = reader->ReadCompressedInt();
|
|
255
|
+
WzPropertyCollection properties(parent);
|
|
256
|
+
|
|
257
|
+
auto addOwnedProperty = [&](std::unique_ptr<WzImageProperty> prop) {
|
|
258
|
+
prop->SetParent(parent);
|
|
259
|
+
properties.Add(std::move(prop));
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
for (int i = 0; i < entryCount; i++) {
|
|
263
|
+
std::string name = reader->ReadStringBlock(offset);
|
|
264
|
+
uint8_t ptype = reader->ReadByte();
|
|
265
|
+
switch (ptype) {
|
|
266
|
+
case 0: {
|
|
267
|
+
addOwnedProperty(std::make_unique<WzNullProperty>(name));
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case 11:
|
|
271
|
+
case 2: {
|
|
272
|
+
addOwnedProperty(
|
|
273
|
+
std::make_unique<WzShortProperty>(name, reader->ReadInt16()));
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
case 3:
|
|
277
|
+
case 19: {
|
|
278
|
+
addOwnedProperty(
|
|
279
|
+
std::make_unique<WzIntProperty>(name, reader->ReadCompressedInt()));
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
case 20: {
|
|
283
|
+
addOwnedProperty(
|
|
284
|
+
std::make_unique<WzLongProperty>(name, reader->ReadLong()));
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
case 4: {
|
|
288
|
+
uint8_t type = reader->ReadByte();
|
|
289
|
+
float val = (type == 0x80) ? reader->ReadSingle() : 0.0f;
|
|
290
|
+
addOwnedProperty(std::make_unique<WzFloatProperty>(name, val));
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
case 5: {
|
|
294
|
+
addOwnedProperty(
|
|
295
|
+
std::make_unique<WzDoubleProperty>(name, reader->ReadDouble()));
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
case 8: {
|
|
299
|
+
addOwnedProperty(std::make_unique<WzStringProperty>(
|
|
300
|
+
name, reader->ReadStringBlock(offset)));
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case 9: {
|
|
304
|
+
int64_t eob =
|
|
305
|
+
static_cast<int64_t>(reader->ReadUInt32()) + reader->Position();
|
|
306
|
+
auto exProp =
|
|
307
|
+
ParseExtendedProp(offset, reader, name, parent, parentImg);
|
|
308
|
+
if (!exProp.has_value()) return std::unexpected(exProp.error());
|
|
309
|
+
addOwnedProperty(std::move(exProp.value()));
|
|
310
|
+
if (reader->Position() != eob) {
|
|
311
|
+
reader->SetPosition(eob);
|
|
312
|
+
}
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
default:
|
|
316
|
+
return std::unexpected(Error::ParseError(
|
|
317
|
+
"Unknown property type at ParsePropertyList, ptype = " +
|
|
318
|
+
std::to_string(ptype)));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return properties;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
Result<void> WzImageProperty::WritePropertyList(
|
|
325
|
+
WzBinaryWriter* writer, const WzPropertyCollection& properties) {
|
|
326
|
+
if (properties.size() == 1 &&
|
|
327
|
+
properties[0]->PropertyType() == WzPropertyType::Lua) {
|
|
328
|
+
return properties[0]->WriteValue(writer);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
writer->WriteUInt16(0);
|
|
332
|
+
writer->WriteCompressedInt(static_cast<int32_t>(properties.size()));
|
|
333
|
+
for (auto* prop : properties) {
|
|
334
|
+
writer->WriteStringValue(prop->Name(), 0x00, 0x01);
|
|
335
|
+
auto result = IsExtendedProperty(prop) ? WriteExtendedValue(writer, prop)
|
|
336
|
+
: prop->WriteValue(writer);
|
|
337
|
+
if (!result.has_value()) return result;
|
|
338
|
+
}
|
|
339
|
+
return {};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
Result<std::unique_ptr<WzImageProperty>> WzImageProperty::ParseExtendedProp(
|
|
343
|
+
int64_t offset,
|
|
344
|
+
WzBinaryReader* reader,
|
|
345
|
+
const std::string& name,
|
|
346
|
+
WzObject* parent,
|
|
347
|
+
WzImage* parentImg) {
|
|
348
|
+
uint8_t extType = reader->ReadByte();
|
|
349
|
+
std::string iname;
|
|
350
|
+
switch (extType) {
|
|
351
|
+
case 0x01:
|
|
352
|
+
case WzImage::WzImageHeaderByte_WithOffset:
|
|
353
|
+
iname = reader->ReadStringAtOffset(offset + reader->ReadInt32());
|
|
354
|
+
break;
|
|
355
|
+
case 0x00:
|
|
356
|
+
case WzImage::WzImageHeaderByte_WithoutOffset:
|
|
357
|
+
iname = reader->ReadString();
|
|
358
|
+
break;
|
|
359
|
+
default:
|
|
360
|
+
return std::unexpected(
|
|
361
|
+
Error::ParseError("Invalid byte read at ParseExtendedProp"));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (iname == "Property") {
|
|
365
|
+
auto subProp = std::make_unique<WzSubProperty>(name);
|
|
366
|
+
subProp->SetParent(parent);
|
|
367
|
+
reader->SetPosition(reader->Position() + 2);
|
|
368
|
+
auto r = ParsePropertyList(offset, reader, subProp.get(), parentImg);
|
|
369
|
+
if (!r.has_value()) return std::unexpected(r.error());
|
|
370
|
+
for (auto& child : r.value().TakeItems()) {
|
|
371
|
+
subProp->WzProperties()->Add(std::move(child));
|
|
372
|
+
}
|
|
373
|
+
return subProp;
|
|
374
|
+
} else if (iname == "Canvas") {
|
|
375
|
+
auto canvasProp = std::make_unique<WzCanvasProperty>(name);
|
|
376
|
+
canvasProp->SetParent(parent);
|
|
377
|
+
reader->ReadByte();
|
|
378
|
+
if (reader->ReadByte() == 1) {
|
|
379
|
+
reader->SetPosition(reader->Position() + 2);
|
|
380
|
+
auto r = ParsePropertyList(offset, reader, canvasProp.get(), parentImg);
|
|
381
|
+
if (!r.has_value()) return std::unexpected(r.error());
|
|
382
|
+
for (auto& child : r.value().TakeItems()) {
|
|
383
|
+
canvasProp->WzProperties()->Add(std::move(child));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
auto png =
|
|
387
|
+
std::make_unique<WzPngProperty>(reader, parentImg->ParseEverything());
|
|
388
|
+
png->SetParent(canvasProp.get());
|
|
389
|
+
canvasProp->SetPngProperty(std::move(png));
|
|
390
|
+
return canvasProp;
|
|
391
|
+
} else if (iname == "Shape2D#Vector2D") {
|
|
392
|
+
auto vecProp = std::make_unique<WzVectorProperty>(name);
|
|
393
|
+
vecProp->SetParent(parent);
|
|
394
|
+
vecProp->X =
|
|
395
|
+
std::make_unique<WzIntProperty>("X", reader->ReadCompressedInt());
|
|
396
|
+
vecProp->X->SetParent(vecProp.get());
|
|
397
|
+
vecProp->Y =
|
|
398
|
+
std::make_unique<WzIntProperty>("Y", reader->ReadCompressedInt());
|
|
399
|
+
vecProp->Y->SetParent(vecProp.get());
|
|
400
|
+
return vecProp;
|
|
401
|
+
} else if (iname == "Shape2D#Convex2D") {
|
|
402
|
+
auto convexProp = std::make_unique<WzConvexProperty>(name);
|
|
403
|
+
convexProp->SetParent(parent);
|
|
404
|
+
int convexEntryCount = reader->ReadCompressedInt();
|
|
405
|
+
for (int j = 0; j < convexEntryCount; j++) {
|
|
406
|
+
auto entryProp =
|
|
407
|
+
ParseExtendedProp(offset, reader, name, convexProp.get(), parentImg);
|
|
408
|
+
if (!entryProp.has_value()) {
|
|
409
|
+
return std::unexpected(entryProp.error());
|
|
410
|
+
}
|
|
411
|
+
convexProp->WzProperties()->Add(std::move(entryProp.value()));
|
|
412
|
+
}
|
|
413
|
+
return convexProp;
|
|
414
|
+
} else if (iname == "Sound_DX8") {
|
|
415
|
+
auto soundProp = std::make_unique<WzBinaryProperty>(
|
|
416
|
+
name, reader, parentImg->ParseEverything());
|
|
417
|
+
soundProp->SetParent(parent);
|
|
418
|
+
return soundProp;
|
|
419
|
+
} else if (iname == "UOL") {
|
|
420
|
+
reader->ReadByte();
|
|
421
|
+
uint8_t uolType = reader->ReadByte();
|
|
422
|
+
if (uolType == 0) {
|
|
423
|
+
auto uolProp =
|
|
424
|
+
std::make_unique<WzUOLProperty>(name, reader->ReadString());
|
|
425
|
+
uolProp->SetParent(parent);
|
|
426
|
+
return uolProp;
|
|
427
|
+
} else if (uolType == 1) {
|
|
428
|
+
auto uolProp = std::make_unique<WzUOLProperty>(
|
|
429
|
+
name, reader->ReadStringAtOffset(offset + reader->ReadInt32()));
|
|
430
|
+
uolProp->SetParent(parent);
|
|
431
|
+
return uolProp;
|
|
432
|
+
}
|
|
433
|
+
return std::unexpected(Error::ParseError("Unsupported UOL type"));
|
|
434
|
+
} else if (iname == WzRawDataProperty::RAW_DATA_HEADER) {
|
|
435
|
+
uint8_t rawType = reader->ReadByte();
|
|
436
|
+
auto rawProp = std::make_unique<WzRawDataProperty>(name, reader, rawType);
|
|
437
|
+
rawProp->SetParent(parent);
|
|
438
|
+
if (rawType == 1) {
|
|
439
|
+
if (reader->ReadByte() == 1) {
|
|
440
|
+
reader->SetPosition(reader->Position() + 2);
|
|
441
|
+
auto r = ParsePropertyList(offset, reader, rawProp.get(), parentImg);
|
|
442
|
+
if (!r.has_value()) return std::unexpected(r.error());
|
|
443
|
+
for (auto& child : r.value().TakeItems()) {
|
|
444
|
+
rawProp->WzProperties()->Add(std::move(child));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
rawProp->Parse(parentImg->ParseEverything());
|
|
449
|
+
return rawProp;
|
|
450
|
+
} else if (iname == WzVideoProperty::CANVAS_VIDEO_HEADER) {
|
|
451
|
+
auto videoProp = std::make_unique<WzVideoProperty>(name, reader);
|
|
452
|
+
videoProp->SetParent(parent);
|
|
453
|
+
reader->ReadByte();
|
|
454
|
+
if (reader->ReadByte() == 1) {
|
|
455
|
+
reader->SetPosition(reader->Position() + 2);
|
|
456
|
+
auto r = ParsePropertyList(offset, reader, videoProp.get(), parentImg);
|
|
457
|
+
if (!r.has_value()) return std::unexpected(r.error());
|
|
458
|
+
for (auto& child : r.value().TakeItems()) {
|
|
459
|
+
videoProp->WzProperties()->Add(std::move(child));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
videoProp->Parse(parentImg->ParseEverything());
|
|
463
|
+
return videoProp;
|
|
464
|
+
} else {
|
|
465
|
+
return std::unexpected(Error::ParseError("Unknown iname: " + iname));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
} // namespace wz
|
package/src/WzObject.cpp
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#include "wz/WzObject.h"
|
|
2
|
+
#include <cctype>
|
|
3
|
+
|
|
4
|
+
#include <algorithm>
|
|
5
|
+
|
|
6
|
+
#include "wz/WzDirectory.h"
|
|
7
|
+
#include "wz/WzFile.h"
|
|
8
|
+
#include "wz/WzImage.h"
|
|
9
|
+
#include "wz/WzImageProperty.h"
|
|
10
|
+
#include "wz/WzPropertyCollection.h"
|
|
11
|
+
|
|
12
|
+
namespace wz {
|
|
13
|
+
|
|
14
|
+
namespace {
|
|
15
|
+
|
|
16
|
+
std::string ToLower(const std::string& s) {
|
|
17
|
+
std::string r = s;
|
|
18
|
+
std::transform(r.begin(), r.end(), r.begin(), [](unsigned char c) {
|
|
19
|
+
return static_cast<char>(std::tolower(c));
|
|
20
|
+
});
|
|
21
|
+
return r;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Result<WzImageProperty*> FindSiblingPropertyByName(WzObject* parent,
|
|
25
|
+
const std::string& name,
|
|
26
|
+
const WzObject* self) {
|
|
27
|
+
WzPropertyCollection* properties = nullptr;
|
|
28
|
+
if (parent->ObjectType() == WzObjectType::Image) {
|
|
29
|
+
auto result = static_cast<WzImage*>(parent)->WzPropertiesResult();
|
|
30
|
+
if (!result.has_value()) return std::unexpected(result.error());
|
|
31
|
+
properties = result.value();
|
|
32
|
+
} else if (parent->ObjectType() == WzObjectType::Property) {
|
|
33
|
+
properties = static_cast<WzImageProperty*>(parent)->WzProperties();
|
|
34
|
+
}
|
|
35
|
+
if (!properties) return nullptr;
|
|
36
|
+
|
|
37
|
+
const std::string lower = ToLower(name);
|
|
38
|
+
for (auto* prop : *properties) {
|
|
39
|
+
if (prop != self && ToLower(prop->Name()) == lower) return prop;
|
|
40
|
+
}
|
|
41
|
+
return nullptr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace
|
|
45
|
+
|
|
46
|
+
WzFile* WzObject::WzFileParent() const {
|
|
47
|
+
if (parent_) return parent_->WzFileParent();
|
|
48
|
+
return nullptr;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Result<void> WzObject::Rename(const std::string& name) {
|
|
52
|
+
if (name.empty()) {
|
|
53
|
+
return std::unexpected(
|
|
54
|
+
Error::InvalidArgument("WZ object name cannot be empty"));
|
|
55
|
+
}
|
|
56
|
+
if (name_ == name) return {};
|
|
57
|
+
if (parent_) {
|
|
58
|
+
switch (ObjectType()) {
|
|
59
|
+
case WzObjectType::Directory: {
|
|
60
|
+
if (parent_->ObjectType() != WzObjectType::Directory) break;
|
|
61
|
+
auto* parentDir = static_cast<WzDirectory*>(parent_);
|
|
62
|
+
auto* existing = parentDir->GetDirectoryByName(name);
|
|
63
|
+
if (existing && existing != this) {
|
|
64
|
+
return std::unexpected(
|
|
65
|
+
Error::InvalidArgument("Duplicate WZ directory name: " + name));
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
case WzObjectType::Image: {
|
|
70
|
+
if (parent_->ObjectType() != WzObjectType::Directory) break;
|
|
71
|
+
auto* parentDir = static_cast<WzDirectory*>(parent_);
|
|
72
|
+
auto* existing = parentDir->GetImageByName(name);
|
|
73
|
+
if (existing && existing != this) {
|
|
74
|
+
return std::unexpected(
|
|
75
|
+
Error::InvalidArgument("Duplicate WZ image name: " + name));
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case WzObjectType::Property: {
|
|
80
|
+
auto result = FindSiblingPropertyByName(parent_, name, this);
|
|
81
|
+
if (!result.has_value()) return std::unexpected(result.error());
|
|
82
|
+
WzImageProperty* existing = result.value();
|
|
83
|
+
if (existing && existing != this) {
|
|
84
|
+
return std::unexpected(Error::InvalidArgument(
|
|
85
|
+
"Duplicate WZ image property name: " + name));
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
default:
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
name_ = name;
|
|
94
|
+
if (ObjectType() == WzObjectType::Property) {
|
|
95
|
+
static_cast<WzImageProperty*>(this)->MarkParentImageChanged();
|
|
96
|
+
}
|
|
97
|
+
return {};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Result<std::unique_ptr<WzObject>> WzObject::Remove() {
|
|
101
|
+
return std::unique_ptr<WzObject>();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
std::string WzObject::FullPath() const {
|
|
105
|
+
if (ObjectType() == WzObjectType::File) {
|
|
106
|
+
auto* file = static_cast<const WzFile*>(this);
|
|
107
|
+
if (file && file->GetWzDirectory()) return file->GetWzDirectory()->Name();
|
|
108
|
+
}
|
|
109
|
+
std::string result = Name();
|
|
110
|
+
auto* currObj = parent_;
|
|
111
|
+
while (currObj) {
|
|
112
|
+
result = currObj->Name() + "\\" + result;
|
|
113
|
+
currObj = currObj->Parent();
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
WzObject* WzObject::GetTopMostWzDirectory() {
|
|
119
|
+
auto* p = Parent();
|
|
120
|
+
if (!p) return this;
|
|
121
|
+
while (p->Parent()) p = p->Parent();
|
|
122
|
+
return p;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
WzObject* WzObject::GetTopMostWzImage() {
|
|
126
|
+
auto* p = Parent();
|
|
127
|
+
if (!p) return this;
|
|
128
|
+
while (p->Parent()) {
|
|
129
|
+
p = p->Parent();
|
|
130
|
+
if (p->ObjectType() == WzObjectType::Image) return p;
|
|
131
|
+
}
|
|
132
|
+
return p;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
int32_t WzObject::GetInt() const {
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
int16_t WzObject::GetShort() const {
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
int64_t WzObject::GetLong() const {
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
float WzObject::GetFloat() const {
|
|
145
|
+
return 0.0f;
|
|
146
|
+
}
|
|
147
|
+
double WzObject::GetDouble() const {
|
|
148
|
+
return 0.0;
|
|
149
|
+
}
|
|
150
|
+
std::string WzObject::GetString() const {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
Result<std::vector<uint8_t>> WzObject::GetBytes() {
|
|
154
|
+
return std::unexpected(Error::NotImplemented());
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
WzObject* WzObject::operator[](const std::string& name) {
|
|
158
|
+
switch (ObjectType()) {
|
|
159
|
+
case WzObjectType::File: {
|
|
160
|
+
auto* f = static_cast<WzFile*>(this);
|
|
161
|
+
return f->GetWzDirectory() ? (*f->GetWzDirectory())[name] : nullptr;
|
|
162
|
+
}
|
|
163
|
+
case WzObjectType::Directory:
|
|
164
|
+
return static_cast<WzDirectory*>(this)->operator[](name);
|
|
165
|
+
case WzObjectType::Image:
|
|
166
|
+
return static_cast<WzImage*>(this)->operator[](name);
|
|
167
|
+
case WzObjectType::Property:
|
|
168
|
+
return static_cast<WzImageProperty*>(this)->operator[](name);
|
|
169
|
+
default:
|
|
170
|
+
return nullptr;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
} // namespace wz
|