rj_schema 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +18 -0
- data/ext/rj_schema/extconf.rb +7 -0
- data/ext/rj_schema/rapidjson/CHANGELOG.md +158 -0
- data/ext/rj_schema/rapidjson/CMakeLists.txt +221 -0
- data/ext/rj_schema/rapidjson/CMakeModules/FindGTestSrc.cmake +30 -0
- data/ext/rj_schema/rapidjson/RapidJSON.pc.in +7 -0
- data/ext/rj_schema/rapidjson/RapidJSONConfig.cmake.in +15 -0
- data/ext/rj_schema/rapidjson/RapidJSONConfigVersion.cmake.in +10 -0
- data/ext/rj_schema/rapidjson/appveyor.yml +41 -0
- data/ext/rj_schema/rapidjson/bin/data/glossary.json +22 -0
- data/ext/rj_schema/rapidjson/bin/data/menu.json +27 -0
- data/ext/rj_schema/rapidjson/bin/data/readme.txt +1 -0
- data/ext/rj_schema/rapidjson/bin/data/sample.json +3315 -0
- data/ext/rj_schema/rapidjson/bin/data/webapp.json +88 -0
- data/ext/rj_schema/rapidjson/bin/data/widget.json +26 -0
- data/ext/rj_schema/rapidjson/bin/draft-04/schema +150 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf16be.json +0 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf16bebom.json +0 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf16le.json +0 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf16lebom.json +0 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf32be.json +0 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf32bebom.json +0 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf32le.json +0 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf32lebom.json +0 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf8.json +7 -0
- data/ext/rj_schema/rapidjson/bin/encodings/utf8bom.json +7 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail1.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail10.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail11.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail12.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail13.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail14.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail15.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail16.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail17.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail18.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail19.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail2.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail20.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail21.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail22.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail23.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail24.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail25.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail26.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail27.json +2 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail28.json +2 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail29.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail3.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail30.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail31.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail32.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail33.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail4.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail5.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail6.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail7.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail8.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/fail9.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/pass1.json +58 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/pass2.json +1 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/pass3.json +6 -0
- data/ext/rj_schema/rapidjson/bin/jsonchecker/readme.txt +3 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/LICENSE +19 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/README.md +148 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/bin/jsonschema_suite +283 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/folder/folderInteger.json +3 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/integer.json +3 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/subSchemas.json +8 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/additionalItems.json +82 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/additionalProperties.json +88 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/default.json +49 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/dependencies.json +108 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/disallow.json +80 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/divisibleBy.json +60 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/enum.json +71 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/extends.json +94 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/items.json +46 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maxItems.json +28 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maxLength.json +33 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maximum.json +42 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minItems.json +28 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minLength.json +33 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minimum.json +42 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/bignum.json +107 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/format.json +222 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/jsregex.json +18 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/zeroTerminatedFloats.json +15 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/pattern.json +34 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/patternProperties.json +110 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/properties.json +92 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/ref.json +159 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/refRemote.json +74 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/required.json +53 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/type.json +474 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/uniqueItems.json +79 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/additionalItems.json +82 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/additionalProperties.json +88 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/allOf.json +112 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/anyOf.json +68 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/default.json +49 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/definitions.json +32 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/dependencies.json +113 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/enum.json +72 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/items.json +46 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxItems.json +28 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxLength.json +33 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxProperties.json +28 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maximum.json +42 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minItems.json +28 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minLength.json +33 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minProperties.json +28 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minimum.json +42 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/multipleOf.json +60 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/not.json +96 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/oneOf.json +68 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/bignum.json +107 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/format.json +148 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/zeroTerminatedFloats.json +15 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/pattern.json +34 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/patternProperties.json +110 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/properties.json +92 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/ref.json +159 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/refRemote.json +74 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/required.json +39 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/type.json +330 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/uniqueItems.json +79 -0
- data/ext/rj_schema/rapidjson/bin/jsonschema/tox.ini +8 -0
- data/ext/rj_schema/rapidjson/bin/types/booleans.json +102 -0
- data/ext/rj_schema/rapidjson/bin/types/floats.json +102 -0
- data/ext/rj_schema/rapidjson/bin/types/guids.json +102 -0
- data/ext/rj_schema/rapidjson/bin/types/integers.json +102 -0
- data/ext/rj_schema/rapidjson/bin/types/mixed.json +592 -0
- data/ext/rj_schema/rapidjson/bin/types/nulls.json +102 -0
- data/ext/rj_schema/rapidjson/bin/types/paragraphs.json +102 -0
- data/ext/rj_schema/rapidjson/bin/types/readme.txt +1 -0
- data/ext/rj_schema/rapidjson/contrib/natvis/LICENSE +45 -0
- data/ext/rj_schema/rapidjson/contrib/natvis/README.md +7 -0
- data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +38 -0
- data/ext/rj_schema/rapidjson/doc/CMakeLists.txt +27 -0
- data/ext/rj_schema/rapidjson/doc/Doxyfile.in +2369 -0
- data/ext/rj_schema/rapidjson/doc/Doxyfile.zh-cn.in +2369 -0
- data/ext/rj_schema/rapidjson/doc/diagram/architecture.dot +50 -0
- data/ext/rj_schema/rapidjson/doc/diagram/architecture.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.dot +65 -0
- data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.dot +62 -0
- data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/makefile +8 -0
- data/ext/rj_schema/rapidjson/doc/diagram/move1.dot +47 -0
- data/ext/rj_schema/rapidjson/doc/diagram/move1.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/move2.dot +62 -0
- data/ext/rj_schema/rapidjson/doc/diagram/move2.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/move3.dot +60 -0
- data/ext/rj_schema/rapidjson/doc/diagram/move3.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.dot +56 -0
- data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/simpledom.dot +54 -0
- data/ext/rj_schema/rapidjson/doc/diagram/simpledom.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/tutorial.dot +58 -0
- data/ext/rj_schema/rapidjson/doc/diagram/tutorial.png +0 -0
- data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.dot +73 -0
- data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.png +0 -0
- data/ext/rj_schema/rapidjson/doc/dom.md +280 -0
- data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +284 -0
- data/ext/rj_schema/rapidjson/doc/encoding.md +146 -0
- data/ext/rj_schema/rapidjson/doc/encoding.zh-cn.md +152 -0
- data/ext/rj_schema/rapidjson/doc/faq.md +289 -0
- data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +290 -0
- data/ext/rj_schema/rapidjson/doc/features.md +104 -0
- data/ext/rj_schema/rapidjson/doc/features.zh-cn.md +103 -0
- data/ext/rj_schema/rapidjson/doc/internals.md +368 -0
- data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +363 -0
- data/ext/rj_schema/rapidjson/doc/logo/rapidjson.png +0 -0
- data/ext/rj_schema/rapidjson/doc/logo/rapidjson.svg +119 -0
- data/ext/rj_schema/rapidjson/doc/misc/DoxygenLayout.xml +194 -0
- data/ext/rj_schema/rapidjson/doc/misc/doxygenextra.css +274 -0
- data/ext/rj_schema/rapidjson/doc/misc/footer.html +11 -0
- data/ext/rj_schema/rapidjson/doc/misc/header.html +24 -0
- data/ext/rj_schema/rapidjson/doc/npm.md +31 -0
- data/ext/rj_schema/rapidjson/doc/performance.md +26 -0
- data/ext/rj_schema/rapidjson/doc/performance.zh-cn.md +26 -0
- data/ext/rj_schema/rapidjson/doc/pointer.md +234 -0
- data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +234 -0
- data/ext/rj_schema/rapidjson/doc/sax.md +509 -0
- data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +487 -0
- data/ext/rj_schema/rapidjson/doc/schema.md +505 -0
- data/ext/rj_schema/rapidjson/doc/schema.zh-cn.md +237 -0
- data/ext/rj_schema/rapidjson/doc/stream.md +426 -0
- data/ext/rj_schema/rapidjson/doc/stream.zh-cn.md +426 -0
- data/ext/rj_schema/rapidjson/doc/tutorial.md +536 -0
- data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +534 -0
- data/ext/rj_schema/rapidjson/docker/debian/Dockerfile +8 -0
- data/ext/rj_schema/rapidjson/example/CMakeLists.txt +45 -0
- data/ext/rj_schema/rapidjson/example/archiver/archiver.cpp +292 -0
- data/ext/rj_schema/rapidjson/example/archiver/archiver.h +145 -0
- data/ext/rj_schema/rapidjson/example/archiver/archivertest.cpp +287 -0
- data/ext/rj_schema/rapidjson/example/capitalize/capitalize.cpp +67 -0
- data/ext/rj_schema/rapidjson/example/condense/condense.cpp +32 -0
- data/ext/rj_schema/rapidjson/example/filterkey/filterkey.cpp +135 -0
- data/ext/rj_schema/rapidjson/example/filterkeydom/filterkeydom.cpp +170 -0
- data/ext/rj_schema/rapidjson/example/jsonx/jsonx.cpp +207 -0
- data/ext/rj_schema/rapidjson/example/lookaheadparser/lookaheadparser.cpp +350 -0
- data/ext/rj_schema/rapidjson/example/messagereader/messagereader.cpp +105 -0
- data/ext/rj_schema/rapidjson/example/parsebyparts/parsebyparts.cpp +176 -0
- data/ext/rj_schema/rapidjson/example/pretty/pretty.cpp +30 -0
- data/ext/rj_schema/rapidjson/example/prettyauto/prettyauto.cpp +56 -0
- data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +78 -0
- data/ext/rj_schema/rapidjson/example/serialize/serialize.cpp +173 -0
- data/ext/rj_schema/rapidjson/example/simpledom/simpledom.cpp +29 -0
- data/ext/rj_schema/rapidjson/example/simplepullreader/simplepullreader.cpp +53 -0
- data/ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp +42 -0
- data/ext/rj_schema/rapidjson/example/simplewriter/simplewriter.cpp +36 -0
- data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +151 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +271 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +78 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/document.h +2630 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/encodedstream.h +299 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +716 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/error/en.h +74 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/error/error.h +161 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/filereadstream.h +99 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/filewritestream.h +104 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/fwd.h +151 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +290 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +258 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +245 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +78 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +304 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +181 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +55 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +734 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +231 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +69 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +269 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +46 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +115 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +70 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +71 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/inttypes.h +316 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/stdint.h +300 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +81 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +1363 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +277 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +628 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +2222 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +2479 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +223 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +121 -0
- data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +716 -0
- data/ext/rj_schema/rapidjson/include_dirs.js +2 -0
- data/ext/rj_schema/rapidjson/library.json +15 -0
- data/ext/rj_schema/rapidjson/license.txt +57 -0
- data/ext/rj_schema/rapidjson/package.json +24 -0
- data/ext/rj_schema/rapidjson/rapidjson.autopkg +77 -0
- data/ext/rj_schema/rapidjson/readme.md +160 -0
- data/ext/rj_schema/rapidjson/readme.zh-cn.md +152 -0
- data/ext/rj_schema/rapidjson/test/CMakeLists.txt +20 -0
- data/ext/rj_schema/rapidjson/test/perftest/CMakeLists.txt +28 -0
- data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +974 -0
- data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +24 -0
- data/ext/rj_schema/rapidjson/test/perftest/perftest.h +185 -0
- data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +166 -0
- data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +472 -0
- data/ext/rj_schema/rapidjson/test/perftest/schematest.cpp +216 -0
- data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +92 -0
- data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +102 -0
- data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +133 -0
- data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +115 -0
- data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +672 -0
- data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +98 -0
- data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +313 -0
- data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +451 -0
- data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +112 -0
- data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +230 -0
- data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +181 -0
- data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +160 -0
- data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +143 -0
- data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +70 -0
- data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +92 -0
- data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +1529 -0
- data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +344 -0
- data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +1895 -0
- data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +638 -0
- data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +2009 -0
- data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +219 -0
- data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +30 -0
- data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +192 -0
- data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +132 -0
- data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +51 -0
- data/ext/rj_schema/rapidjson/test/unittest/unittest.h +140 -0
- data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +1829 -0
- data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +598 -0
- data/ext/rj_schema/rapidjson/test/valgrind.supp +17 -0
- data/ext/rj_schema/rapidjson/travis-doxygen.sh +121 -0
- data/ext/rj_schema/rj_schema.cpp +136 -0
- data/lib/rj_schema.rb +7 -0
- metadata +371 -0
@@ -0,0 +1,231 @@
|
|
1
|
+
// Tencent is pleased to support the open source community by making RapidJSON available.
|
2
|
+
//
|
3
|
+
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
|
4
|
+
//
|
5
|
+
// Licensed under the MIT License (the "License"); you may not use this file except
|
6
|
+
// in compliance with the License. You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://opensource.org/licenses/MIT
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software distributed
|
11
|
+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
12
|
+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
13
|
+
// specific language governing permissions and limitations under the License.
|
14
|
+
|
15
|
+
#ifndef RAPIDJSON_INTERNAL_STACK_H_
|
16
|
+
#define RAPIDJSON_INTERNAL_STACK_H_
|
17
|
+
|
18
|
+
#include "../allocators.h"
|
19
|
+
#include "swap.h"
|
20
|
+
|
21
|
+
#if defined(__clang__)
|
22
|
+
RAPIDJSON_DIAG_PUSH
|
23
|
+
RAPIDJSON_DIAG_OFF(c++98-compat)
|
24
|
+
#endif
|
25
|
+
|
26
|
+
RAPIDJSON_NAMESPACE_BEGIN
|
27
|
+
namespace internal {
|
28
|
+
|
29
|
+
///////////////////////////////////////////////////////////////////////////////
|
30
|
+
// Stack
|
31
|
+
|
32
|
+
//! A type-unsafe stack for storing different types of data.
|
33
|
+
/*! \tparam Allocator Allocator for allocating stack memory.
|
34
|
+
*/
|
35
|
+
template <typename Allocator>
|
36
|
+
class Stack {
|
37
|
+
public:
|
38
|
+
// Optimization note: Do not allocate memory for stack_ in constructor.
|
39
|
+
// Do it lazily when first Push() -> Expand() -> Resize().
|
40
|
+
Stack(Allocator* allocator, size_t stackCapacity) : allocator_(allocator), ownAllocator_(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) {
|
41
|
+
}
|
42
|
+
|
43
|
+
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
44
|
+
Stack(Stack&& rhs)
|
45
|
+
: allocator_(rhs.allocator_),
|
46
|
+
ownAllocator_(rhs.ownAllocator_),
|
47
|
+
stack_(rhs.stack_),
|
48
|
+
stackTop_(rhs.stackTop_),
|
49
|
+
stackEnd_(rhs.stackEnd_),
|
50
|
+
initialCapacity_(rhs.initialCapacity_)
|
51
|
+
{
|
52
|
+
rhs.allocator_ = 0;
|
53
|
+
rhs.ownAllocator_ = 0;
|
54
|
+
rhs.stack_ = 0;
|
55
|
+
rhs.stackTop_ = 0;
|
56
|
+
rhs.stackEnd_ = 0;
|
57
|
+
rhs.initialCapacity_ = 0;
|
58
|
+
}
|
59
|
+
#endif
|
60
|
+
|
61
|
+
~Stack() {
|
62
|
+
Destroy();
|
63
|
+
}
|
64
|
+
|
65
|
+
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
|
66
|
+
Stack& operator=(Stack&& rhs) {
|
67
|
+
if (&rhs != this)
|
68
|
+
{
|
69
|
+
Destroy();
|
70
|
+
|
71
|
+
allocator_ = rhs.allocator_;
|
72
|
+
ownAllocator_ = rhs.ownAllocator_;
|
73
|
+
stack_ = rhs.stack_;
|
74
|
+
stackTop_ = rhs.stackTop_;
|
75
|
+
stackEnd_ = rhs.stackEnd_;
|
76
|
+
initialCapacity_ = rhs.initialCapacity_;
|
77
|
+
|
78
|
+
rhs.allocator_ = 0;
|
79
|
+
rhs.ownAllocator_ = 0;
|
80
|
+
rhs.stack_ = 0;
|
81
|
+
rhs.stackTop_ = 0;
|
82
|
+
rhs.stackEnd_ = 0;
|
83
|
+
rhs.initialCapacity_ = 0;
|
84
|
+
}
|
85
|
+
return *this;
|
86
|
+
}
|
87
|
+
#endif
|
88
|
+
|
89
|
+
void Swap(Stack& rhs) RAPIDJSON_NOEXCEPT {
|
90
|
+
internal::Swap(allocator_, rhs.allocator_);
|
91
|
+
internal::Swap(ownAllocator_, rhs.ownAllocator_);
|
92
|
+
internal::Swap(stack_, rhs.stack_);
|
93
|
+
internal::Swap(stackTop_, rhs.stackTop_);
|
94
|
+
internal::Swap(stackEnd_, rhs.stackEnd_);
|
95
|
+
internal::Swap(initialCapacity_, rhs.initialCapacity_);
|
96
|
+
}
|
97
|
+
|
98
|
+
void Clear() { stackTop_ = stack_; }
|
99
|
+
|
100
|
+
void ShrinkToFit() {
|
101
|
+
if (Empty()) {
|
102
|
+
// If the stack is empty, completely deallocate the memory.
|
103
|
+
Allocator::Free(stack_); // NOLINT (+clang-analyzer-unix.Malloc)
|
104
|
+
stack_ = 0;
|
105
|
+
stackTop_ = 0;
|
106
|
+
stackEnd_ = 0;
|
107
|
+
}
|
108
|
+
else
|
109
|
+
Resize(GetSize());
|
110
|
+
}
|
111
|
+
|
112
|
+
// Optimization note: try to minimize the size of this function for force inline.
|
113
|
+
// Expansion is run very infrequently, so it is moved to another (probably non-inline) function.
|
114
|
+
template<typename T>
|
115
|
+
RAPIDJSON_FORCEINLINE void Reserve(size_t count = 1) {
|
116
|
+
// Expand the stack if needed
|
117
|
+
if (RAPIDJSON_UNLIKELY(stackTop_ + sizeof(T) * count > stackEnd_))
|
118
|
+
Expand<T>(count);
|
119
|
+
}
|
120
|
+
|
121
|
+
template<typename T>
|
122
|
+
RAPIDJSON_FORCEINLINE T* Push(size_t count = 1) {
|
123
|
+
Reserve<T>(count);
|
124
|
+
return PushUnsafe<T>(count);
|
125
|
+
}
|
126
|
+
|
127
|
+
template<typename T>
|
128
|
+
RAPIDJSON_FORCEINLINE T* PushUnsafe(size_t count = 1) {
|
129
|
+
RAPIDJSON_ASSERT(stackTop_);
|
130
|
+
RAPIDJSON_ASSERT(stackTop_ + sizeof(T) * count <= stackEnd_);
|
131
|
+
T* ret = reinterpret_cast<T*>(stackTop_);
|
132
|
+
stackTop_ += sizeof(T) * count;
|
133
|
+
return ret;
|
134
|
+
}
|
135
|
+
|
136
|
+
template<typename T>
|
137
|
+
T* Pop(size_t count) {
|
138
|
+
RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T));
|
139
|
+
stackTop_ -= count * sizeof(T);
|
140
|
+
return reinterpret_cast<T*>(stackTop_);
|
141
|
+
}
|
142
|
+
|
143
|
+
template<typename T>
|
144
|
+
T* Top() {
|
145
|
+
RAPIDJSON_ASSERT(GetSize() >= sizeof(T));
|
146
|
+
return reinterpret_cast<T*>(stackTop_ - sizeof(T));
|
147
|
+
}
|
148
|
+
|
149
|
+
template<typename T>
|
150
|
+
const T* Top() const {
|
151
|
+
RAPIDJSON_ASSERT(GetSize() >= sizeof(T));
|
152
|
+
return reinterpret_cast<T*>(stackTop_ - sizeof(T));
|
153
|
+
}
|
154
|
+
|
155
|
+
template<typename T>
|
156
|
+
T* End() { return reinterpret_cast<T*>(stackTop_); }
|
157
|
+
|
158
|
+
template<typename T>
|
159
|
+
const T* End() const { return reinterpret_cast<T*>(stackTop_); }
|
160
|
+
|
161
|
+
template<typename T>
|
162
|
+
T* Bottom() { return reinterpret_cast<T*>(stack_); }
|
163
|
+
|
164
|
+
template<typename T>
|
165
|
+
const T* Bottom() const { return reinterpret_cast<T*>(stack_); }
|
166
|
+
|
167
|
+
bool HasAllocator() const {
|
168
|
+
return allocator_ != 0;
|
169
|
+
}
|
170
|
+
|
171
|
+
Allocator& GetAllocator() {
|
172
|
+
RAPIDJSON_ASSERT(allocator_);
|
173
|
+
return *allocator_;
|
174
|
+
}
|
175
|
+
|
176
|
+
bool Empty() const { return stackTop_ == stack_; }
|
177
|
+
size_t GetSize() const { return static_cast<size_t>(stackTop_ - stack_); }
|
178
|
+
size_t GetCapacity() const { return static_cast<size_t>(stackEnd_ - stack_); }
|
179
|
+
|
180
|
+
private:
|
181
|
+
template<typename T>
|
182
|
+
void Expand(size_t count) {
|
183
|
+
// Only expand the capacity if the current stack exists. Otherwise just create a stack with initial capacity.
|
184
|
+
size_t newCapacity;
|
185
|
+
if (stack_ == 0) {
|
186
|
+
if (!allocator_)
|
187
|
+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
|
188
|
+
newCapacity = initialCapacity_;
|
189
|
+
} else {
|
190
|
+
newCapacity = GetCapacity();
|
191
|
+
newCapacity += (newCapacity + 1) / 2;
|
192
|
+
}
|
193
|
+
size_t newSize = GetSize() + sizeof(T) * count;
|
194
|
+
if (newCapacity < newSize)
|
195
|
+
newCapacity = newSize;
|
196
|
+
|
197
|
+
Resize(newCapacity);
|
198
|
+
}
|
199
|
+
|
200
|
+
void Resize(size_t newCapacity) {
|
201
|
+
const size_t size = GetSize(); // Backup the current size
|
202
|
+
stack_ = static_cast<char*>(allocator_->Realloc(stack_, GetCapacity(), newCapacity));
|
203
|
+
stackTop_ = stack_ + size;
|
204
|
+
stackEnd_ = stack_ + newCapacity;
|
205
|
+
}
|
206
|
+
|
207
|
+
void Destroy() {
|
208
|
+
Allocator::Free(stack_);
|
209
|
+
RAPIDJSON_DELETE(ownAllocator_); // Only delete if it is owned by the stack
|
210
|
+
}
|
211
|
+
|
212
|
+
// Prohibit copy constructor & assignment operator.
|
213
|
+
Stack(const Stack&);
|
214
|
+
Stack& operator=(const Stack&);
|
215
|
+
|
216
|
+
Allocator* allocator_;
|
217
|
+
Allocator* ownAllocator_;
|
218
|
+
char *stack_;
|
219
|
+
char *stackTop_;
|
220
|
+
char *stackEnd_;
|
221
|
+
size_t initialCapacity_;
|
222
|
+
};
|
223
|
+
|
224
|
+
} // namespace internal
|
225
|
+
RAPIDJSON_NAMESPACE_END
|
226
|
+
|
227
|
+
#if defined(__clang__)
|
228
|
+
RAPIDJSON_DIAG_POP
|
229
|
+
#endif
|
230
|
+
|
231
|
+
#endif // RAPIDJSON_STACK_H_
|
@@ -0,0 +1,69 @@
|
|
1
|
+
// Tencent is pleased to support the open source community by making RapidJSON available.
|
2
|
+
//
|
3
|
+
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
|
4
|
+
//
|
5
|
+
// Licensed under the MIT License (the "License"); you may not use this file except
|
6
|
+
// in compliance with the License. You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://opensource.org/licenses/MIT
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software distributed
|
11
|
+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
12
|
+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
13
|
+
// specific language governing permissions and limitations under the License.
|
14
|
+
|
15
|
+
#ifndef RAPIDJSON_INTERNAL_STRFUNC_H_
|
16
|
+
#define RAPIDJSON_INTERNAL_STRFUNC_H_
|
17
|
+
|
18
|
+
#include "../stream.h"
|
19
|
+
#include <cwchar>
|
20
|
+
|
21
|
+
RAPIDJSON_NAMESPACE_BEGIN
|
22
|
+
namespace internal {
|
23
|
+
|
24
|
+
//! Custom strlen() which works on different character types.
|
25
|
+
/*! \tparam Ch Character type (e.g. char, wchar_t, short)
|
26
|
+
\param s Null-terminated input string.
|
27
|
+
\return Number of characters in the string.
|
28
|
+
\note This has the same semantics as strlen(), the return value is not number of Unicode codepoints.
|
29
|
+
*/
|
30
|
+
template <typename Ch>
|
31
|
+
inline SizeType StrLen(const Ch* s) {
|
32
|
+
RAPIDJSON_ASSERT(s != 0);
|
33
|
+
const Ch* p = s;
|
34
|
+
while (*p) ++p;
|
35
|
+
return SizeType(p - s);
|
36
|
+
}
|
37
|
+
|
38
|
+
template <>
|
39
|
+
inline SizeType StrLen(const char* s) {
|
40
|
+
return SizeType(std::strlen(s));
|
41
|
+
}
|
42
|
+
|
43
|
+
template <>
|
44
|
+
inline SizeType StrLen(const wchar_t* s) {
|
45
|
+
return SizeType(std::wcslen(s));
|
46
|
+
}
|
47
|
+
|
48
|
+
//! Returns number of code points in a encoded string.
|
49
|
+
template<typename Encoding>
|
50
|
+
bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) {
|
51
|
+
RAPIDJSON_ASSERT(s != 0);
|
52
|
+
RAPIDJSON_ASSERT(outCount != 0);
|
53
|
+
GenericStringStream<Encoding> is(s);
|
54
|
+
const typename Encoding::Ch* end = s + length;
|
55
|
+
SizeType count = 0;
|
56
|
+
while (is.src_ < end) {
|
57
|
+
unsigned codepoint;
|
58
|
+
if (!Encoding::Decode(is, &codepoint))
|
59
|
+
return false;
|
60
|
+
count++;
|
61
|
+
}
|
62
|
+
*outCount = count;
|
63
|
+
return true;
|
64
|
+
}
|
65
|
+
|
66
|
+
} // namespace internal
|
67
|
+
RAPIDJSON_NAMESPACE_END
|
68
|
+
|
69
|
+
#endif // RAPIDJSON_INTERNAL_STRFUNC_H_
|
@@ -0,0 +1,269 @@
|
|
1
|
+
// Tencent is pleased to support the open source community by making RapidJSON available.
|
2
|
+
//
|
3
|
+
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
|
4
|
+
//
|
5
|
+
// Licensed under the MIT License (the "License"); you may not use this file except
|
6
|
+
// in compliance with the License. You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://opensource.org/licenses/MIT
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software distributed
|
11
|
+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
12
|
+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
13
|
+
// specific language governing permissions and limitations under the License.
|
14
|
+
|
15
|
+
#ifndef RAPIDJSON_STRTOD_
|
16
|
+
#define RAPIDJSON_STRTOD_
|
17
|
+
|
18
|
+
#include "ieee754.h"
|
19
|
+
#include "biginteger.h"
|
20
|
+
#include "diyfp.h"
|
21
|
+
#include "pow10.h"
|
22
|
+
|
23
|
+
RAPIDJSON_NAMESPACE_BEGIN
|
24
|
+
namespace internal {
|
25
|
+
|
26
|
+
inline double FastPath(double significand, int exp) {
|
27
|
+
if (exp < -308)
|
28
|
+
return 0.0;
|
29
|
+
else if (exp >= 0)
|
30
|
+
return significand * internal::Pow10(exp);
|
31
|
+
else
|
32
|
+
return significand / internal::Pow10(-exp);
|
33
|
+
}
|
34
|
+
|
35
|
+
inline double StrtodNormalPrecision(double d, int p) {
|
36
|
+
if (p < -308) {
|
37
|
+
// Prevent expSum < -308, making Pow10(p) = 0
|
38
|
+
d = FastPath(d, -308);
|
39
|
+
d = FastPath(d, p + 308);
|
40
|
+
}
|
41
|
+
else
|
42
|
+
d = FastPath(d, p);
|
43
|
+
return d;
|
44
|
+
}
|
45
|
+
|
46
|
+
template <typename T>
|
47
|
+
inline T Min3(T a, T b, T c) {
|
48
|
+
T m = a;
|
49
|
+
if (m > b) m = b;
|
50
|
+
if (m > c) m = c;
|
51
|
+
return m;
|
52
|
+
}
|
53
|
+
|
54
|
+
inline int CheckWithinHalfULP(double b, const BigInteger& d, int dExp) {
|
55
|
+
const Double db(b);
|
56
|
+
const uint64_t bInt = db.IntegerSignificand();
|
57
|
+
const int bExp = db.IntegerExponent();
|
58
|
+
const int hExp = bExp - 1;
|
59
|
+
|
60
|
+
int dS_Exp2 = 0, dS_Exp5 = 0, bS_Exp2 = 0, bS_Exp5 = 0, hS_Exp2 = 0, hS_Exp5 = 0;
|
61
|
+
|
62
|
+
// Adjust for decimal exponent
|
63
|
+
if (dExp >= 0) {
|
64
|
+
dS_Exp2 += dExp;
|
65
|
+
dS_Exp5 += dExp;
|
66
|
+
}
|
67
|
+
else {
|
68
|
+
bS_Exp2 -= dExp;
|
69
|
+
bS_Exp5 -= dExp;
|
70
|
+
hS_Exp2 -= dExp;
|
71
|
+
hS_Exp5 -= dExp;
|
72
|
+
}
|
73
|
+
|
74
|
+
// Adjust for binary exponent
|
75
|
+
if (bExp >= 0)
|
76
|
+
bS_Exp2 += bExp;
|
77
|
+
else {
|
78
|
+
dS_Exp2 -= bExp;
|
79
|
+
hS_Exp2 -= bExp;
|
80
|
+
}
|
81
|
+
|
82
|
+
// Adjust for half ulp exponent
|
83
|
+
if (hExp >= 0)
|
84
|
+
hS_Exp2 += hExp;
|
85
|
+
else {
|
86
|
+
dS_Exp2 -= hExp;
|
87
|
+
bS_Exp2 -= hExp;
|
88
|
+
}
|
89
|
+
|
90
|
+
// Remove common power of two factor from all three scaled values
|
91
|
+
int common_Exp2 = Min3(dS_Exp2, bS_Exp2, hS_Exp2);
|
92
|
+
dS_Exp2 -= common_Exp2;
|
93
|
+
bS_Exp2 -= common_Exp2;
|
94
|
+
hS_Exp2 -= common_Exp2;
|
95
|
+
|
96
|
+
BigInteger dS = d;
|
97
|
+
dS.MultiplyPow5(static_cast<unsigned>(dS_Exp5)) <<= static_cast<unsigned>(dS_Exp2);
|
98
|
+
|
99
|
+
BigInteger bS(bInt);
|
100
|
+
bS.MultiplyPow5(static_cast<unsigned>(bS_Exp5)) <<= static_cast<unsigned>(bS_Exp2);
|
101
|
+
|
102
|
+
BigInteger hS(1);
|
103
|
+
hS.MultiplyPow5(static_cast<unsigned>(hS_Exp5)) <<= static_cast<unsigned>(hS_Exp2);
|
104
|
+
|
105
|
+
BigInteger delta(0);
|
106
|
+
dS.Difference(bS, &delta);
|
107
|
+
|
108
|
+
return delta.Compare(hS);
|
109
|
+
}
|
110
|
+
|
111
|
+
inline bool StrtodFast(double d, int p, double* result) {
|
112
|
+
// Use fast path for string-to-double conversion if possible
|
113
|
+
// see http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion/
|
114
|
+
if (p > 22 && p < 22 + 16) {
|
115
|
+
// Fast Path Cases In Disguise
|
116
|
+
d *= internal::Pow10(p - 22);
|
117
|
+
p = 22;
|
118
|
+
}
|
119
|
+
|
120
|
+
if (p >= -22 && p <= 22 && d <= 9007199254740991.0) { // 2^53 - 1
|
121
|
+
*result = FastPath(d, p);
|
122
|
+
return true;
|
123
|
+
}
|
124
|
+
else
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
|
128
|
+
// Compute an approximation and see if it is within 1/2 ULP
|
129
|
+
inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosition, int exp, double* result) {
|
130
|
+
uint64_t significand = 0;
|
131
|
+
size_t i = 0; // 2^64 - 1 = 18446744073709551615, 1844674407370955161 = 0x1999999999999999
|
132
|
+
for (; i < length; i++) {
|
133
|
+
if (significand > RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) ||
|
134
|
+
(significand == RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) && decimals[i] > '5'))
|
135
|
+
break;
|
136
|
+
significand = significand * 10u + static_cast<unsigned>(decimals[i] - '0');
|
137
|
+
}
|
138
|
+
|
139
|
+
if (i < length && decimals[i] >= '5') // Rounding
|
140
|
+
significand++;
|
141
|
+
|
142
|
+
size_t remaining = length - i;
|
143
|
+
const int kUlpShift = 3;
|
144
|
+
const int kUlp = 1 << kUlpShift;
|
145
|
+
int64_t error = (remaining == 0) ? 0 : kUlp / 2;
|
146
|
+
|
147
|
+
DiyFp v(significand, 0);
|
148
|
+
v = v.Normalize();
|
149
|
+
error <<= -v.e;
|
150
|
+
|
151
|
+
const int dExp = static_cast<int>(decimalPosition) - static_cast<int>(i) + exp;
|
152
|
+
|
153
|
+
int actualExp;
|
154
|
+
DiyFp cachedPower = GetCachedPower10(dExp, &actualExp);
|
155
|
+
if (actualExp != dExp) {
|
156
|
+
static const DiyFp kPow10[] = {
|
157
|
+
DiyFp(RAPIDJSON_UINT64_C2(0xa0000000, 00000000), -60), // 10^1
|
158
|
+
DiyFp(RAPIDJSON_UINT64_C2(0xc8000000, 00000000), -57), // 10^2
|
159
|
+
DiyFp(RAPIDJSON_UINT64_C2(0xfa000000, 00000000), -54), // 10^3
|
160
|
+
DiyFp(RAPIDJSON_UINT64_C2(0x9c400000, 00000000), -50), // 10^4
|
161
|
+
DiyFp(RAPIDJSON_UINT64_C2(0xc3500000, 00000000), -47), // 10^5
|
162
|
+
DiyFp(RAPIDJSON_UINT64_C2(0xf4240000, 00000000), -44), // 10^6
|
163
|
+
DiyFp(RAPIDJSON_UINT64_C2(0x98968000, 00000000), -40) // 10^7
|
164
|
+
};
|
165
|
+
int adjustment = dExp - actualExp - 1;
|
166
|
+
RAPIDJSON_ASSERT(adjustment >= 0 && adjustment < 7);
|
167
|
+
v = v * kPow10[adjustment];
|
168
|
+
if (length + static_cast<unsigned>(adjustment)> 19u) // has more digits than decimal digits in 64-bit
|
169
|
+
error += kUlp / 2;
|
170
|
+
}
|
171
|
+
|
172
|
+
v = v * cachedPower;
|
173
|
+
|
174
|
+
error += kUlp + (error == 0 ? 0 : 1);
|
175
|
+
|
176
|
+
const int oldExp = v.e;
|
177
|
+
v = v.Normalize();
|
178
|
+
error <<= oldExp - v.e;
|
179
|
+
|
180
|
+
const int effectiveSignificandSize = Double::EffectiveSignificandSize(64 + v.e);
|
181
|
+
int precisionSize = 64 - effectiveSignificandSize;
|
182
|
+
if (precisionSize + kUlpShift >= 64) {
|
183
|
+
int scaleExp = (precisionSize + kUlpShift) - 63;
|
184
|
+
v.f >>= scaleExp;
|
185
|
+
v.e += scaleExp;
|
186
|
+
error = (error >> scaleExp) + 1 + kUlp;
|
187
|
+
precisionSize -= scaleExp;
|
188
|
+
}
|
189
|
+
|
190
|
+
DiyFp rounded(v.f >> precisionSize, v.e + precisionSize);
|
191
|
+
const uint64_t precisionBits = (v.f & ((uint64_t(1) << precisionSize) - 1)) * kUlp;
|
192
|
+
const uint64_t halfWay = (uint64_t(1) << (precisionSize - 1)) * kUlp;
|
193
|
+
if (precisionBits >= halfWay + static_cast<unsigned>(error)) {
|
194
|
+
rounded.f++;
|
195
|
+
if (rounded.f & (DiyFp::kDpHiddenBit << 1)) { // rounding overflows mantissa (issue #340)
|
196
|
+
rounded.f >>= 1;
|
197
|
+
rounded.e++;
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
*result = rounded.ToDouble();
|
202
|
+
|
203
|
+
return halfWay - static_cast<unsigned>(error) >= precisionBits || precisionBits >= halfWay + static_cast<unsigned>(error);
|
204
|
+
}
|
205
|
+
|
206
|
+
inline double StrtodBigInteger(double approx, const char* decimals, size_t length, size_t decimalPosition, int exp) {
|
207
|
+
const BigInteger dInt(decimals, length);
|
208
|
+
const int dExp = static_cast<int>(decimalPosition) - static_cast<int>(length) + exp;
|
209
|
+
Double a(approx);
|
210
|
+
int cmp = CheckWithinHalfULP(a.Value(), dInt, dExp);
|
211
|
+
if (cmp < 0)
|
212
|
+
return a.Value(); // within half ULP
|
213
|
+
else if (cmp == 0) {
|
214
|
+
// Round towards even
|
215
|
+
if (a.Significand() & 1)
|
216
|
+
return a.NextPositiveDouble();
|
217
|
+
else
|
218
|
+
return a.Value();
|
219
|
+
}
|
220
|
+
else // adjustment
|
221
|
+
return a.NextPositiveDouble();
|
222
|
+
}
|
223
|
+
|
224
|
+
inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t length, size_t decimalPosition, int exp) {
|
225
|
+
RAPIDJSON_ASSERT(d >= 0.0);
|
226
|
+
RAPIDJSON_ASSERT(length >= 1);
|
227
|
+
|
228
|
+
double result;
|
229
|
+
if (StrtodFast(d, p, &result))
|
230
|
+
return result;
|
231
|
+
|
232
|
+
// Trim leading zeros
|
233
|
+
while (*decimals == '0' && length > 1) {
|
234
|
+
length--;
|
235
|
+
decimals++;
|
236
|
+
decimalPosition--;
|
237
|
+
}
|
238
|
+
|
239
|
+
// Trim trailing zeros
|
240
|
+
while (decimals[length - 1] == '0' && length > 1) {
|
241
|
+
length--;
|
242
|
+
decimalPosition--;
|
243
|
+
exp++;
|
244
|
+
}
|
245
|
+
|
246
|
+
// Trim right-most digits
|
247
|
+
const int kMaxDecimalDigit = 780;
|
248
|
+
if (static_cast<int>(length) > kMaxDecimalDigit) {
|
249
|
+
int delta = (static_cast<int>(length) - kMaxDecimalDigit);
|
250
|
+
exp += delta;
|
251
|
+
decimalPosition -= static_cast<unsigned>(delta);
|
252
|
+
length = kMaxDecimalDigit;
|
253
|
+
}
|
254
|
+
|
255
|
+
// If too small, underflow to zero
|
256
|
+
if (int(length) + exp < -324)
|
257
|
+
return 0.0;
|
258
|
+
|
259
|
+
if (StrtodDiyFp(decimals, length, decimalPosition, exp, &result))
|
260
|
+
return result;
|
261
|
+
|
262
|
+
// Use approximation from StrtodDiyFp and make adjustment with BigInteger comparison
|
263
|
+
return StrtodBigInteger(result, decimals, length, decimalPosition, exp);
|
264
|
+
}
|
265
|
+
|
266
|
+
} // namespace internal
|
267
|
+
RAPIDJSON_NAMESPACE_END
|
268
|
+
|
269
|
+
#endif // RAPIDJSON_STRTOD_
|