libcouchbase 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.travis.yml +35 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +389 -0
- data/Rakefile +75 -0
- data/ext/README.md +6 -0
- data/ext/Rakefile +20 -0
- data/ext/libcouchbase/.gitignore +130 -0
- data/ext/libcouchbase/.travis.yml +19 -0
- data/ext/libcouchbase/CMakeLists.txt +429 -0
- data/ext/libcouchbase/CONTRIBUTING.md +124 -0
- data/ext/libcouchbase/LICENSE +202 -0
- data/ext/libcouchbase/README.markdown +163 -0
- data/ext/libcouchbase/RELEASE_NOTES.markdown +2691 -0
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +27 -0
- data/ext/libcouchbase/cmake/Modules/CopyPDB.cmake +42 -0
- data/ext/libcouchbase/cmake/Modules/DistScript.cmake +17 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +20 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseHdrHistogram.cmake +15 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibev.cmake +73 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +52 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +56 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +29 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +133 -0
- data/ext/libcouchbase/cmake/Modules/GetPlatformCCInfo.cmake +45 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +70 -0
- data/ext/libcouchbase/cmake/config-cmake.h.in +60 -0
- data/ext/libcouchbase/cmake/configure +357 -0
- data/ext/libcouchbase/cmake/defs.mk.in +8 -0
- data/ext/libcouchbase/cmake/dtrace-instr-link.pl +38 -0
- data/ext/libcouchbase/cmake/source_files.cmake +73 -0
- data/ext/libcouchbase/configure.pl +1 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +624 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.h +158 -0
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +9 -0
- data/ext/libcouchbase/contrib/cbsasl/COPYING +202 -0
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +217 -0
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +205 -0
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +46 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.c +67 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.h +33 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.c +296 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.h +45 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.c +573 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.h +15 -0
- data/ext/libcouchbase/contrib/cbsasl/src/util.h +31 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +2 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.c +747 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +493 -0
- data/ext/libcouchbase/contrib/genhash/genhash.c +372 -0
- data/ext/libcouchbase/contrib/genhash/genhash.h +235 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CHANGES +157 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CMakeLists.txt +252 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CONTRIBUTORS +37 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/LICENSE +28 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/MINIFY.sh +15 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/README +435 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/cmake/internal_utils.cmake +227 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-death-test.h +294 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-message.h +250 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h +1421 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h.pump +487 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-printers.h +855 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-spi.h +232 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-test-part.h +179 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-typed-test.h +259 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest.h +2291 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_pred_impl.h +358 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_prod.h +58 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-death-test-internal.h +319 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-filepath.h +206 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-internal.h +1158 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-linked_ptr.h +233 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h +5143 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util.h +619 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-port.h +1947 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-string.h +167 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h +1012 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h.pump +339 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h +3331 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h.pump +297 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-all.cc +48 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-death-test.cc +1344 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-filepath.cc +382 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-internal-inl.h +1218 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-port.cc +805 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-printers.cc +363 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-test-part.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-typed-test.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest.cc +5015 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest_main.cc +38 -0
- data/ext/libcouchbase/contrib/http_parser/LICENSE-MIT +23 -0
- data/ext/libcouchbase/contrib/http_parser/README.md +178 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.c +2060 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.h +321 -0
- data/ext/libcouchbase/contrib/jsonsl/LICENSE +20 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.c +1452 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.h +971 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/CMakeLists.txt +6 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/LICENSE +55 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp-forwards.h +255 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4892 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.h +1961 -0
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +8 -0
- data/ext/libcouchbase/contrib/snappy/COPYING +28 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.cc +90 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.h +138 -0
- data/ext/libcouchbase/contrib/snappy/snappy-internal.h +150 -0
- data/ext/libcouchbase/contrib/snappy/snappy-lcb-msvc.h +5 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +71 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.h +137 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.h +491 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +98 -0
- data/ext/libcouchbase/contrib/snappy/snappy.cc +1307 -0
- data/ext/libcouchbase/contrib/snappy/snappy.h +184 -0
- data/ext/libcouchbase/contrib/win32-defs/iocpdefs.h +133 -0
- data/ext/libcouchbase/contrib/win32-defs/mingwdefs.h +4396 -0
- data/ext/libcouchbase/contrib/win32-defs/win_stdint.h +258 -0
- data/ext/libcouchbase/example/CMakeLists.txt +37 -0
- data/ext/libcouchbase/example/README.markdown +47 -0
- data/ext/libcouchbase/example/db/db.c +167 -0
- data/ext/libcouchbase/example/db/vb.c +227 -0
- data/ext/libcouchbase/example/instancepool/main.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.h +69 -0
- data/ext/libcouchbase/example/libeventdirect/main.c +148 -0
- data/ext/libcouchbase/example/mcc/mcc.cc +246 -0
- data/ext/libcouchbase/example/minimal/minimal.c +130 -0
- data/ext/libcouchbase/example/observe/observe.c +146 -0
- data/ext/libcouchbase/example/subdoc/subdoc-multi.cc +132 -0
- data/ext/libcouchbase/example/subdoc/subdoc-simple.cc +191 -0
- data/ext/libcouchbase/example/tick/tick.c +119 -0
- data/ext/libcouchbase/example/views/views-example.cc +83 -0
- data/ext/libcouchbase/include/libcouchbase/_cxxwrap.h +150 -0
- data/ext/libcouchbase/include/libcouchbase/api-legacy.h +1689 -0
- data/ext/libcouchbase/include/libcouchbase/api3.h +2 -0
- data/ext/libcouchbase/include/libcouchbase/assert.h +44 -0
- data/ext/libcouchbase/include/libcouchbase/cbft.h +109 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +356 -0
- data/ext/libcouchbase/include/libcouchbase/cntl.h +937 -0
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +23 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +3677 -0
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +300 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +595 -0
- data/ext/libcouchbase/include/libcouchbase/http.h +1 -0
- data/ext/libcouchbase/include/libcouchbase/iops.h +1050 -0
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +263 -0
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +132 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +364 -0
- data/ext/libcouchbase/include/libcouchbase/pktfwd.h +270 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +367 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr-inl.c +76 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr.h +199 -0
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +312 -0
- data/ext/libcouchbase/include/libcouchbase/sysdefs.h +98 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +643 -0
- data/ext/libcouchbase/include/libcouchbase/views.h +298 -0
- data/ext/libcouchbase/include/libcouchbase/visibility.h +65 -0
- data/ext/libcouchbase/include/memcached/COPYING +30 -0
- data/ext/libcouchbase/include/memcached/README +10 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +1916 -0
- data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
- data/ext/libcouchbase/packaging/README +7 -0
- data/ext/libcouchbase/packaging/abicheck/.gitignore +4 -0
- data/ext/libcouchbase/packaging/abicheck/Makefile +17 -0
- data/ext/libcouchbase/packaging/abicheck/README.md +27 -0
- data/ext/libcouchbase/packaging/abicheck/template.xml +3 -0
- data/ext/libcouchbase/packaging/deb/compat +1 -0
- data/ext/libcouchbase/packaging/deb/control +73 -0
- data/ext/libcouchbase/packaging/deb/copyright +10 -0
- data/ext/libcouchbase/packaging/deb/libcouchbase-dev.docs +3 -0
- data/ext/libcouchbase/packaging/deb/package.mk +31 -0
- data/ext/libcouchbase/packaging/deb/rules +46 -0
- data/ext/libcouchbase/packaging/deb/source/format +1 -0
- data/ext/libcouchbase/packaging/distinfo/README +1 -0
- data/ext/libcouchbase/packaging/distinfo/distinfo.cmake.in +4 -0
- data/ext/libcouchbase/packaging/dllversion.rc.in +39 -0
- data/ext/libcouchbase/packaging/libcouchbase.pc.in +10 -0
- data/ext/libcouchbase/packaging/nuget/libcouchbase.autopkg +76 -0
- data/ext/libcouchbase/packaging/parse-git-describe.pl +166 -0
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +108 -0
- data/ext/libcouchbase/packaging/rpm/package.mk +40 -0
- data/ext/libcouchbase/plugins/io/iocp/CMakeLists.txt +9 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.c +466 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.h +217 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_loop.c +295 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_timer.c +79 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_util.c +229 -0
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +65 -0
- data/ext/libcouchbase/plugins/io/libev/plugin-libev.c +289 -0
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libevent/libevent_io_opts.h +67 -0
- data/ext/libcouchbase/plugins/io/libevent/plugin-libevent.c +292 -0
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +42 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +212 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_io_opts.h +118 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +148 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +648 -0
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +11 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +448 -0
- data/ext/libcouchbase/plugins/io/select/select_io_opts.h +39 -0
- data/ext/libcouchbase/src/README.md +103 -0
- data/ext/libcouchbase/src/aspend.h +106 -0
- data/ext/libcouchbase/src/auth.cc +74 -0
- data/ext/libcouchbase/src/auth.h +54 -0
- data/ext/libcouchbase/src/bootstrap.c +269 -0
- data/ext/libcouchbase/src/bootstrap.h +129 -0
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +495 -0
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +82 -0
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +681 -0
- data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
- data/ext/libcouchbase/src/callbacks.c +378 -0
- data/ext/libcouchbase/src/cbft.cc +210 -0
- data/ext/libcouchbase/src/cntl.cc +847 -0
- data/ext/libcouchbase/src/config_static.h +159 -0
- data/ext/libcouchbase/src/connspec.cc +462 -0
- data/ext/libcouchbase/src/connspec.h +105 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +27 -0
- data/ext/libcouchbase/src/dump.c +98 -0
- data/ext/libcouchbase/src/getconfig.c +100 -0
- data/ext/libcouchbase/src/gethrtime.c +109 -0
- data/ext/libcouchbase/src/handler.c +922 -0
- data/ext/libcouchbase/src/hashset.c +164 -0
- data/ext/libcouchbase/src/hashset.h +86 -0
- data/ext/libcouchbase/src/hashtable.c +75 -0
- data/ext/libcouchbase/src/hdr_timings.c +92 -0
- data/ext/libcouchbase/src/hostlist.cc +301 -0
- data/ext/libcouchbase/src/hostlist.h +171 -0
- data/ext/libcouchbase/src/http/http-priv.h +307 -0
- data/ext/libcouchbase/src/http/http.cc +633 -0
- data/ext/libcouchbase/src/http/http.h +34 -0
- data/ext/libcouchbase/src/http/http_io.cc +307 -0
- data/ext/libcouchbase/src/instance.cc +722 -0
- data/ext/libcouchbase/src/internal.h +244 -0
- data/ext/libcouchbase/src/iofactory.c +575 -0
- data/ext/libcouchbase/src/jsparse/parser.cc +519 -0
- data/ext/libcouchbase/src/jsparse/parser.h +173 -0
- data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +199 -0
- data/ext/libcouchbase/src/lcbio/connect.c +557 -0
- data/ext/libcouchbase/src/lcbio/connect.h +364 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +611 -0
- data/ext/libcouchbase/src/lcbio/ctx.h +405 -0
- data/ext/libcouchbase/src/lcbio/iotable.c +290 -0
- data/ext/libcouchbase/src/lcbio/iotable.h +84 -0
- data/ext/libcouchbase/src/lcbio/ioutils.c +350 -0
- data/ext/libcouchbase/src/lcbio/ioutils.h +203 -0
- data/ext/libcouchbase/src/lcbio/lcbio.h +51 -0
- data/ext/libcouchbase/src/lcbio/manager.c +584 -0
- data/ext/libcouchbase/src/lcbio/manager.h +156 -0
- data/ext/libcouchbase/src/lcbio/protoctx.c +84 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +115 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +149 -0
- data/ext/libcouchbase/src/lcbio/timer-ng.h +179 -0
- data/ext/libcouchbase/src/lcbio/timer.c +132 -0
- data/ext/libcouchbase/src/legacy.c +430 -0
- data/ext/libcouchbase/src/list.c +144 -0
- data/ext/libcouchbase/src/list.h +127 -0
- data/ext/libcouchbase/src/logging.c +244 -0
- data/ext/libcouchbase/src/logging.h +86 -0
- data/ext/libcouchbase/src/mc/compress.c +90 -0
- data/ext/libcouchbase/src/mc/compress.h +61 -0
- data/ext/libcouchbase/src/mc/forward.c +186 -0
- data/ext/libcouchbase/src/mc/forward.h +90 -0
- data/ext/libcouchbase/src/mc/iovcursor-inl.h +279 -0
- data/ext/libcouchbase/src/mc/iovcursor.h +66 -0
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +111 -0
- data/ext/libcouchbase/src/mc/mcreq.c +954 -0
- data/ext/libcouchbase/src/mc/mcreq.h +977 -0
- data/ext/libcouchbase/src/mcserver/mcserver.c +784 -0
- data/ext/libcouchbase/src/mcserver/mcserver.h +121 -0
- data/ext/libcouchbase/src/mcserver/negotiate.c +656 -0
- data/ext/libcouchbase/src/mcserver/negotiate.h +119 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +860 -0
- data/ext/libcouchbase/src/n1ql/n1ql-internal.h +22 -0
- data/ext/libcouchbase/src/n1ql/n1ql.cc +729 -0
- data/ext/libcouchbase/src/n1ql/params.cc +215 -0
- data/ext/libcouchbase/src/netbuf/netbuf-defs.h +89 -0
- data/ext/libcouchbase/src/netbuf/netbuf-mblock.h +235 -0
- data/ext/libcouchbase/src/netbuf/netbuf.c +929 -0
- data/ext/libcouchbase/src/netbuf/netbuf.h +452 -0
- data/ext/libcouchbase/src/newconfig.c +385 -0
- data/ext/libcouchbase/src/nodeinfo.cc +194 -0
- data/ext/libcouchbase/src/operations/cbflush.c +71 -0
- data/ext/libcouchbase/src/operations/counter.c +116 -0
- data/ext/libcouchbase/src/operations/durability-cas.c +224 -0
- data/ext/libcouchbase/src/operations/durability-seqno.c +157 -0
- data/ext/libcouchbase/src/operations/durability.c +668 -0
- data/ext/libcouchbase/src/operations/durability_internal.h +199 -0
- data/ext/libcouchbase/src/operations/get.c +409 -0
- data/ext/libcouchbase/src/operations/observe-seqno.c +96 -0
- data/ext/libcouchbase/src/operations/observe.c +340 -0
- data/ext/libcouchbase/src/operations/pktfwd.c +86 -0
- data/ext/libcouchbase/src/operations/remove.c +83 -0
- data/ext/libcouchbase/src/operations/stats.c +461 -0
- data/ext/libcouchbase/src/operations/store.c +360 -0
- data/ext/libcouchbase/src/operations/subdoc.cc +510 -0
- data/ext/libcouchbase/src/operations/touch.c +81 -0
- data/ext/libcouchbase/src/packetutils.c +60 -0
- data/ext/libcouchbase/src/packetutils.h +147 -0
- data/ext/libcouchbase/src/probes.d +211 -0
- data/ext/libcouchbase/src/rdb/bigalloc.c +225 -0
- data/ext/libcouchbase/src/rdb/bigalloc.h +73 -0
- data/ext/libcouchbase/src/rdb/chunkalloc.c +174 -0
- data/ext/libcouchbase/src/rdb/libcalloc.c +94 -0
- data/ext/libcouchbase/src/rdb/rope.c +419 -0
- data/ext/libcouchbase/src/rdb/rope.h +488 -0
- data/ext/libcouchbase/src/retrychk.c +113 -0
- data/ext/libcouchbase/src/retryq.c +424 -0
- data/ext/libcouchbase/src/retryq.h +157 -0
- data/ext/libcouchbase/src/ringbuffer.c +442 -0
- data/ext/libcouchbase/src/ringbuffer.h +100 -0
- data/ext/libcouchbase/src/settings.c +95 -0
- data/ext/libcouchbase/src/settings.h +188 -0
- data/ext/libcouchbase/src/simplestring.c +211 -0
- data/ext/libcouchbase/src/simplestring.h +228 -0
- data/ext/libcouchbase/src/sllist-inl.h +197 -0
- data/ext/libcouchbase/src/sllist.h +76 -0
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +23 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +415 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +454 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +408 -0
- data/ext/libcouchbase/src/ssl/ssl_iot_common.h +180 -0
- data/ext/libcouchbase/src/ssobuf.h +82 -0
- data/ext/libcouchbase/src/strcodecs/base64.c +123 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +285 -0
- data/ext/libcouchbase/src/timings.c +208 -0
- data/ext/libcouchbase/src/trace.h +105 -0
- data/ext/libcouchbase/src/utilities.c +171 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -0
- data/ext/libcouchbase/src/vbucket/aliases.h +35 -0
- data/ext/libcouchbase/src/vbucket/crc32.h +83 -0
- data/ext/libcouchbase/src/vbucket/hash.h +30 -0
- data/ext/libcouchbase/src/vbucket/json-inl.h +112 -0
- data/ext/libcouchbase/src/vbucket/ketama.c +66 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/global.h +32 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5.h +35 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5c-inl.h +335 -0
- data/ext/libcouchbase/src/vbucket/vbucket.c +1543 -0
- data/ext/libcouchbase/src/views/docreq.c +194 -0
- data/ext/libcouchbase/src/views/docreq.h +83 -0
- data/ext/libcouchbase/src/views/viewreq.c +358 -0
- data/ext/libcouchbase/src/views/viewreq.h +36 -0
- data/ext/libcouchbase/src/wait.c +161 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +140 -0
- data/ext/libcouchbase/tests/basic/t_base64.cc +81 -0
- data/ext/libcouchbase/tests/basic/t_ccbc103.cc +95 -0
- data/ext/libcouchbase/tests/basic/t_connstr.cc +404 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +32 -0
- data/ext/libcouchbase/tests/basic/t_ctlcodes.cc +92 -0
- data/ext/libcouchbase/tests/basic/t_hashset.cc +262 -0
- data/ext/libcouchbase/tests/basic/t_host.cc +198 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +137 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.h +589 -0
- data/ext/libcouchbase/tests/basic/t_list.cc +155 -0
- data/ext/libcouchbase/tests/basic/t_logger.cc +65 -0
- data/ext/libcouchbase/tests/basic/t_misc.cc +24 -0
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +18 -0
- data/ext/libcouchbase/tests/basic/t_netbuf.cc +446 -0
- data/ext/libcouchbase/tests/basic/t_packet.cc +222 -0
- data/ext/libcouchbase/tests/basic/t_ringbuffer.cc +278 -0
- data/ext/libcouchbase/tests/basic/t_slist.cc +429 -0
- data/ext/libcouchbase/tests/basic/t_strerror.cc +64 -0
- data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
- data/ext/libcouchbase/tests/basic/t_urlencode.cc +132 -0
- data/ext/libcouchbase/tests/check-all.cc +608 -0
- data/ext/libcouchbase/tests/htparse/t_basic.cc +193 -0
- data/ext/libcouchbase/tests/ioserver/connection.cc +166 -0
- data/ext/libcouchbase/tests/ioserver/future.cc +50 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +104 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.h +478 -0
- data/ext/libcouchbase/tests/ioserver/socket.cc +88 -0
- data/ext/libcouchbase/tests/ioserver/ssl_connection.cc +145 -0
- data/ext/libcouchbase/tests/ioserver/threads-pthreads.cc +119 -0
- data/ext/libcouchbase/tests/ioserver/threads-win32.cc +117 -0
- data/ext/libcouchbase/tests/ioserver/threads.h +66 -0
- data/ext/libcouchbase/tests/iotests/iotests.h +15 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +524 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +385 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.cc +67 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.h +61 -0
- data/ext/libcouchbase/tests/iotests/serverparams.h +76 -0
- data/ext/libcouchbase/tests/iotests/t_arithmetic.cc +143 -0
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +226 -0
- data/ext/libcouchbase/tests/iotests/t_configcache.cc +117 -0
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +241 -0
- data/ext/libcouchbase/tests/iotests/t_durability.cc +1059 -0
- data/ext/libcouchbase/tests/iotests/t_forward.cc +110 -0
- data/ext/libcouchbase/tests/iotests/t_get.cc +512 -0
- data/ext/libcouchbase/tests/iotests/t_http.cc +438 -0
- data/ext/libcouchbase/tests/iotests/t_iops.cc +175 -0
- data/ext/libcouchbase/tests/iotests/t_lock.cc +275 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +713 -0
- data/ext/libcouchbase/tests/iotests/t_mutate.cc +609 -0
- data/ext/libcouchbase/tests/iotests/t_n1ql.cc +270 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +654 -0
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +157 -0
- data/ext/libcouchbase/tests/iotests/t_regression.cc +321 -0
- data/ext/libcouchbase/tests/iotests/t_sched.cc +88 -0
- data/ext/libcouchbase/tests/iotests/t_serverops.cc +230 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +528 -0
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +822 -0
- data/ext/libcouchbase/tests/iotests/t_syncmode.cc +64 -0
- data/ext/libcouchbase/tests/iotests/t_views.cc +405 -0
- data/ext/libcouchbase/tests/iotests/testutil.cc +250 -0
- data/ext/libcouchbase/tests/iotests/testutil.h +163 -0
- data/ext/libcouchbase/tests/mc/mctest.h +119 -0
- data/ext/libcouchbase/tests/mc/pktmaker.h +101 -0
- data/ext/libcouchbase/tests/mc/t_alloc.cc +269 -0
- data/ext/libcouchbase/tests/mc/t_context.cc +100 -0
- data/ext/libcouchbase/tests/mc/t_flush.cc +185 -0
- data/ext/libcouchbase/tests/mc/t_forward.cc +239 -0
- data/ext/libcouchbase/tests/mc/t_ioflush.cc +102 -0
- data/ext/libcouchbase/tests/mc/t_iovcursor.cc +173 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.c +305 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.h +89 -0
- data/ext/libcouchbase/tests/mocksupport/server.c +391 -0
- data/ext/libcouchbase/tests/mocksupport/server.h +72 -0
- data/ext/libcouchbase/tests/mocksupport/timeout.c +69 -0
- data/ext/libcouchbase/tests/nonio_tests.cc +23 -0
- data/ext/libcouchbase/tests/rdb/rdbtest.h +133 -0
- data/ext/libcouchbase/tests/rdb/t_basic.cc +128 -0
- data/ext/libcouchbase/tests/rdb/t_bigalloc.cc +93 -0
- data/ext/libcouchbase/tests/rdb/t_refs.cc +112 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +347 -0
- data/ext/libcouchbase/tests/socktests/socktest.h +448 -0
- data/ext/libcouchbase/tests/socktests/t_basic.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ctx.cc +73 -0
- data/ext/libcouchbase/tests/socktests/t_manager.cc +179 -0
- data/ext/libcouchbase/tests/socktests/t_putex.cc +256 -0
- data/ext/libcouchbase/tests/socktests/t_read.cc +187 -0
- data/ext/libcouchbase/tests/socktests/t_reentrant.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +80 -0
- data/ext/libcouchbase/tests/socktests/t_write.cc +95 -0
- data/ext/libcouchbase/tests/start_mock.bat +15 -0
- data/ext/libcouchbase/tests/start_mock.sh +42 -0
- data/ext/libcouchbase/tests/unit_tests.cc +43 -0
- data/ext/libcouchbase/tests/vbucket/confdata/bad.json +101 -0
- data/ext/libcouchbase/tests/vbucket/confdata/full_25.json +363 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_25.json +90 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_45.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_25.json +291 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +341 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +51 -0
- data/ext/libcouchbase/tools/cbc-handlers.h +462 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +439 -0
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +822 -0
- data/ext/libcouchbase/tools/cbc.cc +1541 -0
- data/ext/libcouchbase/tools/common/histogram.cc +43 -0
- data/ext/libcouchbase/tools/common/histogram.h +23 -0
- data/ext/libcouchbase/tools/common/my_inttypes.h +22 -0
- data/ext/libcouchbase/tools/common/options.cc +420 -0
- data/ext/libcouchbase/tools/common/options.h +81 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +469 -0
- data/ext/libcouchbase/tools/docgen/loc.h +210 -0
- data/ext/libcouchbase/tools/docgen/placeholders.h +211 -0
- data/ext/libcouchbase/tools/docgen/seqgen.h +94 -0
- data/lib/libcouchbase.rb +36 -0
- data/lib/libcouchbase/bucket.rb +819 -0
- data/lib/libcouchbase/callbacks.rb +72 -0
- data/lib/libcouchbase/connection.rb +790 -0
- data/lib/libcouchbase/design_docs.rb +86 -0
- data/lib/libcouchbase/error.rb +68 -0
- data/lib/libcouchbase/ext/libcouchbase.rb +1135 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdbase.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdcounter.rb +36 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdendure.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdfts.rb +24 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdget.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdgetreplica.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdhttp.rb +58 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdn1ql.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobseqno.rb +33 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobserve.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstore.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstoredur.rb +45 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdverbosity.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdviewquery.rb +61 -0
- data/lib/libcouchbase/ext/libcouchbase/contigbuf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st.rb +15 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st0.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st1.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st2.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st3.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/crst_u.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_st_v.rb +11 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_t.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/durabilityopt_sv0.rb +63 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +991 -0
- data/lib/libcouchbase/ext/libcouchbase/fragbuf.rb +18 -0
- data/lib/libcouchbase/ext/libcouchbase/ftshandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/histogram.rb +34 -0
- data/lib/libcouchbase/ext/libcouchbase/http_request_t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/keybuf.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/multicmd_ctx.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/mutation_token.rb +17 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlparams.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/respbase.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/respcounter.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respendure.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/respfts.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/respget.rb +44 -0
- data/lib/libcouchbase/ext/libcouchbase/resphttp.rb +48 -0
- data/lib/libcouchbase/ext/libcouchbase/respmcversion.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respn1ql.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respobseqno.rb +52 -0
- data/lib/libcouchbase/ext/libcouchbase/respobserve.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respserverbase.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstats.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respstore.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstoredur.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respsubdoc.rb +35 -0
- data/lib/libcouchbase/ext/libcouchbase/respviewquery.rb +67 -0
- data/lib/libcouchbase/ext/libcouchbase/sdentry.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf_u_buf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/viewhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase_iocp.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase_libuv.rb +18 -0
- data/lib/libcouchbase/ext/tasks.rb +87 -0
- data/lib/libcouchbase/n1ql.rb +73 -0
- data/lib/libcouchbase/query_full_text.rb +147 -0
- data/lib/libcouchbase/query_n1ql.rb +121 -0
- data/lib/libcouchbase/query_view.rb +129 -0
- data/lib/libcouchbase/results_fiber.rb +262 -0
- data/lib/libcouchbase/results_native.rb +211 -0
- data/lib/libcouchbase/version.rb +5 -0
- data/libcouchbase.gemspec +61 -0
- data/spec/bucket_spec.rb +270 -0
- data/spec/connection_spec.rb +277 -0
- data/spec/design_docs_spec.rb +23 -0
- data/spec/error_spec.rb +26 -0
- data/spec/fts_spec.rb +129 -0
- data/spec/n1ql_spec.rb +201 -0
- data/spec/results_libuv_spec.rb +229 -0
- data/spec/results_native_spec.rb +259 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/design.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/data-0000.cbb +0 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/failover.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/meta.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/seqno.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/snapshot_markers.json +1 -0
- data/spec/view_spec.rb +195 -0
- metadata +775 -0
@@ -0,0 +1,1961 @@
|
|
1
|
+
/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).
|
2
|
+
/// It is intended to be used with #include "lcb-jsoncpp.h"
|
3
|
+
|
4
|
+
// //////////////////////////////////////////////////////////////////////
|
5
|
+
// Beginning of content of file: LICENSE
|
6
|
+
// //////////////////////////////////////////////////////////////////////
|
7
|
+
|
8
|
+
/*
|
9
|
+
The JsonCpp library's source code, including accompanying documentation,
|
10
|
+
tests and demonstration applications, are licensed under the following
|
11
|
+
conditions...
|
12
|
+
|
13
|
+
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
14
|
+
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
15
|
+
this software is released into the Public Domain.
|
16
|
+
|
17
|
+
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
18
|
+
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
19
|
+
released under the terms of the MIT License (see below).
|
20
|
+
|
21
|
+
In jurisdictions which recognize Public Domain property, the user of this
|
22
|
+
software may choose to accept it either as 1) Public Domain, 2) under the
|
23
|
+
conditions of the MIT License (see below), or 3) under the terms of dual
|
24
|
+
Public Domain/MIT License conditions described here, as they choose.
|
25
|
+
|
26
|
+
The MIT License is about as close to Public Domain as a license can get, and is
|
27
|
+
described in clear, concise terms at:
|
28
|
+
|
29
|
+
http://en.wikipedia.org/wiki/MIT_License
|
30
|
+
|
31
|
+
The full text of the MIT License follows:
|
32
|
+
|
33
|
+
========================================================================
|
34
|
+
Copyright (c) 2007-2010 Baptiste Lepilleur
|
35
|
+
|
36
|
+
Permission is hereby granted, free of charge, to any person
|
37
|
+
obtaining a copy of this software and associated documentation
|
38
|
+
files (the "Software"), to deal in the Software without
|
39
|
+
restriction, including without limitation the rights to use, copy,
|
40
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies
|
41
|
+
of the Software, and to permit persons to whom the Software is
|
42
|
+
furnished to do so, subject to the following conditions:
|
43
|
+
|
44
|
+
The above copyright notice and this permission notice shall be
|
45
|
+
included in all copies or substantial portions of the Software.
|
46
|
+
|
47
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
48
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
49
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
50
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
51
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
52
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
53
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
54
|
+
SOFTWARE.
|
55
|
+
========================================================================
|
56
|
+
(END LICENSE TEXT)
|
57
|
+
|
58
|
+
The MIT license is compatible with both the GPL and commercial
|
59
|
+
software, affording one all of the rights of Public Domain with the
|
60
|
+
minor nuisance of being required to keep the above copyright notice
|
61
|
+
and license text in the source code. Note also that by accepting the
|
62
|
+
Public Domain "license" you can re-license your copy using whatever
|
63
|
+
license you like.
|
64
|
+
|
65
|
+
*/
|
66
|
+
|
67
|
+
// //////////////////////////////////////////////////////////////////////
|
68
|
+
// End of content of file: LICENSE
|
69
|
+
// //////////////////////////////////////////////////////////////////////
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
#ifndef JSON_AMALGATED_H_INCLUDED
|
76
|
+
# define JSON_AMALGATED_H_INCLUDED
|
77
|
+
/// If defined, indicates that the source file is amalgated
|
78
|
+
/// to prevent private header inclusion.
|
79
|
+
#define JSON_IS_AMALGAMATION
|
80
|
+
|
81
|
+
// //////////////////////////////////////////////////////////////////////
|
82
|
+
// Beginning of content of file: include/json/version.h
|
83
|
+
// //////////////////////////////////////////////////////////////////////
|
84
|
+
|
85
|
+
// DO NOT EDIT. This file (and "version") is generated by CMake.
|
86
|
+
// Run CMake configure step to update it.
|
87
|
+
#ifndef JSON_VERSION_H_INCLUDED
|
88
|
+
# define JSON_VERSION_H_INCLUDED
|
89
|
+
|
90
|
+
# define JSONCPP_VERSION_STRING "0.10.5"
|
91
|
+
# define JSONCPP_VERSION_MAJOR 0
|
92
|
+
# define JSONCPP_VERSION_MINOR 10
|
93
|
+
# define JSONCPP_VERSION_PATCH 5
|
94
|
+
# define JSONCPP_VERSION_QUALIFIER
|
95
|
+
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
96
|
+
|
97
|
+
#endif // JSON_VERSION_H_INCLUDED
|
98
|
+
|
99
|
+
// //////////////////////////////////////////////////////////////////////
|
100
|
+
// End of content of file: include/json/version.h
|
101
|
+
// //////////////////////////////////////////////////////////////////////
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
// //////////////////////////////////////////////////////////////////////
|
109
|
+
// Beginning of content of file: include/json/config.h
|
110
|
+
// //////////////////////////////////////////////////////////////////////
|
111
|
+
|
112
|
+
// Copyright 2007-2010 Baptiste Lepilleur
|
113
|
+
// Distributed under MIT license, or public domain if desired and
|
114
|
+
// recognized in your jurisdiction.
|
115
|
+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
116
|
+
|
117
|
+
#ifndef JSON_CONFIG_H_INCLUDED
|
118
|
+
#define JSON_CONFIG_H_INCLUDED
|
119
|
+
|
120
|
+
/// If defined, indicates that json library is embedded in CppTL library.
|
121
|
+
//# define JSON_IN_CPPTL 1
|
122
|
+
|
123
|
+
/// If defined, indicates that json may leverage CppTL library
|
124
|
+
//# define JSON_USE_CPPTL 1
|
125
|
+
/// If defined, indicates that cpptl vector based map should be used instead of
|
126
|
+
/// std::map
|
127
|
+
/// as Value container.
|
128
|
+
//# define JSON_USE_CPPTL_SMALLMAP 1
|
129
|
+
|
130
|
+
// If non-zero, the library uses exceptions to report bad input instead of C
|
131
|
+
// assertion macros. The default is to use exceptions.
|
132
|
+
#ifndef JSON_USE_EXCEPTION
|
133
|
+
#define JSON_USE_EXCEPTION 1
|
134
|
+
#endif
|
135
|
+
|
136
|
+
/// If defined, indicates that the source file is amalgated
|
137
|
+
/// to prevent private header inclusion.
|
138
|
+
/// Remarks: it is automatically defined in the generated amalgated header.
|
139
|
+
// #define JSON_IS_AMALGAMATION
|
140
|
+
|
141
|
+
#ifdef JSON_IN_CPPTL
|
142
|
+
#include <cpptl/config.h>
|
143
|
+
#ifndef JSON_USE_CPPTL
|
144
|
+
#define JSON_USE_CPPTL 1
|
145
|
+
#endif
|
146
|
+
#endif
|
147
|
+
|
148
|
+
#ifdef JSON_IN_CPPTL
|
149
|
+
#define JSON_API CPPTL_API
|
150
|
+
#elif defined(JSON_DLL_BUILD)
|
151
|
+
#if defined(_MSC_VER)
|
152
|
+
#define JSON_API __declspec(dllexport)
|
153
|
+
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
154
|
+
#endif // if defined(_MSC_VER)
|
155
|
+
#elif defined(JSON_DLL)
|
156
|
+
#if defined(_MSC_VER)
|
157
|
+
#define JSON_API __declspec(dllimport)
|
158
|
+
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
159
|
+
#endif // if defined(_MSC_VER)
|
160
|
+
#endif // ifdef JSON_IN_CPPTL
|
161
|
+
#if !defined(JSON_API)
|
162
|
+
#define JSON_API
|
163
|
+
#endif
|
164
|
+
|
165
|
+
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
166
|
+
// integer
|
167
|
+
// Storages, and 64 bits integer support is disabled.
|
168
|
+
// #define JSON_NO_INT64 1
|
169
|
+
|
170
|
+
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
|
171
|
+
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
172
|
+
// (no conversion from unsigned __int64).
|
173
|
+
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
174
|
+
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
175
|
+
// characters in the debug information)
|
176
|
+
// All projects I've ever seen with VS6 were using this globally (not bothering
|
177
|
+
// with pragma push/pop).
|
178
|
+
#pragma warning(disable : 4786)
|
179
|
+
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
|
180
|
+
|
181
|
+
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
|
182
|
+
/// Indicates that the following function is deprecated.
|
183
|
+
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
184
|
+
#elif defined(__clang__) && defined(__has_feature)
|
185
|
+
#if __has_feature(attribute_deprecated_with_message)
|
186
|
+
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
187
|
+
#endif
|
188
|
+
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
189
|
+
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
190
|
+
#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
191
|
+
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
192
|
+
#endif
|
193
|
+
|
194
|
+
#if !defined(JSONCPP_DEPRECATED)
|
195
|
+
#define JSONCPP_DEPRECATED(message)
|
196
|
+
#endif // if !defined(JSONCPP_DEPRECATED)
|
197
|
+
|
198
|
+
namespace Json {
|
199
|
+
typedef int Int;
|
200
|
+
typedef unsigned int UInt;
|
201
|
+
#if defined(JSON_NO_INT64)
|
202
|
+
typedef int LargestInt;
|
203
|
+
typedef unsigned int LargestUInt;
|
204
|
+
#undef JSON_HAS_INT64
|
205
|
+
#else // if defined(JSON_NO_INT64)
|
206
|
+
// For Microsoft Visual use specific types as long long is not supported
|
207
|
+
#if defined(_MSC_VER) // Microsoft Visual Studio
|
208
|
+
typedef __int64 Int64;
|
209
|
+
typedef unsigned __int64 UInt64;
|
210
|
+
#else // if defined(_MSC_VER) // Other platforms, use long long
|
211
|
+
typedef long long int Int64;
|
212
|
+
typedef unsigned long long int UInt64;
|
213
|
+
#endif // if defined(_MSC_VER)
|
214
|
+
typedef Int64 LargestInt;
|
215
|
+
typedef UInt64 LargestUInt;
|
216
|
+
#define JSON_HAS_INT64
|
217
|
+
#endif // if defined(JSON_NO_INT64)
|
218
|
+
} // end namespace Json
|
219
|
+
|
220
|
+
#endif // JSON_CONFIG_H_INCLUDED
|
221
|
+
|
222
|
+
// //////////////////////////////////////////////////////////////////////
|
223
|
+
// End of content of file: include/json/config.h
|
224
|
+
// //////////////////////////////////////////////////////////////////////
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
// //////////////////////////////////////////////////////////////////////
|
232
|
+
// Beginning of content of file: include/json/forwards.h
|
233
|
+
// //////////////////////////////////////////////////////////////////////
|
234
|
+
|
235
|
+
// Copyright 2007-2010 Baptiste Lepilleur
|
236
|
+
// Distributed under MIT license, or public domain if desired and
|
237
|
+
// recognized in your jurisdiction.
|
238
|
+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
239
|
+
|
240
|
+
#ifndef JSON_FORWARDS_H_INCLUDED
|
241
|
+
#define JSON_FORWARDS_H_INCLUDED
|
242
|
+
|
243
|
+
#if !defined(JSON_IS_AMALGAMATION)
|
244
|
+
#include "config.h"
|
245
|
+
#endif // if !defined(JSON_IS_AMALGAMATION)
|
246
|
+
|
247
|
+
namespace Json {
|
248
|
+
|
249
|
+
// writer.h
|
250
|
+
class FastWriter;
|
251
|
+
class StyledWriter;
|
252
|
+
|
253
|
+
// reader.h
|
254
|
+
class Reader;
|
255
|
+
|
256
|
+
// features.h
|
257
|
+
class Features;
|
258
|
+
|
259
|
+
// value.h
|
260
|
+
typedef unsigned int ArrayIndex;
|
261
|
+
class StaticString;
|
262
|
+
class Path;
|
263
|
+
class PathArgument;
|
264
|
+
class Value;
|
265
|
+
class ValueIteratorBase;
|
266
|
+
class ValueIterator;
|
267
|
+
class ValueConstIterator;
|
268
|
+
|
269
|
+
} // namespace Json
|
270
|
+
|
271
|
+
#endif // JSON_FORWARDS_H_INCLUDED
|
272
|
+
|
273
|
+
// //////////////////////////////////////////////////////////////////////
|
274
|
+
// End of content of file: include/json/forwards.h
|
275
|
+
// //////////////////////////////////////////////////////////////////////
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
// //////////////////////////////////////////////////////////////////////
|
283
|
+
// Beginning of content of file: include/json/features.h
|
284
|
+
// //////////////////////////////////////////////////////////////////////
|
285
|
+
|
286
|
+
// Copyright 2007-2010 Baptiste Lepilleur
|
287
|
+
// Distributed under MIT license, or public domain if desired and
|
288
|
+
// recognized in your jurisdiction.
|
289
|
+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
290
|
+
|
291
|
+
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
|
292
|
+
#define CPPTL_JSON_FEATURES_H_INCLUDED
|
293
|
+
|
294
|
+
#if !defined(JSON_IS_AMALGAMATION)
|
295
|
+
#include "forwards.h"
|
296
|
+
#endif // if !defined(JSON_IS_AMALGAMATION)
|
297
|
+
|
298
|
+
namespace Json {
|
299
|
+
|
300
|
+
/** \brief Configuration passed to reader and writer.
|
301
|
+
* This configuration object can be used to force the Reader or Writer
|
302
|
+
* to behave in a standard conforming way.
|
303
|
+
*/
|
304
|
+
class JSON_API Features {
|
305
|
+
public:
|
306
|
+
/** \brief A configuration that allows all features and assumes all strings
|
307
|
+
* are UTF-8.
|
308
|
+
* - C & C++ comments are allowed
|
309
|
+
* - Root object can be any JSON value
|
310
|
+
* - Assumes Value strings are encoded in UTF-8
|
311
|
+
*/
|
312
|
+
static Features all();
|
313
|
+
|
314
|
+
/** \brief A configuration that is strictly compatible with the JSON
|
315
|
+
* specification.
|
316
|
+
* - Comments are forbidden.
|
317
|
+
* - Root object must be either an array or an object value.
|
318
|
+
* - Assumes Value strings are encoded in UTF-8
|
319
|
+
*/
|
320
|
+
static Features strictMode();
|
321
|
+
|
322
|
+
/** \brief Initialize the configuration like JsonConfig::allFeatures;
|
323
|
+
*/
|
324
|
+
Features();
|
325
|
+
|
326
|
+
/// \c true if comments are allowed. Default: \c true.
|
327
|
+
bool allowComments_;
|
328
|
+
|
329
|
+
/// \c true if root must be either an array or an object value. Default: \c
|
330
|
+
/// false.
|
331
|
+
bool strictRoot_;
|
332
|
+
};
|
333
|
+
|
334
|
+
} // namespace Json
|
335
|
+
|
336
|
+
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
|
337
|
+
|
338
|
+
// //////////////////////////////////////////////////////////////////////
|
339
|
+
// End of content of file: include/json/features.h
|
340
|
+
// //////////////////////////////////////////////////////////////////////
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
// //////////////////////////////////////////////////////////////////////
|
348
|
+
// Beginning of content of file: include/json/value.h
|
349
|
+
// //////////////////////////////////////////////////////////////////////
|
350
|
+
|
351
|
+
// Copyright 2007-2010 Baptiste Lepilleur
|
352
|
+
// Distributed under MIT license, or public domain if desired and
|
353
|
+
// recognized in your jurisdiction.
|
354
|
+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
355
|
+
|
356
|
+
#ifndef CPPTL_JSON_H_INCLUDED
|
357
|
+
#define CPPTL_JSON_H_INCLUDED
|
358
|
+
|
359
|
+
#if !defined(JSON_IS_AMALGAMATION)
|
360
|
+
#include "forwards.h"
|
361
|
+
#endif // if !defined(JSON_IS_AMALGAMATION)
|
362
|
+
#include <string>
|
363
|
+
#include <vector>
|
364
|
+
#include <exception>
|
365
|
+
|
366
|
+
#ifndef JSON_USE_CPPTL_SMALLMAP
|
367
|
+
#include <map>
|
368
|
+
#else
|
369
|
+
#include <cpptl/smallmap.h>
|
370
|
+
#endif
|
371
|
+
#ifdef JSON_USE_CPPTL
|
372
|
+
#include <cpptl/forwards.h>
|
373
|
+
#endif
|
374
|
+
|
375
|
+
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
376
|
+
// be used by...
|
377
|
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
378
|
+
#pragma warning(push)
|
379
|
+
#pragma warning(disable : 4251)
|
380
|
+
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
381
|
+
|
382
|
+
/** \brief JSON (JavaScript Object Notation).
|
383
|
+
*/
|
384
|
+
namespace Json {
|
385
|
+
|
386
|
+
/** Base class for all exceptions we throw.
|
387
|
+
*
|
388
|
+
* We use nothing but these internally. Of course, STL can throw others.
|
389
|
+
*/
|
390
|
+
class JSON_API Exception : public std::exception {
|
391
|
+
public:
|
392
|
+
Exception(std::string const& msg);
|
393
|
+
virtual ~Exception() throw();
|
394
|
+
virtual char const* what() const throw();
|
395
|
+
protected:
|
396
|
+
std::string const msg_;
|
397
|
+
};
|
398
|
+
|
399
|
+
/** Exceptions which the user cannot easily avoid.
|
400
|
+
*
|
401
|
+
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
402
|
+
*
|
403
|
+
* \remark derived from Json::Exception
|
404
|
+
*/
|
405
|
+
class JSON_API RuntimeError : public Exception {
|
406
|
+
public:
|
407
|
+
RuntimeError(std::string const& msg);
|
408
|
+
};
|
409
|
+
|
410
|
+
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
411
|
+
*
|
412
|
+
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
413
|
+
*
|
414
|
+
* \remark derived from Json::Exception
|
415
|
+
*/
|
416
|
+
class JSON_API LogicError : public Exception {
|
417
|
+
public:
|
418
|
+
LogicError(std::string const& msg);
|
419
|
+
};
|
420
|
+
|
421
|
+
/// used internally
|
422
|
+
void throwRuntimeError(std::string const& msg);
|
423
|
+
/// used internally
|
424
|
+
void throwLogicError(std::string const& msg);
|
425
|
+
|
426
|
+
/** \brief Type of the value held by a Value object.
|
427
|
+
*/
|
428
|
+
enum ValueType {
|
429
|
+
nullValue = 0, ///< 'null' value
|
430
|
+
intValue, ///< signed integer value
|
431
|
+
uintValue, ///< unsigned integer value
|
432
|
+
realValue, ///< double value
|
433
|
+
stringValue, ///< UTF-8 string value
|
434
|
+
booleanValue, ///< bool value
|
435
|
+
arrayValue, ///< array value (ordered list)
|
436
|
+
objectValue ///< object value (collection of name/value pairs).
|
437
|
+
};
|
438
|
+
|
439
|
+
enum CommentPlacement {
|
440
|
+
commentBefore = 0, ///< a comment placed on the line before a value
|
441
|
+
commentAfterOnSameLine, ///< a comment just after a value on the same line
|
442
|
+
commentAfter, ///< a comment on the line after a value (only make sense for
|
443
|
+
/// root value)
|
444
|
+
numberOfCommentPlacement
|
445
|
+
};
|
446
|
+
|
447
|
+
//# ifdef JSON_USE_CPPTL
|
448
|
+
// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
|
449
|
+
// typedef CppTL::AnyEnumerator<const Value &> EnumValues;
|
450
|
+
//# endif
|
451
|
+
|
452
|
+
/** \brief Lightweight wrapper to tag static string.
|
453
|
+
*
|
454
|
+
* Value constructor and objectValue member assignement takes advantage of the
|
455
|
+
* StaticString and avoid the cost of string duplication when storing the
|
456
|
+
* string or the member name.
|
457
|
+
*
|
458
|
+
* Example of usage:
|
459
|
+
* \code
|
460
|
+
* Json::Value aValue( StaticString("some text") );
|
461
|
+
* Json::Value object;
|
462
|
+
* static const StaticString code("code");
|
463
|
+
* object[code] = 1234;
|
464
|
+
* \endcode
|
465
|
+
*/
|
466
|
+
class JSON_API StaticString {
|
467
|
+
public:
|
468
|
+
explicit StaticString(const char* czstring) : c_str_(czstring) {}
|
469
|
+
|
470
|
+
operator const char*() const { return c_str_; }
|
471
|
+
|
472
|
+
const char* c_str() const { return c_str_; }
|
473
|
+
|
474
|
+
private:
|
475
|
+
const char* c_str_;
|
476
|
+
};
|
477
|
+
|
478
|
+
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
|
479
|
+
*
|
480
|
+
* This class is a discriminated union wrapper that can represents a:
|
481
|
+
* - signed integer [range: Value::minInt - Value::maxInt]
|
482
|
+
* - unsigned integer (range: 0 - Value::maxUInt)
|
483
|
+
* - double
|
484
|
+
* - UTF-8 string
|
485
|
+
* - boolean
|
486
|
+
* - 'null'
|
487
|
+
* - an ordered list of Value
|
488
|
+
* - collection of name/value pairs (javascript object)
|
489
|
+
*
|
490
|
+
* The type of the held value is represented by a #ValueType and
|
491
|
+
* can be obtained using type().
|
492
|
+
*
|
493
|
+
* Values of an #objectValue or #arrayValue can be accessed using operator[]()
|
494
|
+
* methods.
|
495
|
+
* Non-const methods will automatically create the a #nullValue element
|
496
|
+
* if it does not exist.
|
497
|
+
* The sequence of an #arrayValue will be automatically resized and initialized
|
498
|
+
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
|
499
|
+
*
|
500
|
+
* The get() methods can be used to obtain default value in the case the
|
501
|
+
* required element does not exist.
|
502
|
+
*
|
503
|
+
* It is possible to iterate over the list of a #objectValue values using
|
504
|
+
* the getMemberNames() method.
|
505
|
+
*
|
506
|
+
* \note #Value string-length fit in size_t, but keys must be < 2^30.
|
507
|
+
* (The reason is an implementation detail.) A #CharReader will raise an
|
508
|
+
* exception if a bound is exceeded to avoid security holes in your app,
|
509
|
+
* but the Value API does *not* check bounds. That is the responsibility
|
510
|
+
* of the caller.
|
511
|
+
*/
|
512
|
+
class JSON_API Value {
|
513
|
+
friend class ValueIteratorBase;
|
514
|
+
public:
|
515
|
+
typedef std::vector<std::string> Members;
|
516
|
+
typedef ValueIterator iterator;
|
517
|
+
typedef ValueConstIterator const_iterator;
|
518
|
+
typedef Json::UInt UInt;
|
519
|
+
typedef Json::Int Int;
|
520
|
+
#if defined(JSON_HAS_INT64)
|
521
|
+
typedef Json::UInt64 UInt64;
|
522
|
+
typedef Json::Int64 Int64;
|
523
|
+
#endif // defined(JSON_HAS_INT64)
|
524
|
+
typedef Json::LargestInt LargestInt;
|
525
|
+
typedef Json::LargestUInt LargestUInt;
|
526
|
+
typedef Json::ArrayIndex ArrayIndex;
|
527
|
+
|
528
|
+
static const Value& nullRef;
|
529
|
+
#if !defined(__ARMEL__)
|
530
|
+
/// \deprecated This exists for binary compatibility only. Use nullRef.
|
531
|
+
static const Value null;
|
532
|
+
#endif
|
533
|
+
/// Minimum signed integer value that can be stored in a Json::Value.
|
534
|
+
static const LargestInt minLargestInt;
|
535
|
+
/// Maximum signed integer value that can be stored in a Json::Value.
|
536
|
+
static const LargestInt maxLargestInt;
|
537
|
+
/// Maximum unsigned integer value that can be stored in a Json::Value.
|
538
|
+
static const LargestUInt maxLargestUInt;
|
539
|
+
|
540
|
+
/// Minimum signed int value that can be stored in a Json::Value.
|
541
|
+
static const Int minInt;
|
542
|
+
/// Maximum signed int value that can be stored in a Json::Value.
|
543
|
+
static const Int maxInt;
|
544
|
+
/// Maximum unsigned int value that can be stored in a Json::Value.
|
545
|
+
static const UInt maxUInt;
|
546
|
+
|
547
|
+
#if defined(JSON_HAS_INT64)
|
548
|
+
/// Minimum signed 64 bits int value that can be stored in a Json::Value.
|
549
|
+
static const Int64 minInt64;
|
550
|
+
/// Maximum signed 64 bits int value that can be stored in a Json::Value.
|
551
|
+
static const Int64 maxInt64;
|
552
|
+
/// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
|
553
|
+
static const UInt64 maxUInt64;
|
554
|
+
#endif // defined(JSON_HAS_INT64)
|
555
|
+
|
556
|
+
private:
|
557
|
+
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
558
|
+
class CZString {
|
559
|
+
public:
|
560
|
+
enum DuplicationPolicy {
|
561
|
+
noDuplication = 0,
|
562
|
+
duplicate,
|
563
|
+
duplicateOnCopy
|
564
|
+
};
|
565
|
+
CZString(ArrayIndex index);
|
566
|
+
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
567
|
+
CZString(CZString const& other);
|
568
|
+
~CZString();
|
569
|
+
CZString& operator=(CZString other);
|
570
|
+
bool operator<(CZString const& other) const;
|
571
|
+
bool operator==(CZString const& other) const;
|
572
|
+
ArrayIndex index() const;
|
573
|
+
//const char* c_str() const; ///< \deprecated
|
574
|
+
char const* data() const;
|
575
|
+
unsigned length() const;
|
576
|
+
bool isStaticString() const;
|
577
|
+
|
578
|
+
private:
|
579
|
+
void swap(CZString& other);
|
580
|
+
|
581
|
+
struct StringStorage {
|
582
|
+
unsigned policy_: 2;
|
583
|
+
unsigned length_: 30; // 1GB max
|
584
|
+
};
|
585
|
+
|
586
|
+
char const* cstr_; // actually, a prefixed string, unless policy is noDup
|
587
|
+
union {
|
588
|
+
ArrayIndex index_;
|
589
|
+
StringStorage storage_;
|
590
|
+
};
|
591
|
+
};
|
592
|
+
|
593
|
+
public:
|
594
|
+
#ifndef JSON_USE_CPPTL_SMALLMAP
|
595
|
+
typedef std::map<CZString, Value> ObjectValues;
|
596
|
+
#else
|
597
|
+
typedef CppTL::SmallMap<CZString, Value> ObjectValues;
|
598
|
+
#endif // ifndef JSON_USE_CPPTL_SMALLMAP
|
599
|
+
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
600
|
+
|
601
|
+
public:
|
602
|
+
/** \brief Create a default Value of the given type.
|
603
|
+
|
604
|
+
This is a very useful constructor.
|
605
|
+
To create an empty array, pass arrayValue.
|
606
|
+
To create an empty object, pass objectValue.
|
607
|
+
Another Value can then be set to this one by assignment.
|
608
|
+
This is useful since clear() and resize() will not alter types.
|
609
|
+
|
610
|
+
Examples:
|
611
|
+
\code
|
612
|
+
Json::Value null_value; // null
|
613
|
+
Json::Value arr_value(Json::arrayValue); // []
|
614
|
+
Json::Value obj_value(Json::objectValue); // {}
|
615
|
+
\endcode
|
616
|
+
*/
|
617
|
+
Value(ValueType type = nullValue);
|
618
|
+
Value(Int value);
|
619
|
+
Value(UInt value);
|
620
|
+
#if defined(JSON_HAS_INT64)
|
621
|
+
Value(Int64 value);
|
622
|
+
Value(UInt64 value);
|
623
|
+
#endif // if defined(JSON_HAS_INT64)
|
624
|
+
Value(double value);
|
625
|
+
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
|
626
|
+
Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
|
627
|
+
/** \brief Constructs a value from a static string.
|
628
|
+
|
629
|
+
* Like other value string constructor but do not duplicate the string for
|
630
|
+
* internal storage. The given string must remain alive after the call to this
|
631
|
+
* constructor.
|
632
|
+
* \note This works only for null-terminated strings. (We cannot change the
|
633
|
+
* size of this class, so we have nowhere to store the length,
|
634
|
+
* which might be computed later for various operations.)
|
635
|
+
*
|
636
|
+
* Example of usage:
|
637
|
+
* \code
|
638
|
+
* static StaticString foo("some text");
|
639
|
+
* Json::Value aValue(foo);
|
640
|
+
* \endcode
|
641
|
+
*/
|
642
|
+
Value(const StaticString& value);
|
643
|
+
Value(const std::string& value); ///< Copy data() til size(). Embedded zeroes too.
|
644
|
+
#ifdef JSON_USE_CPPTL
|
645
|
+
Value(const CppTL::ConstString& value);
|
646
|
+
#endif
|
647
|
+
Value(bool value);
|
648
|
+
/// Deep copy.
|
649
|
+
Value(const Value& other);
|
650
|
+
~Value();
|
651
|
+
|
652
|
+
/// Deep copy, then swap(other).
|
653
|
+
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
|
654
|
+
Value &operator=(const Value &other);
|
655
|
+
/// Swap everything.
|
656
|
+
void swap(Value& other);
|
657
|
+
/// Swap values but leave comments and source offsets in place.
|
658
|
+
void swapPayload(Value& other);
|
659
|
+
|
660
|
+
ValueType type() const;
|
661
|
+
|
662
|
+
/// Compare payload only, not comments etc.
|
663
|
+
bool operator<(const Value& other) const;
|
664
|
+
bool operator<=(const Value& other) const;
|
665
|
+
bool operator>=(const Value& other) const;
|
666
|
+
bool operator>(const Value& other) const;
|
667
|
+
bool operator==(const Value& other) const;
|
668
|
+
bool operator!=(const Value& other) const;
|
669
|
+
int compare(const Value& other) const;
|
670
|
+
|
671
|
+
const char* asCString() const; ///< Embedded zeroes could cause you trouble!
|
672
|
+
std::string asString() const; ///< Embedded zeroes are possible.
|
673
|
+
/** Get raw char* of string-value.
|
674
|
+
* \return false if !string. (Seg-fault if str or end are NULL.)
|
675
|
+
*/
|
676
|
+
bool getString(
|
677
|
+
char const** begin, char const** end) const;
|
678
|
+
#ifdef JSON_USE_CPPTL
|
679
|
+
CppTL::ConstString asConstString() const;
|
680
|
+
#endif
|
681
|
+
Int asInt() const;
|
682
|
+
UInt asUInt() const;
|
683
|
+
#if defined(JSON_HAS_INT64)
|
684
|
+
Int64 asInt64() const;
|
685
|
+
UInt64 asUInt64() const;
|
686
|
+
#endif // if defined(JSON_HAS_INT64)
|
687
|
+
LargestInt asLargestInt() const;
|
688
|
+
LargestUInt asLargestUInt() const;
|
689
|
+
float asFloat() const;
|
690
|
+
double asDouble() const;
|
691
|
+
bool asBool() const;
|
692
|
+
|
693
|
+
bool isNull() const;
|
694
|
+
bool isBool() const;
|
695
|
+
bool isInt() const;
|
696
|
+
bool isInt64() const;
|
697
|
+
bool isUInt() const;
|
698
|
+
bool isUInt64() const;
|
699
|
+
bool isIntegral() const;
|
700
|
+
bool isDouble() const;
|
701
|
+
bool isNumeric() const;
|
702
|
+
bool isString() const;
|
703
|
+
bool isArray() const;
|
704
|
+
bool isObject() const;
|
705
|
+
|
706
|
+
bool isConvertibleTo(ValueType other) const;
|
707
|
+
|
708
|
+
/// Number of values in array or object
|
709
|
+
ArrayIndex size() const;
|
710
|
+
|
711
|
+
/// \brief Return true if empty array, empty object, or null;
|
712
|
+
/// otherwise, false.
|
713
|
+
bool empty() const;
|
714
|
+
|
715
|
+
/// Return isNull()
|
716
|
+
bool operator!() const;
|
717
|
+
|
718
|
+
/// Remove all object members and array elements.
|
719
|
+
/// \pre type() is arrayValue, objectValue, or nullValue
|
720
|
+
/// \post type() is unchanged
|
721
|
+
void clear();
|
722
|
+
|
723
|
+
/// Resize the array to size elements.
|
724
|
+
/// New elements are initialized to null.
|
725
|
+
/// May only be called on nullValue or arrayValue.
|
726
|
+
/// \pre type() is arrayValue or nullValue
|
727
|
+
/// \post type() is arrayValue
|
728
|
+
void resize(ArrayIndex size);
|
729
|
+
|
730
|
+
/// Access an array element (zero based index ).
|
731
|
+
/// If the array contains less than index element, then null value are
|
732
|
+
/// inserted
|
733
|
+
/// in the array so that its size is index+1.
|
734
|
+
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
735
|
+
/// this from the operator[] which takes a string.)
|
736
|
+
Value& operator[](ArrayIndex index);
|
737
|
+
|
738
|
+
/// Access an array element (zero based index ).
|
739
|
+
/// If the array contains less than index element, then null value are
|
740
|
+
/// inserted
|
741
|
+
/// in the array so that its size is index+1.
|
742
|
+
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
743
|
+
/// this from the operator[] which takes a string.)
|
744
|
+
Value& operator[](int index);
|
745
|
+
|
746
|
+
/// Access an array element (zero based index )
|
747
|
+
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
748
|
+
/// this from the operator[] which takes a string.)
|
749
|
+
const Value& operator[](ArrayIndex index) const;
|
750
|
+
|
751
|
+
/// Access an array element (zero based index )
|
752
|
+
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
753
|
+
/// this from the operator[] which takes a string.)
|
754
|
+
const Value& operator[](int index) const;
|
755
|
+
|
756
|
+
/// If the array contains at least index+1 elements, returns the element
|
757
|
+
/// value,
|
758
|
+
/// otherwise returns defaultValue.
|
759
|
+
Value get(ArrayIndex index, const Value& defaultValue) const;
|
760
|
+
/// Return true if index < size().
|
761
|
+
bool isValidIndex(ArrayIndex index) const;
|
762
|
+
/// \brief Append value to array at the end.
|
763
|
+
///
|
764
|
+
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
|
765
|
+
Value& append(const Value& value);
|
766
|
+
|
767
|
+
/// Access an object value by name, create a null member if it does not exist.
|
768
|
+
/// \note Because of our implementation, keys are limited to 2^30 -1 chars.
|
769
|
+
/// Exceeding that will cause an exception.
|
770
|
+
Value& operator[](const char* key);
|
771
|
+
/// Access an object value by name, returns null if there is no member with
|
772
|
+
/// that name.
|
773
|
+
const Value& operator[](const char* key) const;
|
774
|
+
/// Access an object value by name, create a null member if it does not exist.
|
775
|
+
/// \param key may contain embedded nulls.
|
776
|
+
Value& operator[](const std::string& key);
|
777
|
+
/// Access an object value by name, returns null if there is no member with
|
778
|
+
/// that name.
|
779
|
+
/// \param key may contain embedded nulls.
|
780
|
+
const Value& operator[](const std::string& key) const;
|
781
|
+
/** \brief Access an object value by name, create a null member if it does not
|
782
|
+
exist.
|
783
|
+
|
784
|
+
* If the object has no entry for that name, then the member name used to store
|
785
|
+
* the new entry is not duplicated.
|
786
|
+
* Example of use:
|
787
|
+
* \code
|
788
|
+
* Json::Value object;
|
789
|
+
* static const StaticString code("code");
|
790
|
+
* object[code] = 1234;
|
791
|
+
* \endcode
|
792
|
+
*/
|
793
|
+
Value& operator[](const StaticString& key);
|
794
|
+
#ifdef JSON_USE_CPPTL
|
795
|
+
/// Access an object value by name, create a null member if it does not exist.
|
796
|
+
Value& operator[](const CppTL::ConstString& key);
|
797
|
+
/// Access an object value by name, returns null if there is no member with
|
798
|
+
/// that name.
|
799
|
+
const Value& operator[](const CppTL::ConstString& key) const;
|
800
|
+
#endif
|
801
|
+
/// Return the member named key if it exist, defaultValue otherwise.
|
802
|
+
/// \note deep copy
|
803
|
+
Value get(const char* key, const Value& defaultValue) const;
|
804
|
+
/// Return the member named key if it exist, defaultValue otherwise.
|
805
|
+
/// \note deep copy
|
806
|
+
/// \note key may contain embedded nulls.
|
807
|
+
Value get(const char* begin, const char* end, const Value& defaultValue) const;
|
808
|
+
/// Return the member named key if it exist, defaultValue otherwise.
|
809
|
+
/// \note deep copy
|
810
|
+
/// \param key may contain embedded nulls.
|
811
|
+
Value get(const std::string& key, const Value& defaultValue) const;
|
812
|
+
#ifdef JSON_USE_CPPTL
|
813
|
+
/// Return the member named key if it exist, defaultValue otherwise.
|
814
|
+
/// \note deep copy
|
815
|
+
Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
|
816
|
+
#endif
|
817
|
+
/// Most general and efficient version of isMember()const, get()const,
|
818
|
+
/// and operator[]const
|
819
|
+
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
820
|
+
Value const* find(char const* begin, char const* end) const;
|
821
|
+
/// Most general and efficient version of object-mutators.
|
822
|
+
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
823
|
+
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
|
824
|
+
Value const* demand(char const* begin, char const* end);
|
825
|
+
/// \brief Remove and return the named member.
|
826
|
+
///
|
827
|
+
/// Do nothing if it did not exist.
|
828
|
+
/// \return the removed Value, or null.
|
829
|
+
/// \pre type() is objectValue or nullValue
|
830
|
+
/// \post type() is unchanged
|
831
|
+
/// \deprecated
|
832
|
+
Value removeMember(const char* key);
|
833
|
+
/// Same as removeMember(const char*)
|
834
|
+
/// \param key may contain embedded nulls.
|
835
|
+
/// \deprecated
|
836
|
+
Value removeMember(const std::string& key);
|
837
|
+
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
838
|
+
/// but 'key' is null-terminated.
|
839
|
+
bool removeMember(const char* key, Value* removed);
|
840
|
+
/** \brief Remove the named map member.
|
841
|
+
|
842
|
+
Update 'removed' iff removed.
|
843
|
+
\param key may contain embedded nulls.
|
844
|
+
\return true iff removed (no exceptions)
|
845
|
+
*/
|
846
|
+
bool removeMember(std::string const& key, Value* removed);
|
847
|
+
/// Same as removeMember(std::string const& key, Value* removed)
|
848
|
+
bool removeMember(const char* begin, const char* end, Value* removed);
|
849
|
+
/** \brief Remove the indexed array element.
|
850
|
+
|
851
|
+
O(n) expensive operations.
|
852
|
+
Update 'removed' iff removed.
|
853
|
+
\return true iff removed (no exceptions)
|
854
|
+
*/
|
855
|
+
bool removeIndex(ArrayIndex i, Value* removed);
|
856
|
+
|
857
|
+
/// Return true if the object has a member named key.
|
858
|
+
/// \note 'key' must be null-terminated.
|
859
|
+
bool isMember(const char* key) const;
|
860
|
+
/// Return true if the object has a member named key.
|
861
|
+
/// \param key may contain embedded nulls.
|
862
|
+
bool isMember(const std::string& key) const;
|
863
|
+
/// Same as isMember(std::string const& key)const
|
864
|
+
bool isMember(const char* begin, const char* end) const;
|
865
|
+
#ifdef JSON_USE_CPPTL
|
866
|
+
/// Return true if the object has a member named key.
|
867
|
+
bool isMember(const CppTL::ConstString& key) const;
|
868
|
+
#endif
|
869
|
+
|
870
|
+
/// \brief Return a list of the member names.
|
871
|
+
///
|
872
|
+
/// If null, return an empty list.
|
873
|
+
/// \pre type() is objectValue or nullValue
|
874
|
+
/// \post if type() was nullValue, it remains nullValue
|
875
|
+
Members getMemberNames() const;
|
876
|
+
|
877
|
+
//# ifdef JSON_USE_CPPTL
|
878
|
+
// EnumMemberNames enumMemberNames() const;
|
879
|
+
// EnumValues enumValues() const;
|
880
|
+
//# endif
|
881
|
+
|
882
|
+
/// \deprecated Always pass len.
|
883
|
+
JSONCPP_DEPRECATED("Use setComment(std::string const&) instead.")
|
884
|
+
void setComment(const char* comment, CommentPlacement placement);
|
885
|
+
/// Comments must be //... or /* ... */
|
886
|
+
void setComment(const char* comment, size_t len, CommentPlacement placement);
|
887
|
+
/// Comments must be //... or /* ... */
|
888
|
+
void setComment(const std::string& comment, CommentPlacement placement);
|
889
|
+
bool hasComment(CommentPlacement placement) const;
|
890
|
+
/// Include delimiters and embedded newlines.
|
891
|
+
std::string getComment(CommentPlacement placement) const;
|
892
|
+
|
893
|
+
std::string toStyledString() const;
|
894
|
+
|
895
|
+
const_iterator begin() const;
|
896
|
+
const_iterator end() const;
|
897
|
+
|
898
|
+
iterator begin();
|
899
|
+
iterator end();
|
900
|
+
|
901
|
+
private:
|
902
|
+
void initBasic(ValueType type, bool allocated = false);
|
903
|
+
|
904
|
+
Value& resolveReference(const char* key);
|
905
|
+
Value& resolveReference(const char* key, const char* end);
|
906
|
+
|
907
|
+
struct CommentInfo {
|
908
|
+
CommentInfo();
|
909
|
+
~CommentInfo();
|
910
|
+
|
911
|
+
void setComment(const char* text, size_t len);
|
912
|
+
|
913
|
+
char* comment_;
|
914
|
+
};
|
915
|
+
|
916
|
+
// struct MemberNamesTransform
|
917
|
+
//{
|
918
|
+
// typedef const char *result_type;
|
919
|
+
// const char *operator()( const CZString &name ) const
|
920
|
+
// {
|
921
|
+
// return name.c_str();
|
922
|
+
// }
|
923
|
+
//};
|
924
|
+
|
925
|
+
union ValueHolder {
|
926
|
+
LargestInt int_;
|
927
|
+
LargestUInt uint_;
|
928
|
+
double real_;
|
929
|
+
bool bool_;
|
930
|
+
char* string_; // actually ptr to unsigned, followed by str, unless !allocated_
|
931
|
+
ObjectValues* map_;
|
932
|
+
} value_;
|
933
|
+
ValueType type_ : 8;
|
934
|
+
unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
|
935
|
+
// If not allocated_, string_ must be null-terminated.
|
936
|
+
CommentInfo* comments_;
|
937
|
+
};
|
938
|
+
|
939
|
+
/** \brief Experimental and untested: represents an element of the "path" to
|
940
|
+
* access a node.
|
941
|
+
*/
|
942
|
+
class JSON_API PathArgument {
|
943
|
+
public:
|
944
|
+
friend class Path;
|
945
|
+
|
946
|
+
PathArgument();
|
947
|
+
PathArgument(ArrayIndex index);
|
948
|
+
PathArgument(const char* key);
|
949
|
+
PathArgument(const std::string& key);
|
950
|
+
|
951
|
+
private:
|
952
|
+
enum Kind {
|
953
|
+
kindNone = 0,
|
954
|
+
kindIndex,
|
955
|
+
kindKey
|
956
|
+
};
|
957
|
+
std::string key_;
|
958
|
+
ArrayIndex index_;
|
959
|
+
Kind kind_;
|
960
|
+
};
|
961
|
+
|
962
|
+
/** \brief Experimental and untested: represents a "path" to access a node.
|
963
|
+
*
|
964
|
+
* Syntax:
|
965
|
+
* - "." => root node
|
966
|
+
* - ".[n]" => elements at index 'n' of root node (an array value)
|
967
|
+
* - ".name" => member named 'name' of root node (an object value)
|
968
|
+
* - ".name1.name2.name3"
|
969
|
+
* - ".[0][1][2].name1[3]"
|
970
|
+
* - ".%" => member name is provided as parameter
|
971
|
+
* - ".[%]" => index is provied as parameter
|
972
|
+
*/
|
973
|
+
class JSON_API Path {
|
974
|
+
public:
|
975
|
+
Path(const std::string& path,
|
976
|
+
const PathArgument& a1 = PathArgument(),
|
977
|
+
const PathArgument& a2 = PathArgument(),
|
978
|
+
const PathArgument& a3 = PathArgument(),
|
979
|
+
const PathArgument& a4 = PathArgument(),
|
980
|
+
const PathArgument& a5 = PathArgument());
|
981
|
+
|
982
|
+
const Value& resolve(const Value& root) const;
|
983
|
+
Value resolve(const Value& root, const Value& defaultValue) const;
|
984
|
+
/// Creates the "path" to access the specified node and returns a reference on
|
985
|
+
/// the node.
|
986
|
+
Value& make(Value& root) const;
|
987
|
+
|
988
|
+
private:
|
989
|
+
typedef std::vector<const PathArgument*> InArgs;
|
990
|
+
typedef std::vector<PathArgument> Args;
|
991
|
+
|
992
|
+
void makePath(const std::string& path, const InArgs& in);
|
993
|
+
void addPathInArg(const std::string& path,
|
994
|
+
const InArgs& in,
|
995
|
+
InArgs::const_iterator& itInArg,
|
996
|
+
PathArgument::Kind kind);
|
997
|
+
void invalidPath(const std::string& path, int location);
|
998
|
+
|
999
|
+
Args args_;
|
1000
|
+
};
|
1001
|
+
|
1002
|
+
/** \brief base class for Value iterators.
|
1003
|
+
*
|
1004
|
+
*/
|
1005
|
+
class JSON_API ValueIteratorBase {
|
1006
|
+
public:
|
1007
|
+
typedef std::bidirectional_iterator_tag iterator_category;
|
1008
|
+
typedef unsigned int size_t;
|
1009
|
+
typedef int difference_type;
|
1010
|
+
typedef ValueIteratorBase SelfType;
|
1011
|
+
|
1012
|
+
bool operator==(const SelfType& other) const { return isEqual(other); }
|
1013
|
+
|
1014
|
+
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
1015
|
+
|
1016
|
+
difference_type operator-(const SelfType& other) const {
|
1017
|
+
return other.computeDistance(*this);
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
/// Return either the index or the member name of the referenced value as a
|
1021
|
+
/// Value.
|
1022
|
+
Value key() const;
|
1023
|
+
|
1024
|
+
/// Return the index of the referenced Value, or -1 if it is not an arrayValue.
|
1025
|
+
UInt index() const;
|
1026
|
+
|
1027
|
+
/// Return the member name of the referenced Value, or "" if it is not an
|
1028
|
+
/// objectValue.
|
1029
|
+
/// \note Avoid `c_str()` on result, as embedded zeroes are possible.
|
1030
|
+
std::string name() const;
|
1031
|
+
|
1032
|
+
/// Return the member name of the referenced Value. "" if it is not an
|
1033
|
+
/// objectValue.
|
1034
|
+
/// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
|
1035
|
+
JSONCPP_DEPRECATED("Use `key = name();` instead.")
|
1036
|
+
char const* memberName() const;
|
1037
|
+
/// Return the member name of the referenced Value, or NULL if it is not an
|
1038
|
+
/// objectValue.
|
1039
|
+
/// \note Better version than memberName(). Allows embedded nulls.
|
1040
|
+
char const* memberName(char const** end) const;
|
1041
|
+
|
1042
|
+
protected:
|
1043
|
+
Value& deref() const;
|
1044
|
+
|
1045
|
+
void increment();
|
1046
|
+
|
1047
|
+
void decrement();
|
1048
|
+
|
1049
|
+
difference_type computeDistance(const SelfType& other) const;
|
1050
|
+
|
1051
|
+
bool isEqual(const SelfType& other) const;
|
1052
|
+
|
1053
|
+
void copy(const SelfType& other);
|
1054
|
+
|
1055
|
+
private:
|
1056
|
+
Value::ObjectValues::iterator current_;
|
1057
|
+
// Indicates that iterator is for a null value.
|
1058
|
+
bool isNull_;
|
1059
|
+
|
1060
|
+
public:
|
1061
|
+
// For some reason, BORLAND needs these at the end, rather
|
1062
|
+
// than earlier. No idea why.
|
1063
|
+
ValueIteratorBase();
|
1064
|
+
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
|
1065
|
+
};
|
1066
|
+
|
1067
|
+
/** \brief const iterator for object and array value.
|
1068
|
+
*
|
1069
|
+
*/
|
1070
|
+
class JSON_API ValueConstIterator : public ValueIteratorBase {
|
1071
|
+
friend class Value;
|
1072
|
+
|
1073
|
+
public:
|
1074
|
+
typedef const Value value_type;
|
1075
|
+
//typedef unsigned int size_t;
|
1076
|
+
//typedef int difference_type;
|
1077
|
+
typedef const Value& reference;
|
1078
|
+
typedef const Value* pointer;
|
1079
|
+
typedef ValueConstIterator SelfType;
|
1080
|
+
|
1081
|
+
ValueConstIterator();
|
1082
|
+
|
1083
|
+
private:
|
1084
|
+
/*! \internal Use by Value to create an iterator.
|
1085
|
+
*/
|
1086
|
+
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
|
1087
|
+
public:
|
1088
|
+
SelfType& operator=(const ValueIteratorBase& other);
|
1089
|
+
|
1090
|
+
SelfType operator++(int) {
|
1091
|
+
SelfType temp(*this);
|
1092
|
+
++*this;
|
1093
|
+
return temp;
|
1094
|
+
}
|
1095
|
+
|
1096
|
+
SelfType operator--(int) {
|
1097
|
+
SelfType temp(*this);
|
1098
|
+
--*this;
|
1099
|
+
return temp;
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
SelfType& operator--() {
|
1103
|
+
decrement();
|
1104
|
+
return *this;
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
SelfType& operator++() {
|
1108
|
+
increment();
|
1109
|
+
return *this;
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
reference operator*() const { return deref(); }
|
1113
|
+
|
1114
|
+
pointer operator->() const { return &deref(); }
|
1115
|
+
};
|
1116
|
+
|
1117
|
+
/** \brief Iterator for object and array value.
|
1118
|
+
*/
|
1119
|
+
class JSON_API ValueIterator : public ValueIteratorBase {
|
1120
|
+
friend class Value;
|
1121
|
+
|
1122
|
+
public:
|
1123
|
+
typedef Value value_type;
|
1124
|
+
typedef unsigned int size_t;
|
1125
|
+
typedef int difference_type;
|
1126
|
+
typedef Value& reference;
|
1127
|
+
typedef Value* pointer;
|
1128
|
+
typedef ValueIterator SelfType;
|
1129
|
+
|
1130
|
+
ValueIterator();
|
1131
|
+
ValueIterator(const ValueConstIterator& other);
|
1132
|
+
ValueIterator(const ValueIterator& other);
|
1133
|
+
|
1134
|
+
private:
|
1135
|
+
/*! \internal Use by Value to create an iterator.
|
1136
|
+
*/
|
1137
|
+
explicit ValueIterator(const Value::ObjectValues::iterator& current);
|
1138
|
+
public:
|
1139
|
+
SelfType& operator=(const SelfType& other);
|
1140
|
+
|
1141
|
+
SelfType operator++(int) {
|
1142
|
+
SelfType temp(*this);
|
1143
|
+
++*this;
|
1144
|
+
return temp;
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
SelfType operator--(int) {
|
1148
|
+
SelfType temp(*this);
|
1149
|
+
--*this;
|
1150
|
+
return temp;
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
SelfType& operator--() {
|
1154
|
+
decrement();
|
1155
|
+
return *this;
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
SelfType& operator++() {
|
1159
|
+
increment();
|
1160
|
+
return *this;
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
reference operator*() const { return deref(); }
|
1164
|
+
|
1165
|
+
pointer operator->() const { return &deref(); }
|
1166
|
+
};
|
1167
|
+
|
1168
|
+
} // namespace Json
|
1169
|
+
|
1170
|
+
|
1171
|
+
namespace std {
|
1172
|
+
/// Specialize std::swap() for Json::Value.
|
1173
|
+
template<>
|
1174
|
+
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
1175
|
+
}
|
1176
|
+
|
1177
|
+
|
1178
|
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1179
|
+
#pragma warning(pop)
|
1180
|
+
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1181
|
+
|
1182
|
+
#endif // CPPTL_JSON_H_INCLUDED
|
1183
|
+
|
1184
|
+
// //////////////////////////////////////////////////////////////////////
|
1185
|
+
// End of content of file: include/json/value.h
|
1186
|
+
// //////////////////////////////////////////////////////////////////////
|
1187
|
+
|
1188
|
+
|
1189
|
+
|
1190
|
+
|
1191
|
+
|
1192
|
+
|
1193
|
+
// //////////////////////////////////////////////////////////////////////
|
1194
|
+
// Beginning of content of file: include/json/reader.h
|
1195
|
+
// //////////////////////////////////////////////////////////////////////
|
1196
|
+
|
1197
|
+
// Copyright 2007-2010 Baptiste Lepilleur
|
1198
|
+
// Distributed under MIT license, or public domain if desired and
|
1199
|
+
// recognized in your jurisdiction.
|
1200
|
+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
1201
|
+
|
1202
|
+
#ifndef CPPTL_JSON_READER_H_INCLUDED
|
1203
|
+
#define CPPTL_JSON_READER_H_INCLUDED
|
1204
|
+
|
1205
|
+
#if !defined(JSON_IS_AMALGAMATION)
|
1206
|
+
#include "features.h"
|
1207
|
+
#include "value.h"
|
1208
|
+
#endif // if !defined(JSON_IS_AMALGAMATION)
|
1209
|
+
#include <deque>
|
1210
|
+
#include <iosfwd>
|
1211
|
+
#include <stack>
|
1212
|
+
#include <string>
|
1213
|
+
#include <istream>
|
1214
|
+
|
1215
|
+
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
1216
|
+
// be used by...
|
1217
|
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1218
|
+
#pragma warning(push)
|
1219
|
+
#pragma warning(disable : 4251)
|
1220
|
+
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1221
|
+
|
1222
|
+
namespace Json {
|
1223
|
+
|
1224
|
+
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
|
1225
|
+
*Value.
|
1226
|
+
*
|
1227
|
+
* \deprecated Use CharReader and CharReaderBuilder.
|
1228
|
+
*/
|
1229
|
+
class JSON_API Reader {
|
1230
|
+
public:
|
1231
|
+
typedef char Char;
|
1232
|
+
typedef const Char* Location;
|
1233
|
+
|
1234
|
+
/** \brief Constructs a Reader allowing all features
|
1235
|
+
* for parsing.
|
1236
|
+
*/
|
1237
|
+
Reader();
|
1238
|
+
|
1239
|
+
/** \brief Constructs a Reader allowing the specified feature set
|
1240
|
+
* for parsing.
|
1241
|
+
*/
|
1242
|
+
Reader(const Features& features);
|
1243
|
+
|
1244
|
+
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
1245
|
+
* document.
|
1246
|
+
* \param document UTF-8 encoded string containing the document to read.
|
1247
|
+
* \param root [out] Contains the root value of the document if it was
|
1248
|
+
* successfully parsed.
|
1249
|
+
* \param collectComments \c true to collect comment and allow writing them
|
1250
|
+
* back during
|
1251
|
+
* serialization, \c false to discard comments.
|
1252
|
+
* This parameter is ignored if
|
1253
|
+
* Features::allowComments_
|
1254
|
+
* is \c false.
|
1255
|
+
* \return \c true if the document was successfully parsed, \c false if an
|
1256
|
+
* error occurred.
|
1257
|
+
*/
|
1258
|
+
bool
|
1259
|
+
parse(const std::string& document, Value& root, bool collectComments = true);
|
1260
|
+
|
1261
|
+
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
1262
|
+
document.
|
1263
|
+
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
|
1264
|
+
document to read.
|
1265
|
+
* \param endDoc Pointer on the end of the UTF-8 encoded string of the
|
1266
|
+
document to read.
|
1267
|
+
* Must be >= beginDoc.
|
1268
|
+
* \param root [out] Contains the root value of the document if it was
|
1269
|
+
* successfully parsed.
|
1270
|
+
* \param collectComments \c true to collect comment and allow writing them
|
1271
|
+
back during
|
1272
|
+
* serialization, \c false to discard comments.
|
1273
|
+
* This parameter is ignored if
|
1274
|
+
Features::allowComments_
|
1275
|
+
* is \c false.
|
1276
|
+
* \return \c true if the document was successfully parsed, \c false if an
|
1277
|
+
error occurred.
|
1278
|
+
*/
|
1279
|
+
bool parse(const char* beginDoc,
|
1280
|
+
const char* endDoc,
|
1281
|
+
Value& root,
|
1282
|
+
bool collectComments = true);
|
1283
|
+
|
1284
|
+
/// \brief Parse from input stream.
|
1285
|
+
/// \see Json::operator>>(std::istream&, Json::Value&).
|
1286
|
+
bool parse(std::istream& is, Value& root, bool collectComments = true);
|
1287
|
+
|
1288
|
+
/** \brief Returns a user friendly string that list errors in the parsed
|
1289
|
+
* document.
|
1290
|
+
* \return Formatted error message with the list of errors with their location
|
1291
|
+
* in
|
1292
|
+
* the parsed document. An empty string is returned if no error
|
1293
|
+
* occurred
|
1294
|
+
* during parsing.
|
1295
|
+
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
1296
|
+
*/
|
1297
|
+
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
|
1298
|
+
std::string getFormatedErrorMessages() const;
|
1299
|
+
|
1300
|
+
/** \brief Returns a user friendly string that list errors in the parsed
|
1301
|
+
* document.
|
1302
|
+
* \return Formatted error message with the list of errors with their location
|
1303
|
+
* in
|
1304
|
+
* the parsed document. An empty string is returned if no error
|
1305
|
+
* occurred
|
1306
|
+
* during parsing.
|
1307
|
+
*/
|
1308
|
+
std::string getFormattedErrorMessages() const;
|
1309
|
+
|
1310
|
+
private:
|
1311
|
+
enum TokenType {
|
1312
|
+
tokenEndOfStream = 0,
|
1313
|
+
tokenObjectBegin,
|
1314
|
+
tokenObjectEnd,
|
1315
|
+
tokenArrayBegin,
|
1316
|
+
tokenArrayEnd,
|
1317
|
+
tokenString,
|
1318
|
+
tokenNumber,
|
1319
|
+
tokenTrue,
|
1320
|
+
tokenFalse,
|
1321
|
+
tokenNull,
|
1322
|
+
tokenArraySeparator,
|
1323
|
+
tokenMemberSeparator,
|
1324
|
+
tokenComment,
|
1325
|
+
tokenError
|
1326
|
+
};
|
1327
|
+
|
1328
|
+
class Token {
|
1329
|
+
public:
|
1330
|
+
TokenType type_;
|
1331
|
+
Location start_;
|
1332
|
+
Location end_;
|
1333
|
+
};
|
1334
|
+
|
1335
|
+
class ErrorInfo {
|
1336
|
+
public:
|
1337
|
+
Token token_;
|
1338
|
+
std::string message_;
|
1339
|
+
Location extra_;
|
1340
|
+
};
|
1341
|
+
|
1342
|
+
typedef std::deque<ErrorInfo> Errors;
|
1343
|
+
|
1344
|
+
bool readToken(Token& token);
|
1345
|
+
void skipSpaces();
|
1346
|
+
bool match(Location pattern, int patternLength);
|
1347
|
+
bool readComment();
|
1348
|
+
bool readCStyleComment();
|
1349
|
+
bool readCppStyleComment();
|
1350
|
+
bool readString();
|
1351
|
+
void readNumber();
|
1352
|
+
bool readValue();
|
1353
|
+
bool readObject(Token& token);
|
1354
|
+
bool readArray(Token& token);
|
1355
|
+
bool decodeNumber(Token& token);
|
1356
|
+
bool decodeNumber(Token& token, Value& decoded);
|
1357
|
+
bool decodeString(Token& token);
|
1358
|
+
bool decodeString(Token& token, std::string& decoded);
|
1359
|
+
bool decodeDouble(Token& token);
|
1360
|
+
bool decodeDouble(Token& token, Value& decoded);
|
1361
|
+
bool decodeUnicodeCodePoint(Token& token,
|
1362
|
+
Location& current,
|
1363
|
+
Location end,
|
1364
|
+
unsigned int& unicode);
|
1365
|
+
bool decodeUnicodeEscapeSequence(Token& token,
|
1366
|
+
Location& current,
|
1367
|
+
Location end,
|
1368
|
+
unsigned int& unicode);
|
1369
|
+
bool addError(const std::string& message, Token& token, Location extra = 0);
|
1370
|
+
bool recoverFromError(TokenType skipUntilToken);
|
1371
|
+
bool addErrorAndRecover(const std::string& message,
|
1372
|
+
Token& token,
|
1373
|
+
TokenType skipUntilToken);
|
1374
|
+
void skipUntilSpace();
|
1375
|
+
Value& currentValue();
|
1376
|
+
Char getNextChar();
|
1377
|
+
void
|
1378
|
+
getLocationLineAndColumn(Location location, int& line, int& column) const;
|
1379
|
+
std::string getLocationLineAndColumn(Location location) const;
|
1380
|
+
void addComment(Location begin, Location end, CommentPlacement placement);
|
1381
|
+
void skipCommentTokens(Token& token);
|
1382
|
+
|
1383
|
+
typedef std::stack<Value*> Nodes;
|
1384
|
+
Nodes nodes_;
|
1385
|
+
Errors errors_;
|
1386
|
+
std::string document_;
|
1387
|
+
Location begin_;
|
1388
|
+
Location end_;
|
1389
|
+
Location current_;
|
1390
|
+
Location lastValueEnd_;
|
1391
|
+
Value* lastValue_;
|
1392
|
+
std::string commentsBefore_;
|
1393
|
+
Features features_;
|
1394
|
+
bool collectComments_;
|
1395
|
+
}; // Reader
|
1396
|
+
|
1397
|
+
/** Interface for reading JSON from a char array.
|
1398
|
+
*/
|
1399
|
+
class JSON_API CharReader {
|
1400
|
+
public:
|
1401
|
+
virtual ~CharReader() {}
|
1402
|
+
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
1403
|
+
document.
|
1404
|
+
* The document must be a UTF-8 encoded string containing the document to read.
|
1405
|
+
*
|
1406
|
+
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
|
1407
|
+
document to read.
|
1408
|
+
* \param endDoc Pointer on the end of the UTF-8 encoded string of the
|
1409
|
+
document to read.
|
1410
|
+
* Must be >= beginDoc.
|
1411
|
+
* \param root [out] Contains the root value of the document if it was
|
1412
|
+
* successfully parsed.
|
1413
|
+
* \param errs [out] Formatted error messages (if not NULL)
|
1414
|
+
* a user friendly string that lists errors in the parsed
|
1415
|
+
* document.
|
1416
|
+
* \return \c true if the document was successfully parsed, \c false if an
|
1417
|
+
error occurred.
|
1418
|
+
*/
|
1419
|
+
virtual bool parse(
|
1420
|
+
char const* beginDoc, char const* endDoc,
|
1421
|
+
Value* root, std::string* errs) = 0;
|
1422
|
+
|
1423
|
+
class Factory {
|
1424
|
+
public:
|
1425
|
+
virtual ~Factory() {}
|
1426
|
+
/** \brief Allocate a CharReader via operator new().
|
1427
|
+
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
1428
|
+
*/
|
1429
|
+
virtual CharReader* newCharReader() const = 0;
|
1430
|
+
}; // Factory
|
1431
|
+
}; // CharReader
|
1432
|
+
|
1433
|
+
/** \brief Build a CharReader implementation.
|
1434
|
+
|
1435
|
+
Usage:
|
1436
|
+
\code
|
1437
|
+
using namespace Json;
|
1438
|
+
CharReaderBuilder builder;
|
1439
|
+
builder["collectComments"] = false;
|
1440
|
+
Value value;
|
1441
|
+
std::string errs;
|
1442
|
+
bool ok = parseFromStream(builder, std::cin, &value, &errs);
|
1443
|
+
\endcode
|
1444
|
+
*/
|
1445
|
+
class JSON_API CharReaderBuilder : public CharReader::Factory {
|
1446
|
+
public:
|
1447
|
+
// Note: We use a Json::Value so that we can add data-members to this class
|
1448
|
+
// without a major version bump.
|
1449
|
+
/** Configuration of this builder.
|
1450
|
+
These are case-sensitive.
|
1451
|
+
Available settings (case-sensitive):
|
1452
|
+
- `"collectComments": false or true`
|
1453
|
+
- true to collect comment and allow writing them
|
1454
|
+
back during serialization, false to discard comments.
|
1455
|
+
This parameter is ignored if allowComments is false.
|
1456
|
+
- `"allowComments": false or true`
|
1457
|
+
- true if comments are allowed.
|
1458
|
+
- `"strictRoot": false or true`
|
1459
|
+
- true if root must be either an array or an object value
|
1460
|
+
- `"allowDroppedNullPlaceholders": false or true`
|
1461
|
+
- true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
|
1462
|
+
- `"allowNumericKeys": false or true`
|
1463
|
+
- true if numeric object keys are allowed.
|
1464
|
+
- `"allowSingleQuotes": false or true`
|
1465
|
+
- true if '' are allowed for strings (both keys and values)
|
1466
|
+
- `"stackLimit": integer`
|
1467
|
+
- Exceeding stackLimit (recursive depth of `readValue()`) will
|
1468
|
+
cause an exception.
|
1469
|
+
- This is a security issue (seg-faults caused by deeply nested JSON),
|
1470
|
+
so the default is low.
|
1471
|
+
- `"failIfExtra": false or true`
|
1472
|
+
- If true, `parse()` returns false when extra non-whitespace trails
|
1473
|
+
the JSON value in the input string.
|
1474
|
+
- `"rejectDupKeys": false or true`
|
1475
|
+
- If true, `parse()` returns false when a key is duplicated within an object.
|
1476
|
+
|
1477
|
+
You can examine 'settings_` yourself
|
1478
|
+
to see the defaults. You can also write and read them just like any
|
1479
|
+
JSON Value.
|
1480
|
+
\sa setDefaults()
|
1481
|
+
*/
|
1482
|
+
Json::Value settings_;
|
1483
|
+
|
1484
|
+
CharReaderBuilder();
|
1485
|
+
virtual ~CharReaderBuilder();
|
1486
|
+
|
1487
|
+
virtual CharReader* newCharReader() const;
|
1488
|
+
|
1489
|
+
/** \return true if 'settings' are legal and consistent;
|
1490
|
+
* otherwise, indicate bad settings via 'invalid'.
|
1491
|
+
*/
|
1492
|
+
bool validate(Json::Value* invalid) const;
|
1493
|
+
|
1494
|
+
/** A simple way to update a specific setting.
|
1495
|
+
*/
|
1496
|
+
Value& operator[](std::string key);
|
1497
|
+
|
1498
|
+
/** Called by ctor, but you can use this to reset settings_.
|
1499
|
+
* \pre 'settings' != NULL (but Json::null is fine)
|
1500
|
+
* \remark Defaults:
|
1501
|
+
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
1502
|
+
*/
|
1503
|
+
static void setDefaults(Json::Value* settings);
|
1504
|
+
/** Same as old Features::strictMode().
|
1505
|
+
* \pre 'settings' != NULL (but Json::null is fine)
|
1506
|
+
* \remark Defaults:
|
1507
|
+
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
1508
|
+
*/
|
1509
|
+
static void strictMode(Json::Value* settings);
|
1510
|
+
};
|
1511
|
+
|
1512
|
+
/** Consume entire stream and use its begin/end.
|
1513
|
+
* Someday we might have a real StreamReader, but for now this
|
1514
|
+
* is convenient.
|
1515
|
+
*/
|
1516
|
+
bool JSON_API parseFromStream(
|
1517
|
+
CharReader::Factory const&,
|
1518
|
+
std::istream&,
|
1519
|
+
Value* root, std::string* errs);
|
1520
|
+
|
1521
|
+
/** \brief Read from 'sin' into 'root'.
|
1522
|
+
|
1523
|
+
Always keep comments from the input JSON.
|
1524
|
+
|
1525
|
+
This can be used to read a file into a particular sub-object.
|
1526
|
+
For example:
|
1527
|
+
\code
|
1528
|
+
Json::Value root;
|
1529
|
+
cin >> root["dir"]["file"];
|
1530
|
+
cout << root;
|
1531
|
+
\endcode
|
1532
|
+
Result:
|
1533
|
+
\verbatim
|
1534
|
+
{
|
1535
|
+
"dir": {
|
1536
|
+
"file": {
|
1537
|
+
// The input stream JSON would be nested here.
|
1538
|
+
}
|
1539
|
+
}
|
1540
|
+
}
|
1541
|
+
\endverbatim
|
1542
|
+
\throw std::exception on parse error.
|
1543
|
+
\see Json::operator<<()
|
1544
|
+
*/
|
1545
|
+
JSON_API std::istream& operator>>(std::istream&, Value&);
|
1546
|
+
|
1547
|
+
} // namespace Json
|
1548
|
+
|
1549
|
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1550
|
+
#pragma warning(pop)
|
1551
|
+
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1552
|
+
|
1553
|
+
#endif // CPPTL_JSON_READER_H_INCLUDED
|
1554
|
+
|
1555
|
+
// //////////////////////////////////////////////////////////////////////
|
1556
|
+
// End of content of file: include/json/reader.h
|
1557
|
+
// //////////////////////////////////////////////////////////////////////
|
1558
|
+
|
1559
|
+
|
1560
|
+
|
1561
|
+
|
1562
|
+
|
1563
|
+
|
1564
|
+
// //////////////////////////////////////////////////////////////////////
|
1565
|
+
// Beginning of content of file: include/json/writer.h
|
1566
|
+
// //////////////////////////////////////////////////////////////////////
|
1567
|
+
|
1568
|
+
// Copyright 2007-2010 Baptiste Lepilleur
|
1569
|
+
// Distributed under MIT license, or public domain if desired and
|
1570
|
+
// recognized in your jurisdiction.
|
1571
|
+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
1572
|
+
|
1573
|
+
#ifndef JSON_WRITER_H_INCLUDED
|
1574
|
+
#define JSON_WRITER_H_INCLUDED
|
1575
|
+
|
1576
|
+
#if !defined(JSON_IS_AMALGAMATION)
|
1577
|
+
#include "value.h"
|
1578
|
+
#endif // if !defined(JSON_IS_AMALGAMATION)
|
1579
|
+
#include <vector>
|
1580
|
+
#include <string>
|
1581
|
+
#include <ostream>
|
1582
|
+
|
1583
|
+
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
1584
|
+
// be used by...
|
1585
|
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1586
|
+
#pragma warning(push)
|
1587
|
+
#pragma warning(disable : 4251)
|
1588
|
+
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1589
|
+
|
1590
|
+
namespace Json {
|
1591
|
+
|
1592
|
+
class Value;
|
1593
|
+
|
1594
|
+
/**
|
1595
|
+
|
1596
|
+
Usage:
|
1597
|
+
\code
|
1598
|
+
using namespace Json;
|
1599
|
+
void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
|
1600
|
+
std::unique_ptr<StreamWriter> const writer(
|
1601
|
+
factory.newStreamWriter());
|
1602
|
+
writer->write(value, &std::cout);
|
1603
|
+
std::cout << std::endl; // add lf and flush
|
1604
|
+
}
|
1605
|
+
\endcode
|
1606
|
+
*/
|
1607
|
+
class JSON_API StreamWriter {
|
1608
|
+
protected:
|
1609
|
+
std::ostream* sout_; // not owned; will not delete
|
1610
|
+
public:
|
1611
|
+
StreamWriter();
|
1612
|
+
virtual ~StreamWriter();
|
1613
|
+
/** Write Value into document as configured in sub-class.
|
1614
|
+
Do not take ownership of sout, but maintain a reference during function.
|
1615
|
+
\pre sout != NULL
|
1616
|
+
\return zero on success (For now, we always return zero, so check the stream instead.)
|
1617
|
+
\throw std::exception possibly, depending on configuration
|
1618
|
+
*/
|
1619
|
+
virtual int write(Value const& root, std::ostream* sout) = 0;
|
1620
|
+
|
1621
|
+
/** \brief A simple abstract factory.
|
1622
|
+
*/
|
1623
|
+
class JSON_API Factory {
|
1624
|
+
public:
|
1625
|
+
virtual ~Factory();
|
1626
|
+
/** \brief Allocate a CharReader via operator new().
|
1627
|
+
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
1628
|
+
*/
|
1629
|
+
virtual StreamWriter* newStreamWriter() const = 0;
|
1630
|
+
}; // Factory
|
1631
|
+
}; // StreamWriter
|
1632
|
+
|
1633
|
+
/** \brief Write into stringstream, then return string, for convenience.
|
1634
|
+
* A StreamWriter will be created from the factory, used, and then deleted.
|
1635
|
+
*/
|
1636
|
+
std::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
|
1637
|
+
|
1638
|
+
|
1639
|
+
/** \brief Build a StreamWriter implementation.
|
1640
|
+
|
1641
|
+
Usage:
|
1642
|
+
\code
|
1643
|
+
using namespace Json;
|
1644
|
+
Value value = ...;
|
1645
|
+
StreamWriterBuilder builder;
|
1646
|
+
builder["commentStyle"] = "None";
|
1647
|
+
builder["indentation"] = " "; // or whatever you like
|
1648
|
+
std::unique_ptr<Json::StreamWriter> writer(
|
1649
|
+
builder.newStreamWriter());
|
1650
|
+
writer->write(value, &std::cout);
|
1651
|
+
std::cout << std::endl; // add lf and flush
|
1652
|
+
\endcode
|
1653
|
+
*/
|
1654
|
+
class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
|
1655
|
+
public:
|
1656
|
+
// Note: We use a Json::Value so that we can add data-members to this class
|
1657
|
+
// without a major version bump.
|
1658
|
+
/** Configuration of this builder.
|
1659
|
+
Available settings (case-sensitive):
|
1660
|
+
- "commentStyle": "None" or "All"
|
1661
|
+
- "indentation": "<anything>"
|
1662
|
+
- "enableYAMLCompatibility": false or true
|
1663
|
+
- slightly change the whitespace around colons
|
1664
|
+
- "dropNullPlaceholders": false or true
|
1665
|
+
- Drop the "null" string from the writer's output for nullValues.
|
1666
|
+
Strictly speaking, this is not valid JSON. But when the output is being
|
1667
|
+
fed to a browser's Javascript, it makes for smaller output and the
|
1668
|
+
browser can handle the output just fine.
|
1669
|
+
|
1670
|
+
You can examine 'settings_` yourself
|
1671
|
+
to see the defaults. You can also write and read them just like any
|
1672
|
+
JSON Value.
|
1673
|
+
\sa setDefaults()
|
1674
|
+
*/
|
1675
|
+
Json::Value settings_;
|
1676
|
+
|
1677
|
+
StreamWriterBuilder();
|
1678
|
+
virtual ~StreamWriterBuilder();
|
1679
|
+
|
1680
|
+
/**
|
1681
|
+
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
1682
|
+
*/
|
1683
|
+
virtual StreamWriter* newStreamWriter() const;
|
1684
|
+
|
1685
|
+
/** \return true if 'settings' are legal and consistent;
|
1686
|
+
* otherwise, indicate bad settings via 'invalid'.
|
1687
|
+
*/
|
1688
|
+
bool validate(Json::Value* invalid) const;
|
1689
|
+
/** A simple way to update a specific setting.
|
1690
|
+
*/
|
1691
|
+
Value& operator[](std::string key);
|
1692
|
+
|
1693
|
+
/** Called by ctor, but you can use this to reset settings_.
|
1694
|
+
* \pre 'settings' != NULL (but Json::null is fine)
|
1695
|
+
* \remark Defaults:
|
1696
|
+
* \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
|
1697
|
+
*/
|
1698
|
+
static void setDefaults(Json::Value* settings);
|
1699
|
+
};
|
1700
|
+
|
1701
|
+
/** \brief Abstract class for writers.
|
1702
|
+
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
1703
|
+
*/
|
1704
|
+
class JSON_API Writer {
|
1705
|
+
public:
|
1706
|
+
virtual ~Writer();
|
1707
|
+
|
1708
|
+
virtual std::string write(const Value& root) = 0;
|
1709
|
+
};
|
1710
|
+
|
1711
|
+
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
|
1712
|
+
*without formatting (not human friendly).
|
1713
|
+
*
|
1714
|
+
* The JSON document is written in a single line. It is not intended for 'human'
|
1715
|
+
*consumption,
|
1716
|
+
* but may be usefull to support feature such as RPC where bandwith is limited.
|
1717
|
+
* \sa Reader, Value
|
1718
|
+
* \deprecated Use StreamWriterBuilder.
|
1719
|
+
*/
|
1720
|
+
class JSON_API FastWriter : public Writer {
|
1721
|
+
|
1722
|
+
public:
|
1723
|
+
FastWriter();
|
1724
|
+
virtual ~FastWriter() {}
|
1725
|
+
|
1726
|
+
void enableYAMLCompatibility();
|
1727
|
+
|
1728
|
+
public: // overridden from Writer
|
1729
|
+
virtual std::string write(const Value& root);
|
1730
|
+
|
1731
|
+
private:
|
1732
|
+
void writeValue(const Value& value);
|
1733
|
+
|
1734
|
+
std::string document_;
|
1735
|
+
bool yamlCompatiblityEnabled_;
|
1736
|
+
};
|
1737
|
+
|
1738
|
+
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
1739
|
+
*human friendly way.
|
1740
|
+
*
|
1741
|
+
* The rules for line break and indent are as follow:
|
1742
|
+
* - Object value:
|
1743
|
+
* - if empty then print {} without indent and line break
|
1744
|
+
* - if not empty the print '{', line break & indent, print one value per
|
1745
|
+
*line
|
1746
|
+
* and then unindent and line break and print '}'.
|
1747
|
+
* - Array value:
|
1748
|
+
* - if empty then print [] without indent and line break
|
1749
|
+
* - if the array contains no object value, empty array or some other value
|
1750
|
+
*types,
|
1751
|
+
* and all the values fit on one lines, then print the array on a single
|
1752
|
+
*line.
|
1753
|
+
* - otherwise, it the values do not fit on one line, or the array contains
|
1754
|
+
* object or non empty array, then print one value per line.
|
1755
|
+
*
|
1756
|
+
* If the Value have comments then they are outputed according to their
|
1757
|
+
*#CommentPlacement.
|
1758
|
+
*
|
1759
|
+
* \sa Reader, Value, Value::setComment()
|
1760
|
+
* \deprecated Use StreamWriterBuilder.
|
1761
|
+
*/
|
1762
|
+
class JSON_API StyledWriter : public Writer {
|
1763
|
+
public:
|
1764
|
+
StyledWriter();
|
1765
|
+
virtual ~StyledWriter() {}
|
1766
|
+
|
1767
|
+
public: // overridden from Writer
|
1768
|
+
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
1769
|
+
* \param root Value to serialize.
|
1770
|
+
* \return String containing the JSON document that represents the root value.
|
1771
|
+
*/
|
1772
|
+
virtual std::string write(const Value& root);
|
1773
|
+
|
1774
|
+
private:
|
1775
|
+
void writeValue(const Value& value);
|
1776
|
+
void writeArrayValue(const Value& value);
|
1777
|
+
bool isMultineArray(const Value& value);
|
1778
|
+
void pushValue(const std::string& value);
|
1779
|
+
void writeIndent();
|
1780
|
+
void writeWithIndent(const std::string& value);
|
1781
|
+
void indent();
|
1782
|
+
void unindent();
|
1783
|
+
void writeCommentBeforeValue(const Value& root);
|
1784
|
+
void writeCommentAfterValueOnSameLine(const Value& root);
|
1785
|
+
bool hasCommentForValue(const Value& value);
|
1786
|
+
static std::string normalizeEOL(const std::string& text);
|
1787
|
+
|
1788
|
+
typedef std::vector<std::string> ChildValues;
|
1789
|
+
|
1790
|
+
ChildValues childValues_;
|
1791
|
+
std::string document_;
|
1792
|
+
std::string indentString_;
|
1793
|
+
int rightMargin_;
|
1794
|
+
int indentSize_;
|
1795
|
+
bool addChildValues_;
|
1796
|
+
};
|
1797
|
+
|
1798
|
+
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
1799
|
+
human friendly way,
|
1800
|
+
to a stream rather than to a string.
|
1801
|
+
*
|
1802
|
+
* The rules for line break and indent are as follow:
|
1803
|
+
* - Object value:
|
1804
|
+
* - if empty then print {} without indent and line break
|
1805
|
+
* - if not empty the print '{', line break & indent, print one value per
|
1806
|
+
line
|
1807
|
+
* and then unindent and line break and print '}'.
|
1808
|
+
* - Array value:
|
1809
|
+
* - if empty then print [] without indent and line break
|
1810
|
+
* - if the array contains no object value, empty array or some other value
|
1811
|
+
types,
|
1812
|
+
* and all the values fit on one lines, then print the array on a single
|
1813
|
+
line.
|
1814
|
+
* - otherwise, it the values do not fit on one line, or the array contains
|
1815
|
+
* object or non empty array, then print one value per line.
|
1816
|
+
*
|
1817
|
+
* If the Value have comments then they are outputed according to their
|
1818
|
+
#CommentPlacement.
|
1819
|
+
*
|
1820
|
+
* \param indentation Each level will be indented by this amount extra.
|
1821
|
+
* \sa Reader, Value, Value::setComment()
|
1822
|
+
* \deprecated Use StreamWriterBuilder.
|
1823
|
+
*/
|
1824
|
+
class JSON_API StyledStreamWriter {
|
1825
|
+
public:
|
1826
|
+
StyledStreamWriter(std::string indentation = "\t");
|
1827
|
+
~StyledStreamWriter() {}
|
1828
|
+
|
1829
|
+
public:
|
1830
|
+
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
1831
|
+
* \param out Stream to write to. (Can be ostringstream, e.g.)
|
1832
|
+
* \param root Value to serialize.
|
1833
|
+
* \note There is no point in deriving from Writer, since write() should not
|
1834
|
+
* return a value.
|
1835
|
+
*/
|
1836
|
+
void write(std::ostream& out, const Value& root);
|
1837
|
+
|
1838
|
+
private:
|
1839
|
+
void writeValue(const Value& value);
|
1840
|
+
void writeArrayValue(const Value& value);
|
1841
|
+
bool isMultineArray(const Value& value);
|
1842
|
+
void pushValue(const std::string& value);
|
1843
|
+
void writeIndent();
|
1844
|
+
void writeWithIndent(const std::string& value);
|
1845
|
+
void indent();
|
1846
|
+
void unindent();
|
1847
|
+
void writeCommentBeforeValue(const Value& root);
|
1848
|
+
void writeCommentAfterValueOnSameLine(const Value& root);
|
1849
|
+
bool hasCommentForValue(const Value& value);
|
1850
|
+
static std::string normalizeEOL(const std::string& text);
|
1851
|
+
|
1852
|
+
typedef std::vector<std::string> ChildValues;
|
1853
|
+
|
1854
|
+
ChildValues childValues_;
|
1855
|
+
std::ostream* document_;
|
1856
|
+
std::string indentString_;
|
1857
|
+
int rightMargin_;
|
1858
|
+
std::string indentation_;
|
1859
|
+
bool addChildValues_ : 1;
|
1860
|
+
bool indented_ : 1;
|
1861
|
+
};
|
1862
|
+
|
1863
|
+
#if defined(JSON_HAS_INT64)
|
1864
|
+
std::string JSON_API valueToString(Int value);
|
1865
|
+
std::string JSON_API valueToString(UInt value);
|
1866
|
+
#endif // if defined(JSON_HAS_INT64)
|
1867
|
+
std::string JSON_API valueToString(LargestInt value);
|
1868
|
+
std::string JSON_API valueToString(LargestUInt value);
|
1869
|
+
std::string JSON_API valueToString(double value);
|
1870
|
+
std::string JSON_API valueToString(bool value);
|
1871
|
+
std::string JSON_API valueToQuotedString(const char* value);
|
1872
|
+
|
1873
|
+
/// \brief Output using the StyledStreamWriter.
|
1874
|
+
/// \see Json::operator>>()
|
1875
|
+
JSON_API std::ostream& operator<<(std::ostream&, const Value& root);
|
1876
|
+
|
1877
|
+
} // namespace Json
|
1878
|
+
|
1879
|
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1880
|
+
#pragma warning(pop)
|
1881
|
+
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
1882
|
+
|
1883
|
+
#endif // JSON_WRITER_H_INCLUDED
|
1884
|
+
|
1885
|
+
// //////////////////////////////////////////////////////////////////////
|
1886
|
+
// End of content of file: include/json/writer.h
|
1887
|
+
// //////////////////////////////////////////////////////////////////////
|
1888
|
+
|
1889
|
+
|
1890
|
+
|
1891
|
+
|
1892
|
+
|
1893
|
+
|
1894
|
+
// //////////////////////////////////////////////////////////////////////
|
1895
|
+
// Beginning of content of file: include/json/assertions.h
|
1896
|
+
// //////////////////////////////////////////////////////////////////////
|
1897
|
+
|
1898
|
+
// Copyright 2007-2010 Baptiste Lepilleur
|
1899
|
+
// Distributed under MIT license, or public domain if desired and
|
1900
|
+
// recognized in your jurisdiction.
|
1901
|
+
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
1902
|
+
|
1903
|
+
#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
1904
|
+
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
1905
|
+
|
1906
|
+
#include <stdlib.h>
|
1907
|
+
#include <sstream>
|
1908
|
+
|
1909
|
+
#if !defined(JSON_IS_AMALGAMATION)
|
1910
|
+
#include "config.h"
|
1911
|
+
#endif // if !defined(JSON_IS_AMALGAMATION)
|
1912
|
+
|
1913
|
+
/** It should not be possible for a maliciously designed file to
|
1914
|
+
* cause an abort() or seg-fault, so these macros are used only
|
1915
|
+
* for pre-condition violations and internal logic errors.
|
1916
|
+
*/
|
1917
|
+
#if JSON_USE_EXCEPTION
|
1918
|
+
|
1919
|
+
// @todo <= add detail about condition in exception
|
1920
|
+
# define JSON_ASSERT(condition) \
|
1921
|
+
{if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
|
1922
|
+
|
1923
|
+
# define JSON_FAIL_MESSAGE(message) \
|
1924
|
+
{ \
|
1925
|
+
std::ostringstream oss; oss << message; \
|
1926
|
+
Json::throwLogicError(oss.str()); \
|
1927
|
+
abort(); \
|
1928
|
+
}
|
1929
|
+
|
1930
|
+
#else // JSON_USE_EXCEPTION
|
1931
|
+
|
1932
|
+
# define JSON_ASSERT(condition) assert(condition)
|
1933
|
+
|
1934
|
+
// The call to assert() will show the failure message in debug builds. In
|
1935
|
+
// release builds we abort, for a core-dump or debugger.
|
1936
|
+
# define JSON_FAIL_MESSAGE(message) \
|
1937
|
+
{ \
|
1938
|
+
std::ostringstream oss; oss << message; \
|
1939
|
+
assert(false && oss.str().c_str()); \
|
1940
|
+
abort(); \
|
1941
|
+
}
|
1942
|
+
|
1943
|
+
|
1944
|
+
#endif
|
1945
|
+
|
1946
|
+
#define JSON_ASSERT_MESSAGE(condition, message) \
|
1947
|
+
if (!(condition)) { \
|
1948
|
+
JSON_FAIL_MESSAGE(message); \
|
1949
|
+
}
|
1950
|
+
|
1951
|
+
#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
|
1952
|
+
|
1953
|
+
// //////////////////////////////////////////////////////////////////////
|
1954
|
+
// End of content of file: include/json/assertions.h
|
1955
|
+
// //////////////////////////////////////////////////////////////////////
|
1956
|
+
|
1957
|
+
|
1958
|
+
|
1959
|
+
|
1960
|
+
|
1961
|
+
#endif //ifndef JSON_AMALGATED_H_INCLUDED
|