rj_schema 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rj_schema/rapidjson/CMakeLists.txt +9 -4
- data/ext/rj_schema/rapidjson/RapidJSONConfig.cmake.in +10 -0
- data/ext/rj_schema/rapidjson/appveyor.yml +22 -9
- data/ext/rj_schema/rapidjson/bin/data/abcde.txt +1 -0
- data/ext/rj_schema/rapidjson/bin/unittestschema/address.json +139 -0
- data/ext/rj_schema/rapidjson/bin/unittestschema/allOf_address.json +7 -0
- data/ext/rj_schema/rapidjson/bin/unittestschema/anyOf_address.json +7 -0
- data/ext/rj_schema/rapidjson/bin/unittestschema/oneOf_address.json +7 -0
- data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +2 -2
- data/ext/rj_schema/rapidjson/doc/dom.md +1 -0
- data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +1 -0
- data/ext/rj_schema/rapidjson/doc/faq.md +3 -3
- data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +8 -8
- data/ext/rj_schema/rapidjson/doc/internals.md +1 -1
- data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +2 -2
- data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +1 -1
- data/ext/rj_schema/rapidjson/doc/sax.md +1 -1
- data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +2 -2
- data/ext/rj_schema/rapidjson/doc/stream.md +1 -1
- data/ext/rj_schema/rapidjson/doc/tutorial.md +1 -1
- data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +7 -6
- data/ext/rj_schema/rapidjson/example/CMakeLists.txt +1 -0
- data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +118 -0
- data/ext/rj_schema/rapidjson/example/sortkeys/sortkeys.cpp +62 -0
- data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +6 -6
- data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/document.h +124 -35
- data/ext/rj_schema/rapidjson/include/rapidjson/encodedstream.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/error/en.h +49 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/error/error.h +56 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/filereadstream.h +2 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/filewritestream.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/fwd.h +2 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +2 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/clzll.h +71 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +3 -17
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +20 -13
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +4 -3
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +50 -35
- data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +63 -5
- data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +2 -2
- data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +63 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +67 -53
- data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +318 -164
- data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +1 -1
- data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +10 -10
- data/ext/rj_schema/rapidjson/readme.md +51 -1
- data/ext/rj_schema/rapidjson/readme.zh-cn.md +2 -2
- data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/perftest/perftest.h +1 -1
- data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +2 -2
- data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +75 -1
- data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +1 -0
- data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/clzlltest.cpp +34 -0
- data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +19 -19
- data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +45 -2
- data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +10 -10
- data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +8 -8
- data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +157 -16
- data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +113 -75
- data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +2 -1
- data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +593 -78
- data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +5 -5
- data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +1 -1
- data/ext/rj_schema/rapidjson/test/unittest/unittest.h +4 -1
- data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +12 -12
- data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/BUILD.bazel +175 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/CMakeLists.txt +18 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/CONTRIBUTING.md +160 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/LICENSE +28 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/Makefile.am +14 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/README.md +16 -35
- data/ext/rj_schema/rapidjson/thirdparty/gtest/WORKSPACE +8 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/appveyor.yml +104 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-autotools.sh +44 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-bazel.sh +36 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-linux.sh +41 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-osx.sh +40 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/get-nprocessors.sh +48 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-linux.sh +49 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-osx.sh +39 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/log-config.sh +51 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/travis.sh +44 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/configure.ac +16 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CHANGES +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CMakeLists.txt +72 -32
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/README.md +53 -42
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock.pc.in +9 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock_main.pc.in +9 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/configure.ac +4 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CheatSheet.md +6 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CookBook.md +117 -132
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/Documentation.md +7 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/ForDummies.md +20 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/FrequentlyAskedQuestions.md +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-actions.h +83 -26
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h +262 -68
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h.pump +45 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h +650 -366
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +76 -20
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h +308 -229
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h.pump +18 -15
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h +87 -26
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +33 -16
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-matchers.h +1209 -353
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-matchers.h +33 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-spec-builders.h +159 -88
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock.h +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-matchers.h +3 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h +16 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-internal-utils.h +71 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-port.h +7 -11
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.sln +14 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.vcxproj +69 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_config.props +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_main.vcxproj +69 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_test.vcxproj +83 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.sln +14 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.vcxproj +63 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_main.vcxproj +63 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_test.vcxproj +76 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/fuse_gmock_files.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README +4 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/ast.py +3 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-cardinalities.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-internal-utils.cc +36 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-matchers.cc +210 -135
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-spec-builders.cc +108 -48
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock.cc +23 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/BUILD.bazel +123 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-actions_test.cc +166 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-cardinalities_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-actions_test.cc +64 -62
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-function-mockers_test.cc +43 -18
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-internal-utils_test.cc +11 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-matchers_test.cc +91 -36
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-internal-utils_test.cc +33 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-matchers_test.cc +1286 -167
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-more-actions_test.cc +85 -83
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-nice-strict_test.cc +102 -15
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-spec-builders_test.cc +136 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link2_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.h +24 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test.py +8 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_.cc +20 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_golden.txt +8 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_stress_test.cc +3 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test.cc +44 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test_utils.py +5 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CMakeLists.txt +40 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/Makefile.am +60 -31
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/README.md +232 -171
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest.pc.in +9 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest_main.pc.in +10 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/internal_utils.cmake +54 -16
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/configure.ac +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Pkgconfig.md +146 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/PumpManual.md +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/XcodeGuide.md +6 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{AdvancedGuide.md → advanced.md} +260 -26
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{FAQ.md → faq.md} +62 -57
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{Primer.md → primer.md} +43 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{Samples.md → samples.md} +0 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-death-test.h +53 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-message.h +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h +30 -36
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h.pump +8 -17
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-printers.h +140 -51
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-spi.h +2 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-typed-test.h +4 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest.h +126 -30
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_pred_impl.h +6 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_prod.h +8 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-port.h +6 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest.h +4 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-death-test-internal.h +13 -57
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-filepath.h +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-internal.h +98 -59
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h +34 -41
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +3 -10
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util.h +9 -17
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port-arch.h +8 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port.h +232 -99
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-string.h +3 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h +17 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h.pump +17 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.sln +55 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj +149 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.sln +55 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj +149 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj +154 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj +162 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj +199 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj.filters +26 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj +191 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj.filters +26 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj +188 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj +180 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj.filters +18 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/prime_tables.h +6 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample10_unittest.cc +0 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1_unittest.cc +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2_unittest.cc +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3_unittest.cc +7 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4_unittest.cc +5 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample5_unittest.cc +3 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample6_unittest.cc +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample7_unittest.cc +10 -22
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample8_unittest.cc +2 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample9_unittest.cc +0 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/fuse_gtest_files.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gen_gtest_pred_impl.py +10 -10
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-all.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-death-test.cc +226 -32
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-filepath.cc +5 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-internal-inl.h +21 -29
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-port.cc +85 -67
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-printers.cc +93 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-test-part.cc +1 -9
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-typed-test.cc +1 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest.cc +622 -164
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest_main.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/BUILD.bazel +396 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_test.cc +12 -15
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-filepath_test.cc +2 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-listener_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-options_test.cc +6 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test2_test.cc +1 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.cc +84 -29
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.h +1 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-port_test.cc +11 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-printers_test.cc +165 -63
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test2_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-unittest-api_test.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_all_test.cc +13 -13
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_assert_by_exception_test.cc +119 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest.py +1 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest_.cc +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test.py +0 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test_.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test.py +1 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test_.cc +0 -8
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test.py +6 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test_.cc +0 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_environment_test.cc +0 -3
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest.py +20 -18
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest_.cc +0 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_outfiles_test.py +162 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_output_unittest.py +611 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_test_utils.py +60 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest.py +4 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_main_unittest.cc +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test.py +11 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_.cc +17 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_golden_lin.txt +104 -66
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_pred_impl_unittest.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_prod_test.cc +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_repeat_test.cc +2 -19
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_stress_test.cc +0 -6
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_test_utils.py +12 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test.py +65 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test_.cc +44 -0
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test.py +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test.py +4 -5
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test_.cc +2 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_unittest.cc +240 -149
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile1_test_.cc +0 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile2_test_.cc +0 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfiles_test.py +15 -7
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest.py +100 -30
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest_.cc +0 -2
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_test_utils.py +25 -23
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.cc +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.h +1 -1
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/versiongenerate.py +4 -4
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/gtest.xcodeproj/project.pbxproj +47 -0
- data/ext/rj_schema/rapidjson/travis-doxygen.sh +13 -6
- data/ext/rj_schema/rj_schema.cpp +161 -17
- data/lib/rj_schema.rb +1 -1
- metadata +63 -58
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/DevGuide.md +0 -132
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CheatSheet.md +0 -525
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CookBook.md +0 -3250
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/Documentation.md +0 -11
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/ForDummies.md +0 -439
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/FrequentlyAskedQuestions.md +0 -624
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CheatSheet.md +0 -534
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CookBook.md +0 -3342
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/Documentation.md +0 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/ForDummies.md +0 -439
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/FrequentlyAskedQuestions.md +0 -628
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CheatSheet.md +0 -556
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CookBook.md +0 -3432
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/Documentation.md +0 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/ForDummies.md +0 -439
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/FrequentlyAskedQuestions.md +0 -628
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/DevGuide.md +0 -126
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Documentation.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_AdvancedGuide.md +0 -2096
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Documentation.md +0 -12
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_FAQ.md +0 -886
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Primer.md +0 -497
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_PumpManual.md +0 -177
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_XcodeGuide.md +0 -93
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_AdvancedGuide.md +0 -2178
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Documentation.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_FAQ.md +0 -1038
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Primer.md +0 -501
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_PumpManual.md +0 -177
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Samples.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_XcodeGuide.md +0 -93
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_AdvancedGuide.md +0 -2181
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Documentation.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_FAQ.md +0 -1082
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Primer.md +0 -501
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_PumpManual.md +0 -177
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Samples.md +0 -14
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_XcodeGuide.md +0 -93
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.sln +0 -45
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.vcproj +0 -126
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.sln +0 -45
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.vcproj +0 -126
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main-md.vcproj +0 -129
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main.vcproj +0 -129
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test-md.vcproj +0 -164
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test.vcproj +0 -164
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest-md.vcproj +0 -147
- data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest.vcproj +0 -147
- data/ext/rj_schema/rapidjson/thirdparty/gtest/travis.sh +0 -15
@@ -127,7 +127,7 @@ Due to users' requests, RapidJSON provided official wrappers for `std::basic_ist
|
|
127
127
|
|
128
128
|
## IStreamWrapper {#IStreamWrapper}
|
129
129
|
|
130
|
-
`IStreamWrapper` wraps any class
|
130
|
+
`IStreamWrapper` wraps any class derived from `std::istream`, such as `std::istringstream`, `std::stringstream`, `std::ifstream`, `std::fstream`, into RapidJSON's input stream.
|
131
131
|
|
132
132
|
~~~cpp
|
133
133
|
#include <rapidjson/document.h>
|
@@ -82,7 +82,7 @@ JSON number type represents all numeric values. However, C++ needs more specific
|
|
82
82
|
~~~~~~~~~~cpp
|
83
83
|
assert(document["i"].IsNumber());
|
84
84
|
|
85
|
-
// In this case, IsUint()/IsInt64()/
|
85
|
+
// In this case, IsUint()/IsInt64()/IsUint64() also return true.
|
86
86
|
assert(document["i"].IsInt());
|
87
87
|
printf("i = %d\n", document["i"].GetInt());
|
88
88
|
// Alternative (int)document["i"]
|
@@ -82,7 +82,7 @@ JSON Number 类型表示所有数值。然而,C++ 需要使用更专门的类
|
|
82
82
|
~~~~~~~~~~cpp
|
83
83
|
assert(document["i"].IsNumber());
|
84
84
|
|
85
|
-
// 在此情况下,IsUint()/IsInt64()/
|
85
|
+
// 在此情况下,IsUint()/IsInt64()/IsUint64() 也会返回 true
|
86
86
|
assert(document["i"].IsInt());
|
87
87
|
printf("i = %d\n", document["i"].GetInt());
|
88
88
|
// 另一种用法: (int)document["i"]
|
@@ -250,7 +250,7 @@ string(const char* s, size_t count);
|
|
250
250
|
|
251
251
|
~~~~~~~~~~cpp
|
252
252
|
if (document["hello"] == document["n"]) /*...*/; // 比较两个值
|
253
|
-
if (document["hello"] == "world") /*...*/; //
|
253
|
+
if (document["hello"] == "world") /*...*/; // 与字符串字面量作比较
|
254
254
|
if (document["i"] != 123) /*...*/; // 与整数作比较
|
255
255
|
if (document["pi"] != 3.14) /*...*/; // 与 double 作比较
|
256
256
|
~~~~~~~~~~
|
@@ -294,7 +294,7 @@ Value a(kArrayType);
|
|
294
294
|
|
295
295
|
## 转移语义(Move Semantics) {#MoveSemantics}
|
296
296
|
|
297
|
-
在设计 RapidJSON 时有一个非常特别的决定,就是 Value 赋值并不是把来源 Value 复制至目的 Value
|
297
|
+
在设计 RapidJSON 时有一个非常特别的决定,就是 Value 赋值并不是把来源 Value 复制至目的 Value,而是把来源 Value 转移(move)至目的 Value。例如:
|
298
298
|
|
299
299
|
~~~~~~~~~~cpp
|
300
300
|
Value a(123);
|
@@ -383,11 +383,12 @@ memset(buffer, 0, sizeof(buffer));
|
|
383
383
|
|
384
384
|
另外,上面的 `SetString()` 需要长度参数。这个 API 能处理含有空字符的字符串。另一个 `SetString()` 重载函数没有长度参数,它假设输入是空字符结尾的,并会调用类似 `strlen()` 的函数去获取长度。
|
385
385
|
|
386
|
-
最后,对于字符串字面量或有安全生命周期的字符串,可以使用 const-string 版本的 `SetString()`,它没有
|
386
|
+
最后,对于字符串字面量或有安全生命周期的字符串,可以使用 const-string 版本的 `SetString()`,它没有
|
387
|
+
allocator 参数。对于字符串字面量(或字符数组常量),只需简单地传递字面量,又安全又高效:
|
387
388
|
|
388
389
|
~~~~~~~~~~cpp
|
389
390
|
Value s;
|
390
|
-
s.SetString("rapidjson"); //
|
391
|
+
s.SetString("rapidjson"); // 可包含空字符,长度在编译期推导
|
391
392
|
s = "rapidjson"; // 上行的缩写
|
392
393
|
~~~~~~~~~~
|
393
394
|
|
@@ -446,7 +447,7 @@ contact.PushBack(val, document.GetAllocator());
|
|
446
447
|
~~~~~~~~~~
|
447
448
|
|
448
449
|
## 修改 Object {#ModifyObject}
|
449
|
-
Object 是键值对的集合。每个键必须为 String。要修改 Object,方法是增加或移除成员。以下的 API
|
450
|
+
Object 是键值对的集合。每个键必须为 String。要修改 Object,方法是增加或移除成员。以下的 API 用来增加成员:
|
450
451
|
|
451
452
|
* `Value& AddMember(Value&, Value&, Allocator& allocator)`
|
452
453
|
* `Value& AddMember(StringRefType, Value&, Allocator&)`
|
@@ -7,9 +7,124 @@
|
|
7
7
|
#include "rapidjson/schema.h"
|
8
8
|
#include "rapidjson/stringbuffer.h"
|
9
9
|
#include "rapidjson/prettywriter.h"
|
10
|
+
#include <string>
|
11
|
+
#include <iostream>
|
12
|
+
#include <sstream>
|
10
13
|
|
11
14
|
using namespace rapidjson;
|
12
15
|
|
16
|
+
typedef GenericValue<UTF8<>, CrtAllocator > ValueType;
|
17
|
+
|
18
|
+
// Forward ref
|
19
|
+
static void CreateErrorMessages(const ValueType& errors, size_t depth, const char* context);
|
20
|
+
|
21
|
+
// Convert GenericValue to std::string
|
22
|
+
static std::string GetString(const ValueType& val) {
|
23
|
+
std::ostringstream s;
|
24
|
+
if (val.IsString())
|
25
|
+
s << val.GetString();
|
26
|
+
else if (val.IsDouble())
|
27
|
+
s << val.GetDouble();
|
28
|
+
else if (val.IsUint())
|
29
|
+
s << val.GetUint();
|
30
|
+
else if (val.IsInt())
|
31
|
+
s << val.GetInt();
|
32
|
+
else if (val.IsUint64())
|
33
|
+
s << val.GetUint64();
|
34
|
+
else if (val.IsInt64())
|
35
|
+
s << val.GetInt64();
|
36
|
+
else if (val.IsBool() && val.GetBool())
|
37
|
+
s << "true";
|
38
|
+
else if (val.IsBool())
|
39
|
+
s << "false";
|
40
|
+
else if (val.IsFloat())
|
41
|
+
s << val.GetFloat();
|
42
|
+
return s.str();}
|
43
|
+
|
44
|
+
// Create the error message for a named error
|
45
|
+
// The error object can either be empty or contain at least member properties:
|
46
|
+
// {"errorCode": <code>, "instanceRef": "<pointer>", "schemaRef": "<pointer>" }
|
47
|
+
// Additional properties may be present for use as inserts.
|
48
|
+
// An "errors" property may be present if there are child errors.
|
49
|
+
static void HandleError(const char* errorName, const ValueType& error, size_t depth, const char* context) {
|
50
|
+
if (!error.ObjectEmpty()) {
|
51
|
+
// Get error code and look up error message text (English)
|
52
|
+
int code = error["errorCode"].GetInt();
|
53
|
+
std::string message(GetValidateError_En(static_cast<ValidateErrorCode>(code)));
|
54
|
+
// For each member property in the error, see if its name exists as an insert in the error message and if so replace with the stringified property value
|
55
|
+
// So for example - "Number '%actual' is not a multiple of the 'multipleOf' value '%expected'." - we would expect "actual" and "expected" members.
|
56
|
+
for (ValueType::ConstMemberIterator insertsItr = error.MemberBegin();
|
57
|
+
insertsItr != error.MemberEnd(); ++insertsItr) {
|
58
|
+
std::string insertName("%");
|
59
|
+
insertName += insertsItr->name.GetString(); // eg "%actual"
|
60
|
+
size_t insertPos = message.find(insertName);
|
61
|
+
if (insertPos != std::string::npos) {
|
62
|
+
std::string insertString("");
|
63
|
+
const ValueType &insert = insertsItr->value;
|
64
|
+
if (insert.IsArray()) {
|
65
|
+
// Member is an array so create comma-separated list of items for the insert string
|
66
|
+
for (ValueType::ConstValueIterator itemsItr = insert.Begin(); itemsItr != insert.End(); ++itemsItr) {
|
67
|
+
if (itemsItr != insert.Begin()) insertString += ",";
|
68
|
+
insertString += GetString(*itemsItr);
|
69
|
+
}
|
70
|
+
} else {
|
71
|
+
insertString += GetString(insert);
|
72
|
+
}
|
73
|
+
message.replace(insertPos, insertName.length(), insertString);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
// Output error message, references, context
|
77
|
+
std::string indent(depth * 2, ' ');
|
78
|
+
std::cout << indent << "Error Name: " << errorName << std::endl;
|
79
|
+
std::cout << indent << "Message: " << message.c_str() << std::endl;
|
80
|
+
std::cout << indent << "Instance: " << error["instanceRef"].GetString() << std::endl;
|
81
|
+
std::cout << indent << "Schema: " << error["schemaRef"].GetString() << std::endl;
|
82
|
+
if (depth > 0) std::cout << indent << "Context: " << context << std::endl;
|
83
|
+
std::cout << std::endl;
|
84
|
+
|
85
|
+
// If child errors exist, apply the process recursively to each error structure.
|
86
|
+
// This occurs for "oneOf", "allOf", "anyOf" and "dependencies" errors, so pass the error name as context.
|
87
|
+
if (error.HasMember("errors")) {
|
88
|
+
depth++;
|
89
|
+
const ValueType &childErrors = error["errors"];
|
90
|
+
if (childErrors.IsArray()) {
|
91
|
+
// Array - each item is an error structure - example
|
92
|
+
// "anyOf": {"errorCode": ..., "errors":[{"pattern": {"errorCode\": ...\"}}, {"pattern": {"errorCode\": ...}}]
|
93
|
+
for (ValueType::ConstValueIterator errorsItr = childErrors.Begin();
|
94
|
+
errorsItr != childErrors.End(); ++errorsItr) {
|
95
|
+
CreateErrorMessages(*errorsItr, depth, errorName);
|
96
|
+
}
|
97
|
+
} else if (childErrors.IsObject()) {
|
98
|
+
// Object - each member is an error structure - example
|
99
|
+
// "dependencies": {"errorCode": ..., "errors": {"address": {"required": {"errorCode": ...}}, "name": {"required": {"errorCode": ...}}}
|
100
|
+
for (ValueType::ConstMemberIterator propsItr = childErrors.MemberBegin();
|
101
|
+
propsItr != childErrors.MemberEnd(); ++propsItr) {
|
102
|
+
CreateErrorMessages(propsItr->value, depth, errorName);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
// Create error message for all errors in an error structure
|
110
|
+
// Context is used to indicate whether the error structure has a parent 'dependencies', 'allOf', 'anyOf' or 'oneOf' error
|
111
|
+
static void CreateErrorMessages(const ValueType& errors, size_t depth = 0, const char* context = 0) {
|
112
|
+
// Each member property contains one or more errors of a given type
|
113
|
+
for (ValueType::ConstMemberIterator errorTypeItr = errors.MemberBegin(); errorTypeItr != errors.MemberEnd(); ++errorTypeItr) {
|
114
|
+
const char* errorName = errorTypeItr->name.GetString();
|
115
|
+
const ValueType& errorContent = errorTypeItr->value;
|
116
|
+
if (errorContent.IsArray()) {
|
117
|
+
// Member is an array where each item is an error - eg "type": [{"errorCode": ...}, {"errorCode": ...}]
|
118
|
+
for (ValueType::ConstValueIterator contentItr = errorContent.Begin(); contentItr != errorContent.End(); ++contentItr) {
|
119
|
+
HandleError(errorName, *contentItr, depth, context);
|
120
|
+
}
|
121
|
+
} else if (errorContent.IsObject()) {
|
122
|
+
// Member is an object which is a single error - eg "type": {"errorCode": ... }
|
123
|
+
HandleError(errorName, errorContent, depth, context);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
13
128
|
int main(int argc, char *argv[]) {
|
14
129
|
if (argc != 2) {
|
15
130
|
fprintf(stderr, "Usage: schemavalidator schema.json < input.json\n");
|
@@ -65,6 +180,8 @@ int main(int argc, char *argv[]) {
|
|
65
180
|
validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);
|
66
181
|
fprintf(stderr, "Invalid schema: %s\n", sb.GetString());
|
67
182
|
fprintf(stderr, "Invalid keyword: %s\n", validator.GetInvalidSchemaKeyword());
|
183
|
+
fprintf(stderr, "Invalid code: %d\n", validator.GetInvalidSchemaCode());
|
184
|
+
fprintf(stderr, "Invalid message: %s\n", GetValidateError_En(validator.GetInvalidSchemaCode()));
|
68
185
|
sb.Clear();
|
69
186
|
validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);
|
70
187
|
fprintf(stderr, "Invalid document: %s\n", sb.GetString());
|
@@ -73,6 +190,7 @@ int main(int argc, char *argv[]) {
|
|
73
190
|
PrettyWriter<StringBuffer> w(sb);
|
74
191
|
validator.GetError().Accept(w);
|
75
192
|
fprintf(stderr, "Error report:\n%s\n", sb.GetString());
|
193
|
+
CreateErrorMessages(validator.GetError());
|
76
194
|
return EXIT_FAILURE;
|
77
195
|
}
|
78
196
|
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#include "rapidjson/document.h"
|
2
|
+
#include "rapidjson/filewritestream.h"
|
3
|
+
#include <rapidjson/prettywriter.h>
|
4
|
+
|
5
|
+
#include <algorithm>
|
6
|
+
#include <iostream>
|
7
|
+
|
8
|
+
using namespace rapidjson;
|
9
|
+
using namespace std;
|
10
|
+
|
11
|
+
static void printIt(const Value &doc) {
|
12
|
+
char writeBuffer[65536];
|
13
|
+
FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));
|
14
|
+
PrettyWriter<FileWriteStream> writer(os);
|
15
|
+
doc.Accept(writer);
|
16
|
+
cout << endl;
|
17
|
+
}
|
18
|
+
|
19
|
+
struct NameComparator {
|
20
|
+
bool operator()(const Value::Member &lhs, const Value::Member &rhs) const {
|
21
|
+
return (strcmp(lhs.name.GetString(), rhs.name.GetString()) < 0);
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
int main() {
|
26
|
+
Document d(kObjectType);
|
27
|
+
Document::AllocatorType &allocator = d.GetAllocator();
|
28
|
+
|
29
|
+
d.AddMember("zeta", Value().SetBool(false), allocator);
|
30
|
+
d.AddMember("gama", Value().SetString("test string", allocator), allocator);
|
31
|
+
d.AddMember("delta", Value().SetInt(123), allocator);
|
32
|
+
d.AddMember("alpha", Value(kArrayType).Move(), allocator);
|
33
|
+
|
34
|
+
printIt(d);
|
35
|
+
|
36
|
+
/*
|
37
|
+
{
|
38
|
+
"zeta": false,
|
39
|
+
"gama": "test string",
|
40
|
+
"delta": 123,
|
41
|
+
"alpha": []
|
42
|
+
}
|
43
|
+
*/
|
44
|
+
|
45
|
+
// C++11 supports std::move() of Value so it always have no problem for std::sort().
|
46
|
+
// Some C++03 implementations of std::sort() requires copy constructor which causes compilation error.
|
47
|
+
// Needs a sorting function only depends on std::swap() instead.
|
48
|
+
#if __cplusplus >= 201103L || (!defined(__GLIBCXX__) && (!defined(_MSC_VER) || _MSC_VER >= 1900))
|
49
|
+
std::sort(d.MemberBegin(), d.MemberEnd(), NameComparator());
|
50
|
+
|
51
|
+
printIt(d);
|
52
|
+
|
53
|
+
/*
|
54
|
+
{
|
55
|
+
"alpha": [],
|
56
|
+
"delta": 123,
|
57
|
+
"gama": "test string",
|
58
|
+
"zeta": false
|
59
|
+
}
|
60
|
+
*/
|
61
|
+
#endif
|
62
|
+
}
|
@@ -57,7 +57,7 @@ int main(int, char*[]) {
|
|
57
57
|
printf("n = %s\n", document["n"].IsNull() ? "null" : "?");
|
58
58
|
|
59
59
|
assert(document["i"].IsNumber()); // Number is a JSON type, but C++ needs more specific type.
|
60
|
-
assert(document["i"].IsInt()); // In this case, IsUint()/IsInt64()/
|
60
|
+
assert(document["i"].IsInt()); // In this case, IsUint()/IsInt64()/IsUint64() also return true.
|
61
61
|
printf("i = %d\n", document["i"].GetInt()); // Alternative (int)document["i"]
|
62
62
|
|
63
63
|
assert(document["pi"].IsNumber());
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// Tencent is pleased to support the open source community by making RapidJSON available.
|
2
2
|
//
|
3
|
-
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
|
3
|
+
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
|
4
4
|
//
|
5
5
|
// Licensed under the MIT License (the "License"); you may not use this file except
|
6
6
|
// in compliance with the License. You may obtain a copy of the License at
|
@@ -53,7 +53,7 @@ concept Allocator {
|
|
53
53
|
*/
|
54
54
|
|
55
55
|
|
56
|
-
/*! \def
|
56
|
+
/*! \def RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY
|
57
57
|
\ingroup RAPIDJSON_CONFIG
|
58
58
|
\brief User-defined kDefaultChunkCapacity definition.
|
59
59
|
|
@@ -77,19 +77,19 @@ public:
|
|
77
77
|
static const bool kNeedFree = true;
|
78
78
|
void* Malloc(size_t size) {
|
79
79
|
if (size) // behavior of malloc(0) is implementation defined.
|
80
|
-
return
|
80
|
+
return RAPIDJSON_MALLOC(size);
|
81
81
|
else
|
82
82
|
return NULL; // standardize to returning NULL.
|
83
83
|
}
|
84
84
|
void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {
|
85
85
|
(void)originalSize;
|
86
86
|
if (newSize == 0) {
|
87
|
-
|
87
|
+
RAPIDJSON_FREE(originalPtr);
|
88
88
|
return NULL;
|
89
89
|
}
|
90
|
-
return
|
90
|
+
return RAPIDJSON_REALLOC(originalPtr, newSize);
|
91
91
|
}
|
92
|
-
static void Free(void *ptr) {
|
92
|
+
static void Free(void *ptr) { RAPIDJSON_FREE(ptr); }
|
93
93
|
};
|
94
94
|
|
95
95
|
///////////////////////////////////////////////////////////////////////////////
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// Tencent is pleased to support the open source community by making RapidJSON available.
|
2
2
|
//
|
3
|
-
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
|
3
|
+
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
|
4
4
|
//
|
5
5
|
// Licensed under the MIT License (the "License"); you may not use this file except
|
6
6
|
// in compliance with the License. You may obtain a copy of the License at
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// Tencent is pleased to support the open source community by making RapidJSON available.
|
2
2
|
//
|
3
|
-
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
|
3
|
+
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
|
4
4
|
//
|
5
5
|
// Licensed under the MIT License (the "License"); you may not use this file except
|
6
6
|
// in compliance with the License. You may obtain a copy of the License at
|
@@ -24,6 +24,9 @@
|
|
24
24
|
#include "encodedstream.h"
|
25
25
|
#include <new> // placement new
|
26
26
|
#include <limits>
|
27
|
+
#ifdef __cpp_lib_three_way_comparison
|
28
|
+
#include <compare>
|
29
|
+
#endif
|
27
30
|
|
28
31
|
RAPIDJSON_DIAG_PUSH
|
29
32
|
#ifdef __clang__
|
@@ -37,9 +40,6 @@ RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible lo
|
|
37
40
|
|
38
41
|
#ifdef __GNUC__
|
39
42
|
RAPIDJSON_DIAG_OFF(effc++)
|
40
|
-
#if __GNUC__ >= 6
|
41
|
-
RAPIDJSON_DIAG_OFF(terminate) // ignore throwing RAPIDJSON_ASSERT in RAPIDJSON_NOEXCEPT functions
|
42
|
-
#endif
|
43
43
|
#endif // __GNUC__
|
44
44
|
|
45
45
|
#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
|
@@ -59,6 +59,48 @@ class GenericValue;
|
|
59
59
|
template <typename Encoding, typename Allocator, typename StackAllocator>
|
60
60
|
class GenericDocument;
|
61
61
|
|
62
|
+
/*! \def RAPIDJSON_DEFAULT_ALLOCATOR
|
63
|
+
\ingroup RAPIDJSON_CONFIG
|
64
|
+
\brief Allows to choose default allocator.
|
65
|
+
|
66
|
+
User can define this to use CrtAllocator or MemoryPoolAllocator.
|
67
|
+
*/
|
68
|
+
#ifndef RAPIDJSON_DEFAULT_ALLOCATOR
|
69
|
+
#define RAPIDJSON_DEFAULT_ALLOCATOR MemoryPoolAllocator<CrtAllocator>
|
70
|
+
#endif
|
71
|
+
|
72
|
+
/*! \def RAPIDJSON_DEFAULT_STACK_ALLOCATOR
|
73
|
+
\ingroup RAPIDJSON_CONFIG
|
74
|
+
\brief Allows to choose default stack allocator for Document.
|
75
|
+
|
76
|
+
User can define this to use CrtAllocator or MemoryPoolAllocator.
|
77
|
+
*/
|
78
|
+
#ifndef RAPIDJSON_DEFAULT_STACK_ALLOCATOR
|
79
|
+
#define RAPIDJSON_DEFAULT_STACK_ALLOCATOR CrtAllocator
|
80
|
+
#endif
|
81
|
+
|
82
|
+
/*! \def RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
|
83
|
+
\ingroup RAPIDJSON_CONFIG
|
84
|
+
\brief User defined kDefaultObjectCapacity value.
|
85
|
+
|
86
|
+
User can define this as any natural number.
|
87
|
+
*/
|
88
|
+
#ifndef RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY
|
89
|
+
// number of objects that rapidjson::Value allocates memory for by default
|
90
|
+
#define RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY 16
|
91
|
+
#endif
|
92
|
+
|
93
|
+
/*! \def RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY
|
94
|
+
\ingroup RAPIDJSON_CONFIG
|
95
|
+
\brief User defined kDefaultArrayCapacity value.
|
96
|
+
|
97
|
+
User can define this as any natural number.
|
98
|
+
*/
|
99
|
+
#ifndef RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY
|
100
|
+
// number of array elements that rapidjson::Value allocates memory for by default
|
101
|
+
#define RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY 16
|
102
|
+
#endif
|
103
|
+
|
62
104
|
//! Name-value pair in a JSON object value.
|
63
105
|
/*!
|
64
106
|
This class was internal to GenericValue. It used to be a inner struct.
|
@@ -66,9 +108,45 @@ class GenericDocument;
|
|
66
108
|
https://code.google.com/p/rapidjson/issues/detail?id=64
|
67
109
|
*/
|
68
110
|
template <typename Encoding, typename Allocator>
|
69
|
-
|
111
|
+
class GenericMember {
|
112
|
+
public:
|
70
113
|
GenericValue<Encoding, Allocator> name; //!< name of member (must be a string)
|
71
114
|
GenericValue<Encoding, Allocator> value; //!< value of member.
|
115
|
+
|
116
|
+
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
117
|
+
//! Move constructor in C++11
|
118
|
+
GenericMember(GenericMember&& rhs) RAPIDJSON_NOEXCEPT
|
119
|
+
: name(std::move(rhs.name)),
|
120
|
+
value(std::move(rhs.value))
|
121
|
+
{
|
122
|
+
}
|
123
|
+
|
124
|
+
//! Move assignment in C++11
|
125
|
+
GenericMember& operator=(GenericMember&& rhs) RAPIDJSON_NOEXCEPT {
|
126
|
+
return *this = static_cast<GenericMember&>(rhs);
|
127
|
+
}
|
128
|
+
#endif
|
129
|
+
|
130
|
+
//! Assignment with move semantics.
|
131
|
+
/*! \param rhs Source of the assignment. Its name and value will become a null value after assignment.
|
132
|
+
*/
|
133
|
+
GenericMember& operator=(GenericMember& rhs) RAPIDJSON_NOEXCEPT {
|
134
|
+
if (RAPIDJSON_LIKELY(this != &rhs)) {
|
135
|
+
name = rhs.name;
|
136
|
+
value = rhs.value;
|
137
|
+
}
|
138
|
+
return *this;
|
139
|
+
}
|
140
|
+
|
141
|
+
// swap() for std::sort() and other potential use in STL.
|
142
|
+
friend inline void swap(GenericMember& a, GenericMember& b) RAPIDJSON_NOEXCEPT {
|
143
|
+
a.name.Swap(b.name);
|
144
|
+
a.value.Swap(b.value);
|
145
|
+
}
|
146
|
+
|
147
|
+
private:
|
148
|
+
//! Copy constructor is not permitted.
|
149
|
+
GenericMember(const GenericMember& rhs);
|
72
150
|
};
|
73
151
|
|
74
152
|
///////////////////////////////////////////////////////////////////////////////
|
@@ -172,12 +250,16 @@ public:
|
|
172
250
|
|
173
251
|
//! @name relations
|
174
252
|
//@{
|
175
|
-
bool operator==(
|
176
|
-
bool operator!=(
|
177
|
-
bool operator<=(
|
178
|
-
bool operator>=(
|
179
|
-
bool operator< (
|
180
|
-
bool operator> (
|
253
|
+
template <bool Const_> bool operator==(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ == that.ptr_; }
|
254
|
+
template <bool Const_> bool operator!=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ != that.ptr_; }
|
255
|
+
template <bool Const_> bool operator<=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <= that.ptr_; }
|
256
|
+
template <bool Const_> bool operator>=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ >= that.ptr_; }
|
257
|
+
template <bool Const_> bool operator< (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ < that.ptr_; }
|
258
|
+
template <bool Const_> bool operator> (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ > that.ptr_; }
|
259
|
+
|
260
|
+
#ifdef __cpp_lib_three_way_comparison
|
261
|
+
template <bool Const_> std::strong_ordering operator<=>(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <=> that.ptr_; }
|
262
|
+
#endif
|
181
263
|
//@}
|
182
264
|
|
183
265
|
//! @name dereference
|
@@ -202,17 +284,19 @@ private:
|
|
202
284
|
// class-based member iterator implementation disabled, use plain pointers
|
203
285
|
|
204
286
|
template <bool Const, typename Encoding, typename Allocator>
|
205
|
-
|
287
|
+
class GenericMemberIterator;
|
206
288
|
|
207
289
|
//! non-const GenericMemberIterator
|
208
290
|
template <typename Encoding, typename Allocator>
|
209
|
-
|
291
|
+
class GenericMemberIterator<false,Encoding,Allocator> {
|
292
|
+
public:
|
210
293
|
//! use plain pointer as iterator type
|
211
294
|
typedef GenericMember<Encoding,Allocator>* Iterator;
|
212
295
|
};
|
213
296
|
//! const GenericMemberIterator
|
214
297
|
template <typename Encoding, typename Allocator>
|
215
|
-
|
298
|
+
class GenericMemberIterator<true,Encoding,Allocator> {
|
299
|
+
public:
|
216
300
|
//! use plain const pointer as iterator type
|
217
301
|
typedef const GenericMember<Encoding,Allocator>* Iterator;
|
218
302
|
};
|
@@ -571,7 +655,7 @@ template <bool, typename> class GenericObject;
|
|
571
655
|
\tparam Encoding Encoding of the value. (Even non-string values need to have the same encoding in a document)
|
572
656
|
\tparam Allocator Allocator type for allocating memory of object, array and string.
|
573
657
|
*/
|
574
|
-
template <typename Encoding, typename Allocator =
|
658
|
+
template <typename Encoding, typename Allocator = RAPIDJSON_DEFAULT_ALLOCATOR >
|
575
659
|
class GenericValue {
|
576
660
|
public:
|
577
661
|
//! Name-value pair in an object.
|
@@ -625,11 +709,11 @@ public:
|
|
625
709
|
\note Default content for number is zero.
|
626
710
|
*/
|
627
711
|
explicit GenericValue(Type type) RAPIDJSON_NOEXCEPT : data_() {
|
628
|
-
static const uint16_t defaultFlags[
|
712
|
+
static const uint16_t defaultFlags[] = {
|
629
713
|
kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kShortStringFlag,
|
630
714
|
kNumberAnyFlag
|
631
715
|
};
|
632
|
-
|
716
|
+
RAPIDJSON_NOEXCEPT_ASSERT(type >= kNullType && type <= kNumberType);
|
633
717
|
data_.f.flags = defaultFlags[type];
|
634
718
|
|
635
719
|
// Use ShortString to store empty string.
|
@@ -831,9 +915,10 @@ public:
|
|
831
915
|
/*! \param rhs Source of the assignment. It will become a null value after assignment.
|
832
916
|
*/
|
833
917
|
GenericValue& operator=(GenericValue& rhs) RAPIDJSON_NOEXCEPT {
|
834
|
-
|
835
|
-
|
836
|
-
|
918
|
+
if (RAPIDJSON_LIKELY(this != &rhs)) {
|
919
|
+
this->~GenericValue();
|
920
|
+
RawAssign(rhs);
|
921
|
+
}
|
837
922
|
return *this;
|
838
923
|
}
|
839
924
|
|
@@ -925,7 +1010,7 @@ public:
|
|
925
1010
|
//! Equal-to operator
|
926
1011
|
/*!
|
927
1012
|
\note If an object contains duplicated named member, comparing equality with any object is always \c false.
|
928
|
-
\note
|
1013
|
+
\note Complexity is quadratic in Object's member number and linear for the rest (number of all values in the subtree and total lengths of all strings).
|
929
1014
|
*/
|
930
1015
|
template <typename SourceAllocator>
|
931
1016
|
bool operator==(const GenericValue<Encoding, SourceAllocator>& rhs) const {
|
@@ -1918,25 +2003,26 @@ private:
|
|
1918
2003
|
|
1919
2004
|
// Initial flags of different types.
|
1920
2005
|
kNullFlag = kNullType,
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
2006
|
+
// These casts are added to suppress the warning on MSVC about bitwise operations between enums of different types.
|
2007
|
+
kTrueFlag = static_cast<int>(kTrueType) | static_cast<int>(kBoolFlag),
|
2008
|
+
kFalseFlag = static_cast<int>(kFalseType) | static_cast<int>(kBoolFlag),
|
2009
|
+
kNumberIntFlag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kIntFlag | kInt64Flag),
|
2010
|
+
kNumberUintFlag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag),
|
2011
|
+
kNumberInt64Flag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kInt64Flag),
|
2012
|
+
kNumberUint64Flag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kUint64Flag),
|
2013
|
+
kNumberDoubleFlag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kDoubleFlag),
|
2014
|
+
kNumberAnyFlag = static_cast<int>(kNumberType) | static_cast<int>(kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag),
|
2015
|
+
kConstStringFlag = static_cast<int>(kStringType) | static_cast<int>(kStringFlag),
|
2016
|
+
kCopyStringFlag = static_cast<int>(kStringType) | static_cast<int>(kStringFlag | kCopyFlag),
|
2017
|
+
kShortStringFlag = static_cast<int>(kStringType) | static_cast<int>(kStringFlag | kCopyFlag | kInlineStrFlag),
|
1932
2018
|
kObjectFlag = kObjectType,
|
1933
2019
|
kArrayFlag = kArrayType,
|
1934
2020
|
|
1935
2021
|
kTypeMask = 0x07
|
1936
2022
|
};
|
1937
2023
|
|
1938
|
-
static const SizeType kDefaultArrayCapacity =
|
1939
|
-
static const SizeType kDefaultObjectCapacity =
|
2024
|
+
static const SizeType kDefaultArrayCapacity = RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY;
|
2025
|
+
static const SizeType kDefaultObjectCapacity = RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY;
|
1940
2026
|
|
1941
2027
|
struct Flag {
|
1942
2028
|
#if RAPIDJSON_48BITPOINTER_OPTIMIZATION
|
@@ -2116,7 +2202,7 @@ typedef GenericValue<UTF8<> > Value;
|
|
2116
2202
|
\tparam StackAllocator Allocator for allocating memory for stack during parsing.
|
2117
2203
|
\warning Although GenericDocument inherits from GenericValue, the API does \b not provide any virtual functions, especially no virtual destructor. To avoid memory leaks, do not \c delete a GenericDocument object via a pointer to a GenericValue.
|
2118
2204
|
*/
|
2119
|
-
template <typename Encoding, typename Allocator =
|
2205
|
+
template <typename Encoding, typename Allocator = RAPIDJSON_DEFAULT_ALLOCATOR, typename StackAllocator = RAPIDJSON_DEFAULT_STACK_ALLOCATOR >
|
2120
2206
|
class GenericDocument : public GenericValue<Encoding, Allocator> {
|
2121
2207
|
public:
|
2122
2208
|
typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding.
|
@@ -2501,6 +2587,7 @@ private:
|
|
2501
2587
|
//! GenericDocument with UTF8 encoding
|
2502
2588
|
typedef GenericDocument<UTF8<> > Document;
|
2503
2589
|
|
2590
|
+
|
2504
2591
|
//! Helper class for accessing Value of array type.
|
2505
2592
|
/*!
|
2506
2593
|
Instance of this helper class is obtained by \c GenericValue::GetArray().
|
@@ -2525,6 +2612,7 @@ public:
|
|
2525
2612
|
GenericArray& operator=(const GenericArray& rhs) { value_ = rhs.value_; return *this; }
|
2526
2613
|
~GenericArray() {}
|
2527
2614
|
|
2615
|
+
operator ValueType&() const { return value_; }
|
2528
2616
|
SizeType Size() const { return value_.Size(); }
|
2529
2617
|
SizeType Capacity() const { return value_.Capacity(); }
|
2530
2618
|
bool Empty() const { return value_.Empty(); }
|
@@ -2580,6 +2668,7 @@ public:
|
|
2580
2668
|
GenericObject& operator=(const GenericObject& rhs) { value_ = rhs.value_; return *this; }
|
2581
2669
|
~GenericObject() {}
|
2582
2670
|
|
2671
|
+
operator ValueType&() const { return value_; }
|
2583
2672
|
SizeType MemberCount() const { return value_.MemberCount(); }
|
2584
2673
|
SizeType MemberCapacity() const { return value_.MemberCapacity(); }
|
2585
2674
|
bool ObjectEmpty() const { return value_.ObjectEmpty(); }
|