rj_schema 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (299) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +18 -0
  3. data/ext/rj_schema/extconf.rb +7 -0
  4. data/ext/rj_schema/rapidjson/CHANGELOG.md +158 -0
  5. data/ext/rj_schema/rapidjson/CMakeLists.txt +221 -0
  6. data/ext/rj_schema/rapidjson/CMakeModules/FindGTestSrc.cmake +30 -0
  7. data/ext/rj_schema/rapidjson/RapidJSON.pc.in +7 -0
  8. data/ext/rj_schema/rapidjson/RapidJSONConfig.cmake.in +15 -0
  9. data/ext/rj_schema/rapidjson/RapidJSONConfigVersion.cmake.in +10 -0
  10. data/ext/rj_schema/rapidjson/appveyor.yml +41 -0
  11. data/ext/rj_schema/rapidjson/bin/data/glossary.json +22 -0
  12. data/ext/rj_schema/rapidjson/bin/data/menu.json +27 -0
  13. data/ext/rj_schema/rapidjson/bin/data/readme.txt +1 -0
  14. data/ext/rj_schema/rapidjson/bin/data/sample.json +3315 -0
  15. data/ext/rj_schema/rapidjson/bin/data/webapp.json +88 -0
  16. data/ext/rj_schema/rapidjson/bin/data/widget.json +26 -0
  17. data/ext/rj_schema/rapidjson/bin/draft-04/schema +150 -0
  18. data/ext/rj_schema/rapidjson/bin/encodings/utf16be.json +0 -0
  19. data/ext/rj_schema/rapidjson/bin/encodings/utf16bebom.json +0 -0
  20. data/ext/rj_schema/rapidjson/bin/encodings/utf16le.json +0 -0
  21. data/ext/rj_schema/rapidjson/bin/encodings/utf16lebom.json +0 -0
  22. data/ext/rj_schema/rapidjson/bin/encodings/utf32be.json +0 -0
  23. data/ext/rj_schema/rapidjson/bin/encodings/utf32bebom.json +0 -0
  24. data/ext/rj_schema/rapidjson/bin/encodings/utf32le.json +0 -0
  25. data/ext/rj_schema/rapidjson/bin/encodings/utf32lebom.json +0 -0
  26. data/ext/rj_schema/rapidjson/bin/encodings/utf8.json +7 -0
  27. data/ext/rj_schema/rapidjson/bin/encodings/utf8bom.json +7 -0
  28. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail1.json +1 -0
  29. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail10.json +1 -0
  30. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail11.json +1 -0
  31. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail12.json +1 -0
  32. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail13.json +1 -0
  33. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail14.json +1 -0
  34. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail15.json +1 -0
  35. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail16.json +1 -0
  36. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail17.json +1 -0
  37. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail18.json +1 -0
  38. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail19.json +1 -0
  39. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail2.json +1 -0
  40. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail20.json +1 -0
  41. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail21.json +1 -0
  42. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail22.json +1 -0
  43. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail23.json +1 -0
  44. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail24.json +1 -0
  45. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail25.json +1 -0
  46. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail26.json +1 -0
  47. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail27.json +2 -0
  48. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail28.json +2 -0
  49. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail29.json +1 -0
  50. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail3.json +1 -0
  51. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail30.json +1 -0
  52. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail31.json +1 -0
  53. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail32.json +1 -0
  54. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail33.json +1 -0
  55. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail4.json +1 -0
  56. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail5.json +1 -0
  57. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail6.json +1 -0
  58. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail7.json +1 -0
  59. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail8.json +1 -0
  60. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail9.json +1 -0
  61. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass1.json +58 -0
  62. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass2.json +1 -0
  63. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass3.json +6 -0
  64. data/ext/rj_schema/rapidjson/bin/jsonchecker/readme.txt +3 -0
  65. data/ext/rj_schema/rapidjson/bin/jsonschema/LICENSE +19 -0
  66. data/ext/rj_schema/rapidjson/bin/jsonschema/README.md +148 -0
  67. data/ext/rj_schema/rapidjson/bin/jsonschema/bin/jsonschema_suite +283 -0
  68. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/folder/folderInteger.json +3 -0
  69. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/integer.json +3 -0
  70. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/subSchemas.json +8 -0
  71. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/additionalItems.json +82 -0
  72. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/additionalProperties.json +88 -0
  73. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/default.json +49 -0
  74. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/dependencies.json +108 -0
  75. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/disallow.json +80 -0
  76. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/divisibleBy.json +60 -0
  77. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/enum.json +71 -0
  78. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/extends.json +94 -0
  79. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/items.json +46 -0
  80. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maxItems.json +28 -0
  81. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maxLength.json +33 -0
  82. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maximum.json +42 -0
  83. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minItems.json +28 -0
  84. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minLength.json +33 -0
  85. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minimum.json +42 -0
  86. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/bignum.json +107 -0
  87. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/format.json +222 -0
  88. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/jsregex.json +18 -0
  89. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/zeroTerminatedFloats.json +15 -0
  90. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/pattern.json +34 -0
  91. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/patternProperties.json +110 -0
  92. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/properties.json +92 -0
  93. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/ref.json +159 -0
  94. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/refRemote.json +74 -0
  95. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/required.json +53 -0
  96. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/type.json +474 -0
  97. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/uniqueItems.json +79 -0
  98. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/additionalItems.json +82 -0
  99. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/additionalProperties.json +88 -0
  100. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/allOf.json +112 -0
  101. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/anyOf.json +68 -0
  102. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/default.json +49 -0
  103. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/definitions.json +32 -0
  104. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/dependencies.json +113 -0
  105. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/enum.json +72 -0
  106. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/items.json +46 -0
  107. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxItems.json +28 -0
  108. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxLength.json +33 -0
  109. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxProperties.json +28 -0
  110. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maximum.json +42 -0
  111. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minItems.json +28 -0
  112. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minLength.json +33 -0
  113. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minProperties.json +28 -0
  114. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minimum.json +42 -0
  115. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/multipleOf.json +60 -0
  116. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/not.json +96 -0
  117. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/oneOf.json +68 -0
  118. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/bignum.json +107 -0
  119. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/format.json +148 -0
  120. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/zeroTerminatedFloats.json +15 -0
  121. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/pattern.json +34 -0
  122. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/patternProperties.json +110 -0
  123. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/properties.json +92 -0
  124. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/ref.json +159 -0
  125. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/refRemote.json +74 -0
  126. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/required.json +39 -0
  127. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/type.json +330 -0
  128. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/uniqueItems.json +79 -0
  129. data/ext/rj_schema/rapidjson/bin/jsonschema/tox.ini +8 -0
  130. data/ext/rj_schema/rapidjson/bin/types/booleans.json +102 -0
  131. data/ext/rj_schema/rapidjson/bin/types/floats.json +102 -0
  132. data/ext/rj_schema/rapidjson/bin/types/guids.json +102 -0
  133. data/ext/rj_schema/rapidjson/bin/types/integers.json +102 -0
  134. data/ext/rj_schema/rapidjson/bin/types/mixed.json +592 -0
  135. data/ext/rj_schema/rapidjson/bin/types/nulls.json +102 -0
  136. data/ext/rj_schema/rapidjson/bin/types/paragraphs.json +102 -0
  137. data/ext/rj_schema/rapidjson/bin/types/readme.txt +1 -0
  138. data/ext/rj_schema/rapidjson/contrib/natvis/LICENSE +45 -0
  139. data/ext/rj_schema/rapidjson/contrib/natvis/README.md +7 -0
  140. data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +38 -0
  141. data/ext/rj_schema/rapidjson/doc/CMakeLists.txt +27 -0
  142. data/ext/rj_schema/rapidjson/doc/Doxyfile.in +2369 -0
  143. data/ext/rj_schema/rapidjson/doc/Doxyfile.zh-cn.in +2369 -0
  144. data/ext/rj_schema/rapidjson/doc/diagram/architecture.dot +50 -0
  145. data/ext/rj_schema/rapidjson/doc/diagram/architecture.png +0 -0
  146. data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.dot +65 -0
  147. data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.png +0 -0
  148. data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.dot +62 -0
  149. data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.png +0 -0
  150. data/ext/rj_schema/rapidjson/doc/diagram/makefile +8 -0
  151. data/ext/rj_schema/rapidjson/doc/diagram/move1.dot +47 -0
  152. data/ext/rj_schema/rapidjson/doc/diagram/move1.png +0 -0
  153. data/ext/rj_schema/rapidjson/doc/diagram/move2.dot +62 -0
  154. data/ext/rj_schema/rapidjson/doc/diagram/move2.png +0 -0
  155. data/ext/rj_schema/rapidjson/doc/diagram/move3.dot +60 -0
  156. data/ext/rj_schema/rapidjson/doc/diagram/move3.png +0 -0
  157. data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.dot +56 -0
  158. data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.png +0 -0
  159. data/ext/rj_schema/rapidjson/doc/diagram/simpledom.dot +54 -0
  160. data/ext/rj_schema/rapidjson/doc/diagram/simpledom.png +0 -0
  161. data/ext/rj_schema/rapidjson/doc/diagram/tutorial.dot +58 -0
  162. data/ext/rj_schema/rapidjson/doc/diagram/tutorial.png +0 -0
  163. data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.dot +73 -0
  164. data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.png +0 -0
  165. data/ext/rj_schema/rapidjson/doc/dom.md +280 -0
  166. data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +284 -0
  167. data/ext/rj_schema/rapidjson/doc/encoding.md +146 -0
  168. data/ext/rj_schema/rapidjson/doc/encoding.zh-cn.md +152 -0
  169. data/ext/rj_schema/rapidjson/doc/faq.md +289 -0
  170. data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +290 -0
  171. data/ext/rj_schema/rapidjson/doc/features.md +104 -0
  172. data/ext/rj_schema/rapidjson/doc/features.zh-cn.md +103 -0
  173. data/ext/rj_schema/rapidjson/doc/internals.md +368 -0
  174. data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +363 -0
  175. data/ext/rj_schema/rapidjson/doc/logo/rapidjson.png +0 -0
  176. data/ext/rj_schema/rapidjson/doc/logo/rapidjson.svg +119 -0
  177. data/ext/rj_schema/rapidjson/doc/misc/DoxygenLayout.xml +194 -0
  178. data/ext/rj_schema/rapidjson/doc/misc/doxygenextra.css +274 -0
  179. data/ext/rj_schema/rapidjson/doc/misc/footer.html +11 -0
  180. data/ext/rj_schema/rapidjson/doc/misc/header.html +24 -0
  181. data/ext/rj_schema/rapidjson/doc/npm.md +31 -0
  182. data/ext/rj_schema/rapidjson/doc/performance.md +26 -0
  183. data/ext/rj_schema/rapidjson/doc/performance.zh-cn.md +26 -0
  184. data/ext/rj_schema/rapidjson/doc/pointer.md +234 -0
  185. data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +234 -0
  186. data/ext/rj_schema/rapidjson/doc/sax.md +509 -0
  187. data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +487 -0
  188. data/ext/rj_schema/rapidjson/doc/schema.md +505 -0
  189. data/ext/rj_schema/rapidjson/doc/schema.zh-cn.md +237 -0
  190. data/ext/rj_schema/rapidjson/doc/stream.md +426 -0
  191. data/ext/rj_schema/rapidjson/doc/stream.zh-cn.md +426 -0
  192. data/ext/rj_schema/rapidjson/doc/tutorial.md +536 -0
  193. data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +534 -0
  194. data/ext/rj_schema/rapidjson/docker/debian/Dockerfile +8 -0
  195. data/ext/rj_schema/rapidjson/example/CMakeLists.txt +45 -0
  196. data/ext/rj_schema/rapidjson/example/archiver/archiver.cpp +292 -0
  197. data/ext/rj_schema/rapidjson/example/archiver/archiver.h +145 -0
  198. data/ext/rj_schema/rapidjson/example/archiver/archivertest.cpp +287 -0
  199. data/ext/rj_schema/rapidjson/example/capitalize/capitalize.cpp +67 -0
  200. data/ext/rj_schema/rapidjson/example/condense/condense.cpp +32 -0
  201. data/ext/rj_schema/rapidjson/example/filterkey/filterkey.cpp +135 -0
  202. data/ext/rj_schema/rapidjson/example/filterkeydom/filterkeydom.cpp +170 -0
  203. data/ext/rj_schema/rapidjson/example/jsonx/jsonx.cpp +207 -0
  204. data/ext/rj_schema/rapidjson/example/lookaheadparser/lookaheadparser.cpp +350 -0
  205. data/ext/rj_schema/rapidjson/example/messagereader/messagereader.cpp +105 -0
  206. data/ext/rj_schema/rapidjson/example/parsebyparts/parsebyparts.cpp +176 -0
  207. data/ext/rj_schema/rapidjson/example/pretty/pretty.cpp +30 -0
  208. data/ext/rj_schema/rapidjson/example/prettyauto/prettyauto.cpp +56 -0
  209. data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +78 -0
  210. data/ext/rj_schema/rapidjson/example/serialize/serialize.cpp +173 -0
  211. data/ext/rj_schema/rapidjson/example/simpledom/simpledom.cpp +29 -0
  212. data/ext/rj_schema/rapidjson/example/simplepullreader/simplepullreader.cpp +53 -0
  213. data/ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp +42 -0
  214. data/ext/rj_schema/rapidjson/example/simplewriter/simplewriter.cpp +36 -0
  215. data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +151 -0
  216. data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +271 -0
  217. data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +78 -0
  218. data/ext/rj_schema/rapidjson/include/rapidjson/document.h +2630 -0
  219. data/ext/rj_schema/rapidjson/include/rapidjson/encodedstream.h +299 -0
  220. data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +716 -0
  221. data/ext/rj_schema/rapidjson/include/rapidjson/error/en.h +74 -0
  222. data/ext/rj_schema/rapidjson/include/rapidjson/error/error.h +161 -0
  223. data/ext/rj_schema/rapidjson/include/rapidjson/filereadstream.h +99 -0
  224. data/ext/rj_schema/rapidjson/include/rapidjson/filewritestream.h +104 -0
  225. data/ext/rj_schema/rapidjson/include/rapidjson/fwd.h +151 -0
  226. data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +290 -0
  227. data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +258 -0
  228. data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +245 -0
  229. data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +78 -0
  230. data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +304 -0
  231. data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +181 -0
  232. data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +55 -0
  233. data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +734 -0
  234. data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +231 -0
  235. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +69 -0
  236. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +269 -0
  237. data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +46 -0
  238. data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +115 -0
  239. data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +70 -0
  240. data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +71 -0
  241. data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/inttypes.h +316 -0
  242. data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/stdint.h +300 -0
  243. data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +81 -0
  244. data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +1363 -0
  245. data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +277 -0
  246. data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +628 -0
  247. data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +2222 -0
  248. data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +2479 -0
  249. data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +223 -0
  250. data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +121 -0
  251. data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +716 -0
  252. data/ext/rj_schema/rapidjson/include_dirs.js +2 -0
  253. data/ext/rj_schema/rapidjson/library.json +15 -0
  254. data/ext/rj_schema/rapidjson/license.txt +57 -0
  255. data/ext/rj_schema/rapidjson/package.json +24 -0
  256. data/ext/rj_schema/rapidjson/rapidjson.autopkg +77 -0
  257. data/ext/rj_schema/rapidjson/readme.md +160 -0
  258. data/ext/rj_schema/rapidjson/readme.zh-cn.md +152 -0
  259. data/ext/rj_schema/rapidjson/test/CMakeLists.txt +20 -0
  260. data/ext/rj_schema/rapidjson/test/perftest/CMakeLists.txt +28 -0
  261. data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +974 -0
  262. data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +24 -0
  263. data/ext/rj_schema/rapidjson/test/perftest/perftest.h +185 -0
  264. data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +166 -0
  265. data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +472 -0
  266. data/ext/rj_schema/rapidjson/test/perftest/schematest.cpp +216 -0
  267. data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +92 -0
  268. data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +102 -0
  269. data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +133 -0
  270. data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +115 -0
  271. data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +672 -0
  272. data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +98 -0
  273. data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +313 -0
  274. data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +451 -0
  275. data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +112 -0
  276. data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +230 -0
  277. data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +181 -0
  278. data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +160 -0
  279. data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +143 -0
  280. data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +70 -0
  281. data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +92 -0
  282. data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +1529 -0
  283. data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +344 -0
  284. data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +1895 -0
  285. data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +638 -0
  286. data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +2009 -0
  287. data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +219 -0
  288. data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +30 -0
  289. data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +192 -0
  290. data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +132 -0
  291. data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +51 -0
  292. data/ext/rj_schema/rapidjson/test/unittest/unittest.h +140 -0
  293. data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +1829 -0
  294. data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +598 -0
  295. data/ext/rj_schema/rapidjson/test/valgrind.supp +17 -0
  296. data/ext/rj_schema/rapidjson/travis-doxygen.sh +121 -0
  297. data/ext/rj_schema/rj_schema.cpp +136 -0
  298. data/lib/rj_schema.rb +7 -0
  299. metadata +371 -0
@@ -0,0 +1,300 @@
1
+ // ISO C9x compliant stdint.h for Microsoft Visual Studio
2
+ // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
3
+ //
4
+ // Copyright (c) 2006-2013 Alexander Chemeris
5
+ //
6
+ // Redistribution and use in source and binary forms, with or without
7
+ // modification, are permitted provided that the following conditions are met:
8
+ //
9
+ // 1. Redistributions of source code must retain the above copyright notice,
10
+ // this list of conditions and the following disclaimer.
11
+ //
12
+ // 2. Redistributions in binary form must reproduce the above copyright
13
+ // notice, this list of conditions and the following disclaimer in the
14
+ // documentation and/or other materials provided with the distribution.
15
+ //
16
+ // 3. Neither the name of the product nor the names of its contributors may
17
+ // be used to endorse or promote products derived from this software
18
+ // without specific prior written permission.
19
+ //
20
+ // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
21
+ // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
+ // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
23
+ // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26
+ // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
+ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28
+ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
+ // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ //
31
+ ///////////////////////////////////////////////////////////////////////////////
32
+
33
+ // The above software in this distribution may have been modified by
34
+ // THL A29 Limited ("Tencent Modifications").
35
+ // All Tencent Modifications are Copyright (C) 2015 THL A29 Limited.
36
+
37
+ #ifndef _MSC_VER // [
38
+ #error "Use this header only with Microsoft Visual C++ compilers!"
39
+ #endif // _MSC_VER ]
40
+
41
+ #ifndef _MSC_STDINT_H_ // [
42
+ #define _MSC_STDINT_H_
43
+
44
+ #if _MSC_VER > 1000
45
+ #pragma once
46
+ #endif
47
+
48
+ // miloyip: Originally Visual Studio 2010 uses its own stdint.h. However it generates warning with INT64_C(), so change to use this file for vs2010.
49
+ #if _MSC_VER >= 1600 // [
50
+ #include <stdint.h>
51
+
52
+ #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
53
+
54
+ #undef INT8_C
55
+ #undef INT16_C
56
+ #undef INT32_C
57
+ #undef INT64_C
58
+ #undef UINT8_C
59
+ #undef UINT16_C
60
+ #undef UINT32_C
61
+ #undef UINT64_C
62
+
63
+ // 7.18.4.1 Macros for minimum-width integer constants
64
+
65
+ #define INT8_C(val) val##i8
66
+ #define INT16_C(val) val##i16
67
+ #define INT32_C(val) val##i32
68
+ #define INT64_C(val) val##i64
69
+
70
+ #define UINT8_C(val) val##ui8
71
+ #define UINT16_C(val) val##ui16
72
+ #define UINT32_C(val) val##ui32
73
+ #define UINT64_C(val) val##ui64
74
+
75
+ // 7.18.4.2 Macros for greatest-width integer constants
76
+ // These #ifndef's are needed to prevent collisions with <boost/cstdint.hpp>.
77
+ // Check out Issue 9 for the details.
78
+ #ifndef INTMAX_C // [
79
+ # define INTMAX_C INT64_C
80
+ #endif // INTMAX_C ]
81
+ #ifndef UINTMAX_C // [
82
+ # define UINTMAX_C UINT64_C
83
+ #endif // UINTMAX_C ]
84
+
85
+ #endif // __STDC_CONSTANT_MACROS ]
86
+
87
+ #else // ] _MSC_VER >= 1700 [
88
+
89
+ #include <limits.h>
90
+
91
+ // For Visual Studio 6 in C++ mode and for many Visual Studio versions when
92
+ // compiling for ARM we have to wrap <wchar.h> include with 'extern "C++" {}'
93
+ // or compiler would give many errors like this:
94
+ // error C2733: second C linkage of overloaded function 'wmemchr' not allowed
95
+ #if defined(__cplusplus) && !defined(_M_ARM)
96
+ extern "C" {
97
+ #endif
98
+ # include <wchar.h>
99
+ #if defined(__cplusplus) && !defined(_M_ARM)
100
+ }
101
+ #endif
102
+
103
+ // Define _W64 macros to mark types changing their size, like intptr_t.
104
+ #ifndef _W64
105
+ # if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
106
+ # define _W64 __w64
107
+ # else
108
+ # define _W64
109
+ # endif
110
+ #endif
111
+
112
+
113
+ // 7.18.1 Integer types
114
+
115
+ // 7.18.1.1 Exact-width integer types
116
+
117
+ // Visual Studio 6 and Embedded Visual C++ 4 doesn't
118
+ // realize that, e.g. char has the same size as __int8
119
+ // so we give up on __intX for them.
120
+ #if (_MSC_VER < 1300)
121
+ typedef signed char int8_t;
122
+ typedef signed short int16_t;
123
+ typedef signed int int32_t;
124
+ typedef unsigned char uint8_t;
125
+ typedef unsigned short uint16_t;
126
+ typedef unsigned int uint32_t;
127
+ #else
128
+ typedef signed __int8 int8_t;
129
+ typedef signed __int16 int16_t;
130
+ typedef signed __int32 int32_t;
131
+ typedef unsigned __int8 uint8_t;
132
+ typedef unsigned __int16 uint16_t;
133
+ typedef unsigned __int32 uint32_t;
134
+ #endif
135
+ typedef signed __int64 int64_t;
136
+ typedef unsigned __int64 uint64_t;
137
+
138
+
139
+ // 7.18.1.2 Minimum-width integer types
140
+ typedef int8_t int_least8_t;
141
+ typedef int16_t int_least16_t;
142
+ typedef int32_t int_least32_t;
143
+ typedef int64_t int_least64_t;
144
+ typedef uint8_t uint_least8_t;
145
+ typedef uint16_t uint_least16_t;
146
+ typedef uint32_t uint_least32_t;
147
+ typedef uint64_t uint_least64_t;
148
+
149
+ // 7.18.1.3 Fastest minimum-width integer types
150
+ typedef int8_t int_fast8_t;
151
+ typedef int16_t int_fast16_t;
152
+ typedef int32_t int_fast32_t;
153
+ typedef int64_t int_fast64_t;
154
+ typedef uint8_t uint_fast8_t;
155
+ typedef uint16_t uint_fast16_t;
156
+ typedef uint32_t uint_fast32_t;
157
+ typedef uint64_t uint_fast64_t;
158
+
159
+ // 7.18.1.4 Integer types capable of holding object pointers
160
+ #ifdef _WIN64 // [
161
+ typedef signed __int64 intptr_t;
162
+ typedef unsigned __int64 uintptr_t;
163
+ #else // _WIN64 ][
164
+ typedef _W64 signed int intptr_t;
165
+ typedef _W64 unsigned int uintptr_t;
166
+ #endif // _WIN64 ]
167
+
168
+ // 7.18.1.5 Greatest-width integer types
169
+ typedef int64_t intmax_t;
170
+ typedef uint64_t uintmax_t;
171
+
172
+
173
+ // 7.18.2 Limits of specified-width integer types
174
+
175
+ #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
176
+
177
+ // 7.18.2.1 Limits of exact-width integer types
178
+ #define INT8_MIN ((int8_t)_I8_MIN)
179
+ #define INT8_MAX _I8_MAX
180
+ #define INT16_MIN ((int16_t)_I16_MIN)
181
+ #define INT16_MAX _I16_MAX
182
+ #define INT32_MIN ((int32_t)_I32_MIN)
183
+ #define INT32_MAX _I32_MAX
184
+ #define INT64_MIN ((int64_t)_I64_MIN)
185
+ #define INT64_MAX _I64_MAX
186
+ #define UINT8_MAX _UI8_MAX
187
+ #define UINT16_MAX _UI16_MAX
188
+ #define UINT32_MAX _UI32_MAX
189
+ #define UINT64_MAX _UI64_MAX
190
+
191
+ // 7.18.2.2 Limits of minimum-width integer types
192
+ #define INT_LEAST8_MIN INT8_MIN
193
+ #define INT_LEAST8_MAX INT8_MAX
194
+ #define INT_LEAST16_MIN INT16_MIN
195
+ #define INT_LEAST16_MAX INT16_MAX
196
+ #define INT_LEAST32_MIN INT32_MIN
197
+ #define INT_LEAST32_MAX INT32_MAX
198
+ #define INT_LEAST64_MIN INT64_MIN
199
+ #define INT_LEAST64_MAX INT64_MAX
200
+ #define UINT_LEAST8_MAX UINT8_MAX
201
+ #define UINT_LEAST16_MAX UINT16_MAX
202
+ #define UINT_LEAST32_MAX UINT32_MAX
203
+ #define UINT_LEAST64_MAX UINT64_MAX
204
+
205
+ // 7.18.2.3 Limits of fastest minimum-width integer types
206
+ #define INT_FAST8_MIN INT8_MIN
207
+ #define INT_FAST8_MAX INT8_MAX
208
+ #define INT_FAST16_MIN INT16_MIN
209
+ #define INT_FAST16_MAX INT16_MAX
210
+ #define INT_FAST32_MIN INT32_MIN
211
+ #define INT_FAST32_MAX INT32_MAX
212
+ #define INT_FAST64_MIN INT64_MIN
213
+ #define INT_FAST64_MAX INT64_MAX
214
+ #define UINT_FAST8_MAX UINT8_MAX
215
+ #define UINT_FAST16_MAX UINT16_MAX
216
+ #define UINT_FAST32_MAX UINT32_MAX
217
+ #define UINT_FAST64_MAX UINT64_MAX
218
+
219
+ // 7.18.2.4 Limits of integer types capable of holding object pointers
220
+ #ifdef _WIN64 // [
221
+ # define INTPTR_MIN INT64_MIN
222
+ # define INTPTR_MAX INT64_MAX
223
+ # define UINTPTR_MAX UINT64_MAX
224
+ #else // _WIN64 ][
225
+ # define INTPTR_MIN INT32_MIN
226
+ # define INTPTR_MAX INT32_MAX
227
+ # define UINTPTR_MAX UINT32_MAX
228
+ #endif // _WIN64 ]
229
+
230
+ // 7.18.2.5 Limits of greatest-width integer types
231
+ #define INTMAX_MIN INT64_MIN
232
+ #define INTMAX_MAX INT64_MAX
233
+ #define UINTMAX_MAX UINT64_MAX
234
+
235
+ // 7.18.3 Limits of other integer types
236
+
237
+ #ifdef _WIN64 // [
238
+ # define PTRDIFF_MIN _I64_MIN
239
+ # define PTRDIFF_MAX _I64_MAX
240
+ #else // _WIN64 ][
241
+ # define PTRDIFF_MIN _I32_MIN
242
+ # define PTRDIFF_MAX _I32_MAX
243
+ #endif // _WIN64 ]
244
+
245
+ #define SIG_ATOMIC_MIN INT_MIN
246
+ #define SIG_ATOMIC_MAX INT_MAX
247
+
248
+ #ifndef SIZE_MAX // [
249
+ # ifdef _WIN64 // [
250
+ # define SIZE_MAX _UI64_MAX
251
+ # else // _WIN64 ][
252
+ # define SIZE_MAX _UI32_MAX
253
+ # endif // _WIN64 ]
254
+ #endif // SIZE_MAX ]
255
+
256
+ // WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
257
+ #ifndef WCHAR_MIN // [
258
+ # define WCHAR_MIN 0
259
+ #endif // WCHAR_MIN ]
260
+ #ifndef WCHAR_MAX // [
261
+ # define WCHAR_MAX _UI16_MAX
262
+ #endif // WCHAR_MAX ]
263
+
264
+ #define WINT_MIN 0
265
+ #define WINT_MAX _UI16_MAX
266
+
267
+ #endif // __STDC_LIMIT_MACROS ]
268
+
269
+
270
+ // 7.18.4 Limits of other integer types
271
+
272
+ #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
273
+
274
+ // 7.18.4.1 Macros for minimum-width integer constants
275
+
276
+ #define INT8_C(val) val##i8
277
+ #define INT16_C(val) val##i16
278
+ #define INT32_C(val) val##i32
279
+ #define INT64_C(val) val##i64
280
+
281
+ #define UINT8_C(val) val##ui8
282
+ #define UINT16_C(val) val##ui16
283
+ #define UINT32_C(val) val##ui32
284
+ #define UINT64_C(val) val##ui64
285
+
286
+ // 7.18.4.2 Macros for greatest-width integer constants
287
+ // These #ifndef's are needed to prevent collisions with <boost/cstdint.hpp>.
288
+ // Check out Issue 9 for the details.
289
+ #ifndef INTMAX_C // [
290
+ # define INTMAX_C INT64_C
291
+ #endif // INTMAX_C ]
292
+ #ifndef UINTMAX_C // [
293
+ # define UINTMAX_C UINT64_C
294
+ #endif // UINTMAX_C ]
295
+
296
+ #endif // __STDC_CONSTANT_MACROS ]
297
+
298
+ #endif // _MSC_VER >= 1600 ]
299
+
300
+ #endif // _MSC_STDINT_H_ ]
@@ -0,0 +1,81 @@
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_OSTREAMWRAPPER_H_
16
+ #define RAPIDJSON_OSTREAMWRAPPER_H_
17
+
18
+ #include "stream.h"
19
+ #include <iosfwd>
20
+
21
+ #ifdef __clang__
22
+ RAPIDJSON_DIAG_PUSH
23
+ RAPIDJSON_DIAG_OFF(padded)
24
+ #endif
25
+
26
+ RAPIDJSON_NAMESPACE_BEGIN
27
+
28
+ //! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept.
29
+ /*!
30
+ The classes can be wrapped including but not limited to:
31
+
32
+ - \c std::ostringstream
33
+ - \c std::stringstream
34
+ - \c std::wpstringstream
35
+ - \c std::wstringstream
36
+ - \c std::ifstream
37
+ - \c std::fstream
38
+ - \c std::wofstream
39
+ - \c std::wfstream
40
+
41
+ \tparam StreamType Class derived from \c std::basic_ostream.
42
+ */
43
+
44
+ template <typename StreamType>
45
+ class BasicOStreamWrapper {
46
+ public:
47
+ typedef typename StreamType::char_type Ch;
48
+ BasicOStreamWrapper(StreamType& stream) : stream_(stream) {}
49
+
50
+ void Put(Ch c) {
51
+ stream_.put(c);
52
+ }
53
+
54
+ void Flush() {
55
+ stream_.flush();
56
+ }
57
+
58
+ // Not implemented
59
+ char Peek() const { RAPIDJSON_ASSERT(false); return 0; }
60
+ char Take() { RAPIDJSON_ASSERT(false); return 0; }
61
+ size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
62
+ char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
63
+ size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
64
+
65
+ private:
66
+ BasicOStreamWrapper(const BasicOStreamWrapper&);
67
+ BasicOStreamWrapper& operator=(const BasicOStreamWrapper&);
68
+
69
+ StreamType& stream_;
70
+ };
71
+
72
+ typedef BasicOStreamWrapper<std::ostream> OStreamWrapper;
73
+ typedef BasicOStreamWrapper<std::wostream> WOStreamWrapper;
74
+
75
+ #ifdef __clang__
76
+ RAPIDJSON_DIAG_POP
77
+ #endif
78
+
79
+ RAPIDJSON_NAMESPACE_END
80
+
81
+ #endif // RAPIDJSON_OSTREAMWRAPPER_H_
@@ -0,0 +1,1363 @@
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_POINTER_H_
16
+ #define RAPIDJSON_POINTER_H_
17
+
18
+ #include "document.h"
19
+ #include "internal/itoa.h"
20
+
21
+ #ifdef __clang__
22
+ RAPIDJSON_DIAG_PUSH
23
+ RAPIDJSON_DIAG_OFF(switch-enum)
24
+ #endif
25
+
26
+ #ifdef _MSC_VER
27
+ RAPIDJSON_DIAG_PUSH
28
+ RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
29
+ #endif
30
+
31
+ RAPIDJSON_NAMESPACE_BEGIN
32
+
33
+ static const SizeType kPointerInvalidIndex = ~SizeType(0); //!< Represents an invalid index in GenericPointer::Token
34
+
35
+ //! Error code of parsing.
36
+ /*! \ingroup RAPIDJSON_ERRORS
37
+ \see GenericPointer::GenericPointer, GenericPointer::GetParseErrorCode
38
+ */
39
+ enum PointerParseErrorCode {
40
+ kPointerParseErrorNone = 0, //!< The parse is successful
41
+
42
+ kPointerParseErrorTokenMustBeginWithSolidus, //!< A token must begin with a '/'
43
+ kPointerParseErrorInvalidEscape, //!< Invalid escape
44
+ kPointerParseErrorInvalidPercentEncoding, //!< Invalid percent encoding in URI fragment
45
+ kPointerParseErrorCharacterMustPercentEncode //!< A character must percent encoded in URI fragment
46
+ };
47
+
48
+ ///////////////////////////////////////////////////////////////////////////////
49
+ // GenericPointer
50
+
51
+ //! Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.
52
+ /*!
53
+ This class implements RFC 6901 "JavaScript Object Notation (JSON) Pointer"
54
+ (https://tools.ietf.org/html/rfc6901).
55
+
56
+ A JSON pointer is for identifying a specific value in a JSON document
57
+ (GenericDocument). It can simplify coding of DOM tree manipulation, because it
58
+ can access multiple-level depth of DOM tree with single API call.
59
+
60
+ After it parses a string representation (e.g. "/foo/0" or URI fragment
61
+ representation (e.g. "#/foo/0") into its internal representation (tokens),
62
+ it can be used to resolve a specific value in multiple documents, or sub-tree
63
+ of documents.
64
+
65
+ Contrary to GenericValue, Pointer can be copy constructed and copy assigned.
66
+ Apart from assignment, a Pointer cannot be modified after construction.
67
+
68
+ Although Pointer is very convenient, please aware that constructing Pointer
69
+ involves parsing and dynamic memory allocation. A special constructor with user-
70
+ supplied tokens eliminates these.
71
+
72
+ GenericPointer depends on GenericDocument and GenericValue.
73
+
74
+ \tparam ValueType The value type of the DOM tree. E.g. GenericValue<UTF8<> >
75
+ \tparam Allocator The allocator type for allocating memory for internal representation.
76
+
77
+ \note GenericPointer uses same encoding of ValueType.
78
+ However, Allocator of GenericPointer is independent of Allocator of Value.
79
+ */
80
+ template <typename ValueType, typename Allocator = CrtAllocator>
81
+ class GenericPointer {
82
+ public:
83
+ typedef typename ValueType::EncodingType EncodingType; //!< Encoding type from Value
84
+ typedef typename ValueType::Ch Ch; //!< Character type from Value
85
+
86
+ //! A token is the basic units of internal representation.
87
+ /*!
88
+ A JSON pointer string representation "/foo/123" is parsed to two tokens:
89
+ "foo" and 123. 123 will be represented in both numeric form and string form.
90
+ They are resolved according to the actual value type (object or array).
91
+
92
+ For token that are not numbers, or the numeric value is out of bound
93
+ (greater than limits of SizeType), they are only treated as string form
94
+ (i.e. the token's index will be equal to kPointerInvalidIndex).
95
+
96
+ This struct is public so that user can create a Pointer without parsing and
97
+ allocation, using a special constructor.
98
+ */
99
+ struct Token {
100
+ const Ch* name; //!< Name of the token. It has null character at the end but it can contain null character.
101
+ SizeType length; //!< Length of the name.
102
+ SizeType index; //!< A valid array index, if it is not equal to kPointerInvalidIndex.
103
+ };
104
+
105
+ //!@name Constructors and destructor.
106
+ //@{
107
+
108
+ //! Default constructor.
109
+ GenericPointer(Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {}
110
+
111
+ //! Constructor that parses a string or URI fragment representation.
112
+ /*!
113
+ \param source A null-terminated, string or URI fragment representation of JSON pointer.
114
+ \param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one.
115
+ */
116
+ explicit GenericPointer(const Ch* source, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
117
+ Parse(source, internal::StrLen(source));
118
+ }
119
+
120
+ #if RAPIDJSON_HAS_STDSTRING
121
+ //! Constructor that parses a string or URI fragment representation.
122
+ /*!
123
+ \param source A string or URI fragment representation of JSON pointer.
124
+ \param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one.
125
+ \note Requires the definition of the preprocessor symbol \ref RAPIDJSON_HAS_STDSTRING.
126
+ */
127
+ explicit GenericPointer(const std::basic_string<Ch>& source, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
128
+ Parse(source.c_str(), source.size());
129
+ }
130
+ #endif
131
+
132
+ //! Constructor that parses a string or URI fragment representation, with length of the source string.
133
+ /*!
134
+ \param source A string or URI fragment representation of JSON pointer.
135
+ \param length Length of source.
136
+ \param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one.
137
+ \note Slightly faster than the overload without length.
138
+ */
139
+ GenericPointer(const Ch* source, size_t length, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
140
+ Parse(source, length);
141
+ }
142
+
143
+ //! Constructor with user-supplied tokens.
144
+ /*!
145
+ This constructor let user supplies const array of tokens.
146
+ This prevents the parsing process and eliminates allocation.
147
+ This is preferred for memory constrained environments.
148
+
149
+ \param tokens An constant array of tokens representing the JSON pointer.
150
+ \param tokenCount Number of tokens.
151
+
152
+ \b Example
153
+ \code
154
+ #define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1, kPointerInvalidIndex }
155
+ #define INDEX(i) { #i, sizeof(#i) - 1, i }
156
+
157
+ static const Pointer::Token kTokens[] = { NAME("foo"), INDEX(123) };
158
+ static const Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));
159
+ // Equivalent to static const Pointer p("/foo/123");
160
+
161
+ #undef NAME
162
+ #undef INDEX
163
+ \endcode
164
+ */
165
+ GenericPointer(const Token* tokens, size_t tokenCount) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(const_cast<Token*>(tokens)), tokenCount_(tokenCount), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {}
166
+
167
+ //! Copy constructor.
168
+ GenericPointer(const GenericPointer& rhs) : allocator_(rhs.allocator_), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
169
+ *this = rhs;
170
+ }
171
+
172
+ //! Copy constructor.
173
+ GenericPointer(const GenericPointer& rhs, Allocator* allocator) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {
174
+ *this = rhs;
175
+ }
176
+
177
+ //! Destructor.
178
+ ~GenericPointer() {
179
+ if (nameBuffer_) // If user-supplied tokens constructor is used, nameBuffer_ is nullptr and tokens_ are not deallocated.
180
+ Allocator::Free(tokens_);
181
+ RAPIDJSON_DELETE(ownAllocator_);
182
+ }
183
+
184
+ //! Assignment operator.
185
+ GenericPointer& operator=(const GenericPointer& rhs) {
186
+ if (this != &rhs) {
187
+ // Do not delete ownAllcator
188
+ if (nameBuffer_)
189
+ Allocator::Free(tokens_);
190
+
191
+ tokenCount_ = rhs.tokenCount_;
192
+ parseErrorOffset_ = rhs.parseErrorOffset_;
193
+ parseErrorCode_ = rhs.parseErrorCode_;
194
+
195
+ if (rhs.nameBuffer_)
196
+ CopyFromRaw(rhs); // Normally parsed tokens.
197
+ else {
198
+ tokens_ = rhs.tokens_; // User supplied const tokens.
199
+ nameBuffer_ = 0;
200
+ }
201
+ }
202
+ return *this;
203
+ }
204
+
205
+ //@}
206
+
207
+ //!@name Append token
208
+ //@{
209
+
210
+ //! Append a token and return a new Pointer
211
+ /*!
212
+ \param token Token to be appended.
213
+ \param allocator Allocator for the newly return Pointer.
214
+ \return A new Pointer with appended token.
215
+ */
216
+ GenericPointer Append(const Token& token, Allocator* allocator = 0) const {
217
+ GenericPointer r;
218
+ r.allocator_ = allocator;
219
+ Ch *p = r.CopyFromRaw(*this, 1, token.length + 1);
220
+ std::memcpy(p, token.name, (token.length + 1) * sizeof(Ch));
221
+ r.tokens_[tokenCount_].name = p;
222
+ r.tokens_[tokenCount_].length = token.length;
223
+ r.tokens_[tokenCount_].index = token.index;
224
+ return r;
225
+ }
226
+
227
+ //! Append a name token with length, and return a new Pointer
228
+ /*!
229
+ \param name Name to be appended.
230
+ \param length Length of name.
231
+ \param allocator Allocator for the newly return Pointer.
232
+ \return A new Pointer with appended token.
233
+ */
234
+ GenericPointer Append(const Ch* name, SizeType length, Allocator* allocator = 0) const {
235
+ Token token = { name, length, kPointerInvalidIndex };
236
+ return Append(token, allocator);
237
+ }
238
+
239
+ //! Append a name token without length, and return a new Pointer
240
+ /*!
241
+ \param name Name (const Ch*) to be appended.
242
+ \param allocator Allocator for the newly return Pointer.
243
+ \return A new Pointer with appended token.
244
+ */
245
+ template <typename T>
246
+ RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >), (GenericPointer))
247
+ Append(T* name, Allocator* allocator = 0) const {
248
+ return Append(name, internal::StrLen(name), allocator);
249
+ }
250
+
251
+ #if RAPIDJSON_HAS_STDSTRING
252
+ //! Append a name token, and return a new Pointer
253
+ /*!
254
+ \param name Name to be appended.
255
+ \param allocator Allocator for the newly return Pointer.
256
+ \return A new Pointer with appended token.
257
+ */
258
+ GenericPointer Append(const std::basic_string<Ch>& name, Allocator* allocator = 0) const {
259
+ return Append(name.c_str(), static_cast<SizeType>(name.size()), allocator);
260
+ }
261
+ #endif
262
+
263
+ //! Append a index token, and return a new Pointer
264
+ /*!
265
+ \param index Index to be appended.
266
+ \param allocator Allocator for the newly return Pointer.
267
+ \return A new Pointer with appended token.
268
+ */
269
+ GenericPointer Append(SizeType index, Allocator* allocator = 0) const {
270
+ char buffer[21];
271
+ char* end = sizeof(SizeType) == 4 ? internal::u32toa(index, buffer) : internal::u64toa(index, buffer);
272
+ SizeType length = static_cast<SizeType>(end - buffer);
273
+ buffer[length] = '\0';
274
+
275
+ if (sizeof(Ch) == 1) {
276
+ Token token = { reinterpret_cast<Ch*>(buffer), length, index };
277
+ return Append(token, allocator);
278
+ }
279
+ else {
280
+ Ch name[21];
281
+ for (size_t i = 0; i <= length; i++)
282
+ name[i] = static_cast<Ch>(buffer[i]);
283
+ Token token = { name, length, index };
284
+ return Append(token, allocator);
285
+ }
286
+ }
287
+
288
+ //! Append a token by value, and return a new Pointer
289
+ /*!
290
+ \param token token to be appended.
291
+ \param allocator Allocator for the newly return Pointer.
292
+ \return A new Pointer with appended token.
293
+ */
294
+ GenericPointer Append(const ValueType& token, Allocator* allocator = 0) const {
295
+ if (token.IsString())
296
+ return Append(token.GetString(), token.GetStringLength(), allocator);
297
+ else {
298
+ RAPIDJSON_ASSERT(token.IsUint64());
299
+ RAPIDJSON_ASSERT(token.GetUint64() <= SizeType(~0));
300
+ return Append(static_cast<SizeType>(token.GetUint64()), allocator);
301
+ }
302
+ }
303
+
304
+ //!@name Handling Parse Error
305
+ //@{
306
+
307
+ //! Check whether this is a valid pointer.
308
+ bool IsValid() const { return parseErrorCode_ == kPointerParseErrorNone; }
309
+
310
+ //! Get the parsing error offset in code unit.
311
+ size_t GetParseErrorOffset() const { return parseErrorOffset_; }
312
+
313
+ //! Get the parsing error code.
314
+ PointerParseErrorCode GetParseErrorCode() const { return parseErrorCode_; }
315
+
316
+ //@}
317
+
318
+ //! Get the allocator of this pointer.
319
+ Allocator& GetAllocator() { return *allocator_; }
320
+
321
+ //!@name Tokens
322
+ //@{
323
+
324
+ //! Get the token array (const version only).
325
+ const Token* GetTokens() const { return tokens_; }
326
+
327
+ //! Get the number of tokens.
328
+ size_t GetTokenCount() const { return tokenCount_; }
329
+
330
+ //@}
331
+
332
+ //!@name Equality/inequality operators
333
+ //@{
334
+
335
+ //! Equality operator.
336
+ /*!
337
+ \note When any pointers are invalid, always returns false.
338
+ */
339
+ bool operator==(const GenericPointer& rhs) const {
340
+ if (!IsValid() || !rhs.IsValid() || tokenCount_ != rhs.tokenCount_)
341
+ return false;
342
+
343
+ for (size_t i = 0; i < tokenCount_; i++) {
344
+ if (tokens_[i].index != rhs.tokens_[i].index ||
345
+ tokens_[i].length != rhs.tokens_[i].length ||
346
+ (tokens_[i].length != 0 && std::memcmp(tokens_[i].name, rhs.tokens_[i].name, sizeof(Ch)* tokens_[i].length) != 0))
347
+ {
348
+ return false;
349
+ }
350
+ }
351
+
352
+ return true;
353
+ }
354
+
355
+ //! Inequality operator.
356
+ /*!
357
+ \note When any pointers are invalid, always returns true.
358
+ */
359
+ bool operator!=(const GenericPointer& rhs) const { return !(*this == rhs); }
360
+
361
+ //@}
362
+
363
+ //!@name Stringify
364
+ //@{
365
+
366
+ //! Stringify the pointer into string representation.
367
+ /*!
368
+ \tparam OutputStream Type of output stream.
369
+ \param os The output stream.
370
+ */
371
+ template<typename OutputStream>
372
+ bool Stringify(OutputStream& os) const {
373
+ return Stringify<false, OutputStream>(os);
374
+ }
375
+
376
+ //! Stringify the pointer into URI fragment representation.
377
+ /*!
378
+ \tparam OutputStream Type of output stream.
379
+ \param os The output stream.
380
+ */
381
+ template<typename OutputStream>
382
+ bool StringifyUriFragment(OutputStream& os) const {
383
+ return Stringify<true, OutputStream>(os);
384
+ }
385
+
386
+ //@}
387
+
388
+ //!@name Create value
389
+ //@{
390
+
391
+ //! Create a value in a subtree.
392
+ /*!
393
+ If the value is not exist, it creates all parent values and a JSON Null value.
394
+ So it always succeed and return the newly created or existing value.
395
+
396
+ Remind that it may change types of parents according to tokens, so it
397
+ potentially removes previously stored values. For example, if a document
398
+ was an array, and "/foo" is used to create a value, then the document
399
+ will be changed to an object, and all existing array elements are lost.
400
+
401
+ \param root Root value of a DOM subtree to be resolved. It can be any value other than document root.
402
+ \param allocator Allocator for creating the values if the specified value or its parents are not exist.
403
+ \param alreadyExist If non-null, it stores whether the resolved value is already exist.
404
+ \return The resolved newly created (a JSON Null value), or already exists value.
405
+ */
406
+ ValueType& Create(ValueType& root, typename ValueType::AllocatorType& allocator, bool* alreadyExist = 0) const {
407
+ RAPIDJSON_ASSERT(IsValid());
408
+ ValueType* v = &root;
409
+ bool exist = true;
410
+ for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) {
411
+ if (v->IsArray() && t->name[0] == '-' && t->length == 1) {
412
+ v->PushBack(ValueType().Move(), allocator);
413
+ v = &((*v)[v->Size() - 1]);
414
+ exist = false;
415
+ }
416
+ else {
417
+ if (t->index == kPointerInvalidIndex) { // must be object name
418
+ if (!v->IsObject())
419
+ v->SetObject(); // Change to Object
420
+ }
421
+ else { // object name or array index
422
+ if (!v->IsArray() && !v->IsObject())
423
+ v->SetArray(); // Change to Array
424
+ }
425
+
426
+ if (v->IsArray()) {
427
+ if (t->index >= v->Size()) {
428
+ v->Reserve(t->index + 1, allocator);
429
+ while (t->index >= v->Size())
430
+ v->PushBack(ValueType().Move(), allocator);
431
+ exist = false;
432
+ }
433
+ v = &((*v)[t->index]);
434
+ }
435
+ else {
436
+ typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));
437
+ if (m == v->MemberEnd()) {
438
+ v->AddMember(ValueType(t->name, t->length, allocator).Move(), ValueType().Move(), allocator);
439
+ v = &(--v->MemberEnd())->value; // Assumes AddMember() appends at the end
440
+ exist = false;
441
+ }
442
+ else
443
+ v = &m->value;
444
+ }
445
+ }
446
+ }
447
+
448
+ if (alreadyExist)
449
+ *alreadyExist = exist;
450
+
451
+ return *v;
452
+ }
453
+
454
+ //! Creates a value in a document.
455
+ /*!
456
+ \param document A document to be resolved.
457
+ \param alreadyExist If non-null, it stores whether the resolved value is already exist.
458
+ \return The resolved newly created, or already exists value.
459
+ */
460
+ template <typename stackAllocator>
461
+ ValueType& Create(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, bool* alreadyExist = 0) const {
462
+ return Create(document, document.GetAllocator(), alreadyExist);
463
+ }
464
+
465
+ //@}
466
+
467
+ //!@name Query value
468
+ //@{
469
+
470
+ //! Query a value in a subtree.
471
+ /*!
472
+ \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.
473
+ \param unresolvedTokenIndex If the pointer cannot resolve a token in the pointer, this parameter can obtain the index of unresolved token.
474
+ \return Pointer to the value if it can be resolved. Otherwise null.
475
+
476
+ \note
477
+ There are only 3 situations when a value cannot be resolved:
478
+ 1. A value in the path is not an array nor object.
479
+ 2. An object value does not contain the token.
480
+ 3. A token is out of range of an array value.
481
+
482
+ Use unresolvedTokenIndex to retrieve the token index.
483
+ */
484
+ ValueType* Get(ValueType& root, size_t* unresolvedTokenIndex = 0) const {
485
+ RAPIDJSON_ASSERT(IsValid());
486
+ ValueType* v = &root;
487
+ for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) {
488
+ switch (v->GetType()) {
489
+ case kObjectType:
490
+ {
491
+ typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));
492
+ if (m == v->MemberEnd())
493
+ break;
494
+ v = &m->value;
495
+ }
496
+ continue;
497
+ case kArrayType:
498
+ if (t->index == kPointerInvalidIndex || t->index >= v->Size())
499
+ break;
500
+ v = &((*v)[t->index]);
501
+ continue;
502
+ default:
503
+ break;
504
+ }
505
+
506
+ // Error: unresolved token
507
+ if (unresolvedTokenIndex)
508
+ *unresolvedTokenIndex = static_cast<size_t>(t - tokens_);
509
+ return 0;
510
+ }
511
+ return v;
512
+ }
513
+
514
+ //! Query a const value in a const subtree.
515
+ /*!
516
+ \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.
517
+ \return Pointer to the value if it can be resolved. Otherwise null.
518
+ */
519
+ const ValueType* Get(const ValueType& root, size_t* unresolvedTokenIndex = 0) const {
520
+ return Get(const_cast<ValueType&>(root), unresolvedTokenIndex);
521
+ }
522
+
523
+ //@}
524
+
525
+ //!@name Query a value with default
526
+ //@{
527
+
528
+ //! Query a value in a subtree with default value.
529
+ /*!
530
+ Similar to Get(), but if the specified value do not exists, it creates all parents and clone the default value.
531
+ So that this function always succeed.
532
+
533
+ \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.
534
+ \param defaultValue Default value to be cloned if the value was not exists.
535
+ \param allocator Allocator for creating the values if the specified value or its parents are not exist.
536
+ \see Create()
537
+ */
538
+ ValueType& GetWithDefault(ValueType& root, const ValueType& defaultValue, typename ValueType::AllocatorType& allocator) const {
539
+ bool alreadyExist;
540
+ ValueType& v = Create(root, allocator, &alreadyExist);
541
+ return alreadyExist ? v : v.CopyFrom(defaultValue, allocator);
542
+ }
543
+
544
+ //! Query a value in a subtree with default null-terminated string.
545
+ ValueType& GetWithDefault(ValueType& root, const Ch* defaultValue, typename ValueType::AllocatorType& allocator) const {
546
+ bool alreadyExist;
547
+ ValueType& v = Create(root, allocator, &alreadyExist);
548
+ return alreadyExist ? v : v.SetString(defaultValue, allocator);
549
+ }
550
+
551
+ #if RAPIDJSON_HAS_STDSTRING
552
+ //! Query a value in a subtree with default std::basic_string.
553
+ ValueType& GetWithDefault(ValueType& root, const std::basic_string<Ch>& defaultValue, typename ValueType::AllocatorType& allocator) const {
554
+ bool alreadyExist;
555
+ ValueType& v = Create(root, allocator, &alreadyExist);
556
+ return alreadyExist ? v : v.SetString(defaultValue, allocator);
557
+ }
558
+ #endif
559
+
560
+ //! Query a value in a subtree with default primitive value.
561
+ /*!
562
+ \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c bool
563
+ */
564
+ template <typename T>
565
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&))
566
+ GetWithDefault(ValueType& root, T defaultValue, typename ValueType::AllocatorType& allocator) const {
567
+ return GetWithDefault(root, ValueType(defaultValue).Move(), allocator);
568
+ }
569
+
570
+ //! Query a value in a document with default value.
571
+ template <typename stackAllocator>
572
+ ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const ValueType& defaultValue) const {
573
+ return GetWithDefault(document, defaultValue, document.GetAllocator());
574
+ }
575
+
576
+ //! Query a value in a document with default null-terminated string.
577
+ template <typename stackAllocator>
578
+ ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const Ch* defaultValue) const {
579
+ return GetWithDefault(document, defaultValue, document.GetAllocator());
580
+ }
581
+
582
+ #if RAPIDJSON_HAS_STDSTRING
583
+ //! Query a value in a document with default std::basic_string.
584
+ template <typename stackAllocator>
585
+ ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const std::basic_string<Ch>& defaultValue) const {
586
+ return GetWithDefault(document, defaultValue, document.GetAllocator());
587
+ }
588
+ #endif
589
+
590
+ //! Query a value in a document with default primitive value.
591
+ /*!
592
+ \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c bool
593
+ */
594
+ template <typename T, typename stackAllocator>
595
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&))
596
+ GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, T defaultValue) const {
597
+ return GetWithDefault(document, defaultValue, document.GetAllocator());
598
+ }
599
+
600
+ //@}
601
+
602
+ //!@name Set a value
603
+ //@{
604
+
605
+ //! Set a value in a subtree, with move semantics.
606
+ /*!
607
+ It creates all parents if they are not exist or types are different to the tokens.
608
+ So this function always succeeds but potentially remove existing values.
609
+
610
+ \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.
611
+ \param value Value to be set.
612
+ \param allocator Allocator for creating the values if the specified value or its parents are not exist.
613
+ \see Create()
614
+ */
615
+ ValueType& Set(ValueType& root, ValueType& value, typename ValueType::AllocatorType& allocator) const {
616
+ return Create(root, allocator) = value;
617
+ }
618
+
619
+ //! Set a value in a subtree, with copy semantics.
620
+ ValueType& Set(ValueType& root, const ValueType& value, typename ValueType::AllocatorType& allocator) const {
621
+ return Create(root, allocator).CopyFrom(value, allocator);
622
+ }
623
+
624
+ //! Set a null-terminated string in a subtree.
625
+ ValueType& Set(ValueType& root, const Ch* value, typename ValueType::AllocatorType& allocator) const {
626
+ return Create(root, allocator) = ValueType(value, allocator).Move();
627
+ }
628
+
629
+ #if RAPIDJSON_HAS_STDSTRING
630
+ //! Set a std::basic_string in a subtree.
631
+ ValueType& Set(ValueType& root, const std::basic_string<Ch>& value, typename ValueType::AllocatorType& allocator) const {
632
+ return Create(root, allocator) = ValueType(value, allocator).Move();
633
+ }
634
+ #endif
635
+
636
+ //! Set a primitive value in a subtree.
637
+ /*!
638
+ \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c bool
639
+ */
640
+ template <typename T>
641
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&))
642
+ Set(ValueType& root, T value, typename ValueType::AllocatorType& allocator) const {
643
+ return Create(root, allocator) = ValueType(value).Move();
644
+ }
645
+
646
+ //! Set a value in a document, with move semantics.
647
+ template <typename stackAllocator>
648
+ ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, ValueType& value) const {
649
+ return Create(document) = value;
650
+ }
651
+
652
+ //! Set a value in a document, with copy semantics.
653
+ template <typename stackAllocator>
654
+ ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const ValueType& value) const {
655
+ return Create(document).CopyFrom(value, document.GetAllocator());
656
+ }
657
+
658
+ //! Set a null-terminated string in a document.
659
+ template <typename stackAllocator>
660
+ ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const Ch* value) const {
661
+ return Create(document) = ValueType(value, document.GetAllocator()).Move();
662
+ }
663
+
664
+ #if RAPIDJSON_HAS_STDSTRING
665
+ //! Sets a std::basic_string in a document.
666
+ template <typename stackAllocator>
667
+ ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const std::basic_string<Ch>& value) const {
668
+ return Create(document) = ValueType(value, document.GetAllocator()).Move();
669
+ }
670
+ #endif
671
+
672
+ //! Set a primitive value in a document.
673
+ /*!
674
+ \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t, \c bool
675
+ */
676
+ template <typename T, typename stackAllocator>
677
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&))
678
+ Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, T value) const {
679
+ return Create(document) = value;
680
+ }
681
+
682
+ //@}
683
+
684
+ //!@name Swap a value
685
+ //@{
686
+
687
+ //! Swap a value with a value in a subtree.
688
+ /*!
689
+ It creates all parents if they are not exist or types are different to the tokens.
690
+ So this function always succeeds but potentially remove existing values.
691
+
692
+ \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.
693
+ \param value Value to be swapped.
694
+ \param allocator Allocator for creating the values if the specified value or its parents are not exist.
695
+ \see Create()
696
+ */
697
+ ValueType& Swap(ValueType& root, ValueType& value, typename ValueType::AllocatorType& allocator) const {
698
+ return Create(root, allocator).Swap(value);
699
+ }
700
+
701
+ //! Swap a value with a value in a document.
702
+ template <typename stackAllocator>
703
+ ValueType& Swap(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, ValueType& value) const {
704
+ return Create(document).Swap(value);
705
+ }
706
+
707
+ //@}
708
+
709
+ //! Erase a value in a subtree.
710
+ /*!
711
+ \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.
712
+ \return Whether the resolved value is found and erased.
713
+
714
+ \note Erasing with an empty pointer \c Pointer(""), i.e. the root, always fail and return false.
715
+ */
716
+ bool Erase(ValueType& root) const {
717
+ RAPIDJSON_ASSERT(IsValid());
718
+ if (tokenCount_ == 0) // Cannot erase the root
719
+ return false;
720
+
721
+ ValueType* v = &root;
722
+ const Token* last = tokens_ + (tokenCount_ - 1);
723
+ for (const Token *t = tokens_; t != last; ++t) {
724
+ switch (v->GetType()) {
725
+ case kObjectType:
726
+ {
727
+ typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));
728
+ if (m == v->MemberEnd())
729
+ return false;
730
+ v = &m->value;
731
+ }
732
+ break;
733
+ case kArrayType:
734
+ if (t->index == kPointerInvalidIndex || t->index >= v->Size())
735
+ return false;
736
+ v = &((*v)[t->index]);
737
+ break;
738
+ default:
739
+ return false;
740
+ }
741
+ }
742
+
743
+ switch (v->GetType()) {
744
+ case kObjectType:
745
+ return v->EraseMember(GenericStringRef<Ch>(last->name, last->length));
746
+ case kArrayType:
747
+ if (last->index == kPointerInvalidIndex || last->index >= v->Size())
748
+ return false;
749
+ v->Erase(v->Begin() + last->index);
750
+ return true;
751
+ default:
752
+ return false;
753
+ }
754
+ }
755
+
756
+ private:
757
+ //! Clone the content from rhs to this.
758
+ /*!
759
+ \param rhs Source pointer.
760
+ \param extraToken Extra tokens to be allocated.
761
+ \param extraNameBufferSize Extra name buffer size (in number of Ch) to be allocated.
762
+ \return Start of non-occupied name buffer, for storing extra names.
763
+ */
764
+ Ch* CopyFromRaw(const GenericPointer& rhs, size_t extraToken = 0, size_t extraNameBufferSize = 0) {
765
+ if (!allocator_) // allocator is independently owned.
766
+ ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
767
+
768
+ size_t nameBufferSize = rhs.tokenCount_; // null terminators for tokens
769
+ for (Token *t = rhs.tokens_; t != rhs.tokens_ + rhs.tokenCount_; ++t)
770
+ nameBufferSize += t->length;
771
+
772
+ tokenCount_ = rhs.tokenCount_ + extraToken;
773
+ tokens_ = static_cast<Token *>(allocator_->Malloc(tokenCount_ * sizeof(Token) + (nameBufferSize + extraNameBufferSize) * sizeof(Ch)));
774
+ nameBuffer_ = reinterpret_cast<Ch *>(tokens_ + tokenCount_);
775
+ if (rhs.tokenCount_ > 0) {
776
+ std::memcpy(tokens_, rhs.tokens_, rhs.tokenCount_ * sizeof(Token));
777
+ }
778
+ if (nameBufferSize > 0) {
779
+ std::memcpy(nameBuffer_, rhs.nameBuffer_, nameBufferSize * sizeof(Ch));
780
+ }
781
+
782
+ // Adjust pointers to name buffer
783
+ std::ptrdiff_t diff = nameBuffer_ - rhs.nameBuffer_;
784
+ for (Token *t = tokens_; t != tokens_ + rhs.tokenCount_; ++t)
785
+ t->name += diff;
786
+
787
+ return nameBuffer_ + nameBufferSize;
788
+ }
789
+
790
+ //! Check whether a character should be percent-encoded.
791
+ /*!
792
+ According to RFC 3986 2.3 Unreserved Characters.
793
+ \param c The character (code unit) to be tested.
794
+ */
795
+ bool NeedPercentEncode(Ch c) const {
796
+ return !((c >= '0' && c <= '9') || (c >= 'A' && c <='Z') || (c >= 'a' && c <= 'z') || c == '-' || c == '.' || c == '_' || c =='~');
797
+ }
798
+
799
+ //! Parse a JSON String or its URI fragment representation into tokens.
800
+ #ifndef __clang__ // -Wdocumentation
801
+ /*!
802
+ \param source Either a JSON Pointer string, or its URI fragment representation. Not need to be null terminated.
803
+ \param length Length of the source string.
804
+ \note Source cannot be JSON String Representation of JSON Pointer, e.g. In "/\u0000", \u0000 will not be unescaped.
805
+ */
806
+ #endif
807
+ void Parse(const Ch* source, size_t length) {
808
+ RAPIDJSON_ASSERT(source != NULL);
809
+ RAPIDJSON_ASSERT(nameBuffer_ == 0);
810
+ RAPIDJSON_ASSERT(tokens_ == 0);
811
+
812
+ // Create own allocator if user did not supply.
813
+ if (!allocator_)
814
+ ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator)();
815
+
816
+ // Count number of '/' as tokenCount
817
+ tokenCount_ = 0;
818
+ for (const Ch* s = source; s != source + length; s++)
819
+ if (*s == '/')
820
+ tokenCount_++;
821
+
822
+ Token* token = tokens_ = static_cast<Token *>(allocator_->Malloc(tokenCount_ * sizeof(Token) + length * sizeof(Ch)));
823
+ Ch* name = nameBuffer_ = reinterpret_cast<Ch *>(tokens_ + tokenCount_);
824
+ size_t i = 0;
825
+
826
+ // Detect if it is a URI fragment
827
+ bool uriFragment = false;
828
+ if (source[i] == '#') {
829
+ uriFragment = true;
830
+ i++;
831
+ }
832
+
833
+ if (i != length && source[i] != '/') {
834
+ parseErrorCode_ = kPointerParseErrorTokenMustBeginWithSolidus;
835
+ goto error;
836
+ }
837
+
838
+ while (i < length) {
839
+ RAPIDJSON_ASSERT(source[i] == '/');
840
+ i++; // consumes '/'
841
+
842
+ token->name = name;
843
+ bool isNumber = true;
844
+
845
+ while (i < length && source[i] != '/') {
846
+ Ch c = source[i];
847
+ if (uriFragment) {
848
+ // Decoding percent-encoding for URI fragment
849
+ if (c == '%') {
850
+ PercentDecodeStream is(&source[i], source + length);
851
+ GenericInsituStringStream<EncodingType> os(name);
852
+ Ch* begin = os.PutBegin();
853
+ if (!Transcoder<UTF8<>, EncodingType>().Validate(is, os) || !is.IsValid()) {
854
+ parseErrorCode_ = kPointerParseErrorInvalidPercentEncoding;
855
+ goto error;
856
+ }
857
+ size_t len = os.PutEnd(begin);
858
+ i += is.Tell() - 1;
859
+ if (len == 1)
860
+ c = *name;
861
+ else {
862
+ name += len;
863
+ isNumber = false;
864
+ i++;
865
+ continue;
866
+ }
867
+ }
868
+ else if (NeedPercentEncode(c)) {
869
+ parseErrorCode_ = kPointerParseErrorCharacterMustPercentEncode;
870
+ goto error;
871
+ }
872
+ }
873
+
874
+ i++;
875
+
876
+ // Escaping "~0" -> '~', "~1" -> '/'
877
+ if (c == '~') {
878
+ if (i < length) {
879
+ c = source[i];
880
+ if (c == '0') c = '~';
881
+ else if (c == '1') c = '/';
882
+ else {
883
+ parseErrorCode_ = kPointerParseErrorInvalidEscape;
884
+ goto error;
885
+ }
886
+ i++;
887
+ }
888
+ else {
889
+ parseErrorCode_ = kPointerParseErrorInvalidEscape;
890
+ goto error;
891
+ }
892
+ }
893
+
894
+ // First check for index: all of characters are digit
895
+ if (c < '0' || c > '9')
896
+ isNumber = false;
897
+
898
+ *name++ = c;
899
+ }
900
+ token->length = static_cast<SizeType>(name - token->name);
901
+ if (token->length == 0)
902
+ isNumber = false;
903
+ *name++ = '\0'; // Null terminator
904
+
905
+ // Second check for index: more than one digit cannot have leading zero
906
+ if (isNumber && token->length > 1 && token->name[0] == '0')
907
+ isNumber = false;
908
+
909
+ // String to SizeType conversion
910
+ SizeType n = 0;
911
+ if (isNumber) {
912
+ for (size_t j = 0; j < token->length; j++) {
913
+ SizeType m = n * 10 + static_cast<SizeType>(token->name[j] - '0');
914
+ if (m < n) { // overflow detection
915
+ isNumber = false;
916
+ break;
917
+ }
918
+ n = m;
919
+ }
920
+ }
921
+
922
+ token->index = isNumber ? n : kPointerInvalidIndex;
923
+ token++;
924
+ }
925
+
926
+ RAPIDJSON_ASSERT(name <= nameBuffer_ + length); // Should not overflow buffer
927
+ parseErrorCode_ = kPointerParseErrorNone;
928
+ return;
929
+
930
+ error:
931
+ Allocator::Free(tokens_);
932
+ nameBuffer_ = 0;
933
+ tokens_ = 0;
934
+ tokenCount_ = 0;
935
+ parseErrorOffset_ = i;
936
+ return;
937
+ }
938
+
939
+ //! Stringify to string or URI fragment representation.
940
+ /*!
941
+ \tparam uriFragment True for stringifying to URI fragment representation. False for string representation.
942
+ \tparam OutputStream type of output stream.
943
+ \param os The output stream.
944
+ */
945
+ template<bool uriFragment, typename OutputStream>
946
+ bool Stringify(OutputStream& os) const {
947
+ RAPIDJSON_ASSERT(IsValid());
948
+
949
+ if (uriFragment)
950
+ os.Put('#');
951
+
952
+ for (Token *t = tokens_; t != tokens_ + tokenCount_; ++t) {
953
+ os.Put('/');
954
+ for (size_t j = 0; j < t->length; j++) {
955
+ Ch c = t->name[j];
956
+ if (c == '~') {
957
+ os.Put('~');
958
+ os.Put('0');
959
+ }
960
+ else if (c == '/') {
961
+ os.Put('~');
962
+ os.Put('1');
963
+ }
964
+ else if (uriFragment && NeedPercentEncode(c)) {
965
+ // Transcode to UTF8 sequence
966
+ GenericStringStream<typename ValueType::EncodingType> source(&t->name[j]);
967
+ PercentEncodeStream<OutputStream> target(os);
968
+ if (!Transcoder<EncodingType, UTF8<> >().Validate(source, target))
969
+ return false;
970
+ j += source.Tell() - 1;
971
+ }
972
+ else
973
+ os.Put(c);
974
+ }
975
+ }
976
+ return true;
977
+ }
978
+
979
+ //! A helper stream for decoding a percent-encoded sequence into code unit.
980
+ /*!
981
+ This stream decodes %XY triplet into code unit (0-255).
982
+ If it encounters invalid characters, it sets output code unit as 0 and
983
+ mark invalid, and to be checked by IsValid().
984
+ */
985
+ class PercentDecodeStream {
986
+ public:
987
+ typedef typename ValueType::Ch Ch;
988
+
989
+ //! Constructor
990
+ /*!
991
+ \param source Start of the stream
992
+ \param end Past-the-end of the stream.
993
+ */
994
+ PercentDecodeStream(const Ch* source, const Ch* end) : src_(source), head_(source), end_(end), valid_(true) {}
995
+
996
+ Ch Take() {
997
+ if (*src_ != '%' || src_ + 3 > end_) { // %XY triplet
998
+ valid_ = false;
999
+ return 0;
1000
+ }
1001
+ src_++;
1002
+ Ch c = 0;
1003
+ for (int j = 0; j < 2; j++) {
1004
+ c = static_cast<Ch>(c << 4);
1005
+ Ch h = *src_;
1006
+ if (h >= '0' && h <= '9') c = static_cast<Ch>(c + h - '0');
1007
+ else if (h >= 'A' && h <= 'F') c = static_cast<Ch>(c + h - 'A' + 10);
1008
+ else if (h >= 'a' && h <= 'f') c = static_cast<Ch>(c + h - 'a' + 10);
1009
+ else {
1010
+ valid_ = false;
1011
+ return 0;
1012
+ }
1013
+ src_++;
1014
+ }
1015
+ return c;
1016
+ }
1017
+
1018
+ size_t Tell() const { return static_cast<size_t>(src_ - head_); }
1019
+ bool IsValid() const { return valid_; }
1020
+
1021
+ private:
1022
+ const Ch* src_; //!< Current read position.
1023
+ const Ch* head_; //!< Original head of the string.
1024
+ const Ch* end_; //!< Past-the-end position.
1025
+ bool valid_; //!< Whether the parsing is valid.
1026
+ };
1027
+
1028
+ //! A helper stream to encode character (UTF-8 code unit) into percent-encoded sequence.
1029
+ template <typename OutputStream>
1030
+ class PercentEncodeStream {
1031
+ public:
1032
+ PercentEncodeStream(OutputStream& os) : os_(os) {}
1033
+ void Put(char c) { // UTF-8 must be byte
1034
+ unsigned char u = static_cast<unsigned char>(c);
1035
+ static const char hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
1036
+ os_.Put('%');
1037
+ os_.Put(static_cast<typename OutputStream::Ch>(hexDigits[u >> 4]));
1038
+ os_.Put(static_cast<typename OutputStream::Ch>(hexDigits[u & 15]));
1039
+ }
1040
+ private:
1041
+ OutputStream& os_;
1042
+ };
1043
+
1044
+ Allocator* allocator_; //!< The current allocator. It is either user-supplied or equal to ownAllocator_.
1045
+ Allocator* ownAllocator_; //!< Allocator owned by this Pointer.
1046
+ Ch* nameBuffer_; //!< A buffer containing all names in tokens.
1047
+ Token* tokens_; //!< A list of tokens.
1048
+ size_t tokenCount_; //!< Number of tokens in tokens_.
1049
+ size_t parseErrorOffset_; //!< Offset in code unit when parsing fail.
1050
+ PointerParseErrorCode parseErrorCode_; //!< Parsing error code.
1051
+ };
1052
+
1053
+ //! GenericPointer for Value (UTF-8, default allocator).
1054
+ typedef GenericPointer<Value> Pointer;
1055
+
1056
+ //!@name Helper functions for GenericPointer
1057
+ //@{
1058
+
1059
+ //////////////////////////////////////////////////////////////////////////////
1060
+
1061
+ template <typename T>
1062
+ typename T::ValueType& CreateValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, typename T::AllocatorType& a) {
1063
+ return pointer.Create(root, a);
1064
+ }
1065
+
1066
+ template <typename T, typename CharType, size_t N>
1067
+ typename T::ValueType& CreateValueByPointer(T& root, const CharType(&source)[N], typename T::AllocatorType& a) {
1068
+ return GenericPointer<typename T::ValueType>(source, N - 1).Create(root, a);
1069
+ }
1070
+
1071
+ // No allocator parameter
1072
+
1073
+ template <typename DocumentType>
1074
+ typename DocumentType::ValueType& CreateValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer) {
1075
+ return pointer.Create(document);
1076
+ }
1077
+
1078
+ template <typename DocumentType, typename CharType, size_t N>
1079
+ typename DocumentType::ValueType& CreateValueByPointer(DocumentType& document, const CharType(&source)[N]) {
1080
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Create(document);
1081
+ }
1082
+
1083
+ //////////////////////////////////////////////////////////////////////////////
1084
+
1085
+ template <typename T>
1086
+ typename T::ValueType* GetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, size_t* unresolvedTokenIndex = 0) {
1087
+ return pointer.Get(root, unresolvedTokenIndex);
1088
+ }
1089
+
1090
+ template <typename T>
1091
+ const typename T::ValueType* GetValueByPointer(const T& root, const GenericPointer<typename T::ValueType>& pointer, size_t* unresolvedTokenIndex = 0) {
1092
+ return pointer.Get(root, unresolvedTokenIndex);
1093
+ }
1094
+
1095
+ template <typename T, typename CharType, size_t N>
1096
+ typename T::ValueType* GetValueByPointer(T& root, const CharType (&source)[N], size_t* unresolvedTokenIndex = 0) {
1097
+ return GenericPointer<typename T::ValueType>(source, N - 1).Get(root, unresolvedTokenIndex);
1098
+ }
1099
+
1100
+ template <typename T, typename CharType, size_t N>
1101
+ const typename T::ValueType* GetValueByPointer(const T& root, const CharType(&source)[N], size_t* unresolvedTokenIndex = 0) {
1102
+ return GenericPointer<typename T::ValueType>(source, N - 1).Get(root, unresolvedTokenIndex);
1103
+ }
1104
+
1105
+ //////////////////////////////////////////////////////////////////////////////
1106
+
1107
+ template <typename T>
1108
+ typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::ValueType& defaultValue, typename T::AllocatorType& a) {
1109
+ return pointer.GetWithDefault(root, defaultValue, a);
1110
+ }
1111
+
1112
+ template <typename T>
1113
+ typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::Ch* defaultValue, typename T::AllocatorType& a) {
1114
+ return pointer.GetWithDefault(root, defaultValue, a);
1115
+ }
1116
+
1117
+ #if RAPIDJSON_HAS_STDSTRING
1118
+ template <typename T>
1119
+ typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, const std::basic_string<typename T::Ch>& defaultValue, typename T::AllocatorType& a) {
1120
+ return pointer.GetWithDefault(root, defaultValue, a);
1121
+ }
1122
+ #endif
1123
+
1124
+ template <typename T, typename T2>
1125
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&))
1126
+ GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, T2 defaultValue, typename T::AllocatorType& a) {
1127
+ return pointer.GetWithDefault(root, defaultValue, a);
1128
+ }
1129
+
1130
+ template <typename T, typename CharType, size_t N>
1131
+ typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::ValueType& defaultValue, typename T::AllocatorType& a) {
1132
+ return GenericPointer<typename T::ValueType>(source, N - 1).GetWithDefault(root, defaultValue, a);
1133
+ }
1134
+
1135
+ template <typename T, typename CharType, size_t N>
1136
+ typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::Ch* defaultValue, typename T::AllocatorType& a) {
1137
+ return GenericPointer<typename T::ValueType>(source, N - 1).GetWithDefault(root, defaultValue, a);
1138
+ }
1139
+
1140
+ #if RAPIDJSON_HAS_STDSTRING
1141
+ template <typename T, typename CharType, size_t N>
1142
+ typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const std::basic_string<typename T::Ch>& defaultValue, typename T::AllocatorType& a) {
1143
+ return GenericPointer<typename T::ValueType>(source, N - 1).GetWithDefault(root, defaultValue, a);
1144
+ }
1145
+ #endif
1146
+
1147
+ template <typename T, typename CharType, size_t N, typename T2>
1148
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&))
1149
+ GetValueByPointerWithDefault(T& root, const CharType(&source)[N], T2 defaultValue, typename T::AllocatorType& a) {
1150
+ return GenericPointer<typename T::ValueType>(source, N - 1).GetWithDefault(root, defaultValue, a);
1151
+ }
1152
+
1153
+ // No allocator parameter
1154
+
1155
+ template <typename DocumentType>
1156
+ typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const typename DocumentType::ValueType& defaultValue) {
1157
+ return pointer.GetWithDefault(document, defaultValue);
1158
+ }
1159
+
1160
+ template <typename DocumentType>
1161
+ typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const typename DocumentType::Ch* defaultValue) {
1162
+ return pointer.GetWithDefault(document, defaultValue);
1163
+ }
1164
+
1165
+ #if RAPIDJSON_HAS_STDSTRING
1166
+ template <typename DocumentType>
1167
+ typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const std::basic_string<typename DocumentType::Ch>& defaultValue) {
1168
+ return pointer.GetWithDefault(document, defaultValue);
1169
+ }
1170
+ #endif
1171
+
1172
+ template <typename DocumentType, typename T2>
1173
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename DocumentType::ValueType&))
1174
+ GetValueByPointerWithDefault(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, T2 defaultValue) {
1175
+ return pointer.GetWithDefault(document, defaultValue);
1176
+ }
1177
+
1178
+ template <typename DocumentType, typename CharType, size_t N>
1179
+ typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const typename DocumentType::ValueType& defaultValue) {
1180
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).GetWithDefault(document, defaultValue);
1181
+ }
1182
+
1183
+ template <typename DocumentType, typename CharType, size_t N>
1184
+ typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const typename DocumentType::Ch* defaultValue) {
1185
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).GetWithDefault(document, defaultValue);
1186
+ }
1187
+
1188
+ #if RAPIDJSON_HAS_STDSTRING
1189
+ template <typename DocumentType, typename CharType, size_t N>
1190
+ typename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const std::basic_string<typename DocumentType::Ch>& defaultValue) {
1191
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).GetWithDefault(document, defaultValue);
1192
+ }
1193
+ #endif
1194
+
1195
+ template <typename DocumentType, typename CharType, size_t N, typename T2>
1196
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename DocumentType::ValueType&))
1197
+ GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], T2 defaultValue) {
1198
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).GetWithDefault(document, defaultValue);
1199
+ }
1200
+
1201
+ //////////////////////////////////////////////////////////////////////////////
1202
+
1203
+ template <typename T>
1204
+ typename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, typename T::ValueType& value, typename T::AllocatorType& a) {
1205
+ return pointer.Set(root, value, a);
1206
+ }
1207
+
1208
+ template <typename T>
1209
+ typename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::ValueType& value, typename T::AllocatorType& a) {
1210
+ return pointer.Set(root, value, a);
1211
+ }
1212
+
1213
+ template <typename T>
1214
+ typename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::Ch* value, typename T::AllocatorType& a) {
1215
+ return pointer.Set(root, value, a);
1216
+ }
1217
+
1218
+ #if RAPIDJSON_HAS_STDSTRING
1219
+ template <typename T>
1220
+ typename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, const std::basic_string<typename T::Ch>& value, typename T::AllocatorType& a) {
1221
+ return pointer.Set(root, value, a);
1222
+ }
1223
+ #endif
1224
+
1225
+ template <typename T, typename T2>
1226
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&))
1227
+ SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, T2 value, typename T::AllocatorType& a) {
1228
+ return pointer.Set(root, value, a);
1229
+ }
1230
+
1231
+ template <typename T, typename CharType, size_t N>
1232
+ typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) {
1233
+ return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);
1234
+ }
1235
+
1236
+ template <typename T, typename CharType, size_t N>
1237
+ typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const typename T::ValueType& value, typename T::AllocatorType& a) {
1238
+ return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);
1239
+ }
1240
+
1241
+ template <typename T, typename CharType, size_t N>
1242
+ typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const typename T::Ch* value, typename T::AllocatorType& a) {
1243
+ return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);
1244
+ }
1245
+
1246
+ #if RAPIDJSON_HAS_STDSTRING
1247
+ template <typename T, typename CharType, size_t N>
1248
+ typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const std::basic_string<typename T::Ch>& value, typename T::AllocatorType& a) {
1249
+ return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);
1250
+ }
1251
+ #endif
1252
+
1253
+ template <typename T, typename CharType, size_t N, typename T2>
1254
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&))
1255
+ SetValueByPointer(T& root, const CharType(&source)[N], T2 value, typename T::AllocatorType& a) {
1256
+ return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);
1257
+ }
1258
+
1259
+ // No allocator parameter
1260
+
1261
+ template <typename DocumentType>
1262
+ typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, typename DocumentType::ValueType& value) {
1263
+ return pointer.Set(document, value);
1264
+ }
1265
+
1266
+ template <typename DocumentType>
1267
+ typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const typename DocumentType::ValueType& value) {
1268
+ return pointer.Set(document, value);
1269
+ }
1270
+
1271
+ template <typename DocumentType>
1272
+ typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const typename DocumentType::Ch* value) {
1273
+ return pointer.Set(document, value);
1274
+ }
1275
+
1276
+ #if RAPIDJSON_HAS_STDSTRING
1277
+ template <typename DocumentType>
1278
+ typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const std::basic_string<typename DocumentType::Ch>& value) {
1279
+ return pointer.Set(document, value);
1280
+ }
1281
+ #endif
1282
+
1283
+ template <typename DocumentType, typename T2>
1284
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename DocumentType::ValueType&))
1285
+ SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, T2 value) {
1286
+ return pointer.Set(document, value);
1287
+ }
1288
+
1289
+ template <typename DocumentType, typename CharType, size_t N>
1290
+ typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], typename DocumentType::ValueType& value) {
1291
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);
1292
+ }
1293
+
1294
+ template <typename DocumentType, typename CharType, size_t N>
1295
+ typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const typename DocumentType::ValueType& value) {
1296
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);
1297
+ }
1298
+
1299
+ template <typename DocumentType, typename CharType, size_t N>
1300
+ typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const typename DocumentType::Ch* value) {
1301
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);
1302
+ }
1303
+
1304
+ #if RAPIDJSON_HAS_STDSTRING
1305
+ template <typename DocumentType, typename CharType, size_t N>
1306
+ typename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const std::basic_string<typename DocumentType::Ch>& value) {
1307
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);
1308
+ }
1309
+ #endif
1310
+
1311
+ template <typename DocumentType, typename CharType, size_t N, typename T2>
1312
+ RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename DocumentType::ValueType&))
1313
+ SetValueByPointer(DocumentType& document, const CharType(&source)[N], T2 value) {
1314
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);
1315
+ }
1316
+
1317
+ //////////////////////////////////////////////////////////////////////////////
1318
+
1319
+ template <typename T>
1320
+ typename T::ValueType& SwapValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, typename T::ValueType& value, typename T::AllocatorType& a) {
1321
+ return pointer.Swap(root, value, a);
1322
+ }
1323
+
1324
+ template <typename T, typename CharType, size_t N>
1325
+ typename T::ValueType& SwapValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) {
1326
+ return GenericPointer<typename T::ValueType>(source, N - 1).Swap(root, value, a);
1327
+ }
1328
+
1329
+ template <typename DocumentType>
1330
+ typename DocumentType::ValueType& SwapValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, typename DocumentType::ValueType& value) {
1331
+ return pointer.Swap(document, value);
1332
+ }
1333
+
1334
+ template <typename DocumentType, typename CharType, size_t N>
1335
+ typename DocumentType::ValueType& SwapValueByPointer(DocumentType& document, const CharType(&source)[N], typename DocumentType::ValueType& value) {
1336
+ return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Swap(document, value);
1337
+ }
1338
+
1339
+ //////////////////////////////////////////////////////////////////////////////
1340
+
1341
+ template <typename T>
1342
+ bool EraseValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer) {
1343
+ return pointer.Erase(root);
1344
+ }
1345
+
1346
+ template <typename T, typename CharType, size_t N>
1347
+ bool EraseValueByPointer(T& root, const CharType(&source)[N]) {
1348
+ return GenericPointer<typename T::ValueType>(source, N - 1).Erase(root);
1349
+ }
1350
+
1351
+ //@}
1352
+
1353
+ RAPIDJSON_NAMESPACE_END
1354
+
1355
+ #ifdef __clang__
1356
+ RAPIDJSON_DIAG_POP
1357
+ #endif
1358
+
1359
+ #ifdef _MSC_VER
1360
+ RAPIDJSON_DIAG_POP
1361
+ #endif
1362
+
1363
+ #endif // RAPIDJSON_POINTER_H_