From 93d13ad2acc6a52d58e09d84e76826cd36ee64f0 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Fri, 24 Apr 2015 21:44:42 +0800 Subject: [PATCH 01/13] Fix #313 Assertion In `Pow10.h` is triggered in Document::Parse --- include/rapidjson/reader.h | 5 +++++ test/unittest/readertest.cpp | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 08297a08b..320428ffa 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -929,6 +929,11 @@ class GenericReader { exp = exp * 10 + (s.Take() - '0'); if (exp > 308 && !expMinus) // exp > 308 should be rare, so it should be checked first. RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, s.Tell()); + else if (exp >= 429496729 && expMinus) { // Issue #313: prevent overflow exponent + while (s.Peek() >= '0' && s.Peek() <= '9') // Consume the rest of exponent + s.Take(); + break; + } } } else diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index 4e8d4e4a1..86199fab3 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -219,13 +219,17 @@ static void TestParseDouble() { TEST_DOUBLE(fullPrecision, "2.2250738585072009e-308", 2.2250738585072009e-308); // Max subnormal double TEST_DOUBLE(fullPrecision, "2.2250738585072014e-308", 2.2250738585072014e-308); // Min normal positive double TEST_DOUBLE(fullPrecision, "1.7976931348623157e+308", 1.7976931348623157e+308); // Max double - TEST_DOUBLE(fullPrecision, "1e-10000", 0.0); // must underflow - TEST_DOUBLE(fullPrecision, "18446744073709551616", 18446744073709551616.0); // 2^64 (max of uint64_t + 1, force to use double) - TEST_DOUBLE(fullPrecision, "-9223372036854775809", -9223372036854775809.0); // -2^63 - 1(min of int64_t + 1, force to use double) - TEST_DOUBLE(fullPrecision, "0.9868011474609375", 0.9868011474609375); // https://github.com/miloyip/rapidjson/issues/120 - TEST_DOUBLE(fullPrecision, "123e34", 123e34); // Fast Path Cases In Disguise + TEST_DOUBLE(fullPrecision, "1e-10000", 0.0); // must underflow + TEST_DOUBLE(fullPrecision, "18446744073709551616", 18446744073709551616.0); // 2^64 (max of uint64_t + 1, force to use double) + TEST_DOUBLE(fullPrecision, "-9223372036854775809", -9223372036854775809.0); // -2^63 - 1(min of int64_t + 1, force to use double) + TEST_DOUBLE(fullPrecision, "0.9868011474609375", 0.9868011474609375); // https://github.com/miloyip/rapidjson/issues/120 + TEST_DOUBLE(fullPrecision, "123e34", 123e34); // Fast Path Cases In Disguise TEST_DOUBLE(fullPrecision, "45913141877270640000.0", 45913141877270640000.0); TEST_DOUBLE(fullPrecision, "2.2250738585072011e-308", 2.2250738585072011e-308); // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ + TEST_DOUBLE(fullPrecision, "1e-00011111111111", 0.0); // Issue #313 + TEST_DOUBLE(fullPrecision, "-1e-00011111111111", -0.0); + TEST_DOUBLE(fullPrecision, "1e-429496729", 0.0); // Maximum supported negative exponent + // Since // abs((2^-1022 - 2^-1074) - 2.2250738585072012e-308) = 3.109754131239141401123495768877590405345064751974375599... 10^-324 From 735354efd328709a8efb6a2a43a584bb85f2de6b Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Fri, 24 Apr 2015 22:50:42 +0800 Subject: [PATCH 02/13] Separate handling for pos/neg exp and improve pos exp overflow --- include/rapidjson/reader.h | 23 +++++++++++++++-------- test/unittest/readertest.cpp | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 320428ffa..d809d5732 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -925,14 +925,21 @@ class GenericReader { if (s.Peek() >= '0' && s.Peek() <= '9') { exp = s.Take() - '0'; - while (s.Peek() >= '0' && s.Peek() <= '9') { - exp = exp * 10 + (s.Take() - '0'); - if (exp > 308 && !expMinus) // exp > 308 should be rare, so it should be checked first. - RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, s.Tell()); - else if (exp >= 429496729 && expMinus) { // Issue #313: prevent overflow exponent - while (s.Peek() >= '0' && s.Peek() <= '9') // Consume the rest of exponent - s.Take(); - break; + if (expMinus) { + while (s.Peek() >= '0' && s.Peek() <= '9') { + exp = exp * 10 + (s.Take() - '0'); + if (exp >= 429496729) { // Issue #313: prevent overflow exponent + while (s.Peek() >= '0' && s.Peek() <= '9') // Consume the rest of exponent + s.Take(); + } + } + } + else { // positive exp + int maxExp = 308 - expFrac; + while (s.Peek() >= '0' && s.Peek() <= '9') { + exp = exp * 10 + (s.Take() - '0'); + if (exp > maxExp) + RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, s.Tell()); } } } diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index 86199fab3..e55380c6a 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -229,6 +229,7 @@ static void TestParseDouble() { TEST_DOUBLE(fullPrecision, "1e-00011111111111", 0.0); // Issue #313 TEST_DOUBLE(fullPrecision, "-1e-00011111111111", -0.0); TEST_DOUBLE(fullPrecision, "1e-429496729", 0.0); // Maximum supported negative exponent + TEST_DOUBLE(fullPrecision, "0.017976931348623157e+310", 1.7976931348623157e+308); // Max double in another form // Since From 7708215b609733bcfa06074b67463920c03782e8 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 25 Apr 2015 00:13:09 +0800 Subject: [PATCH 03/13] Try to fix #313 again --- include/rapidjson/reader.h | 2 +- test/unittest/readertest.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index d809d5732..be0d9fb94 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -928,7 +928,7 @@ class GenericReader { if (expMinus) { while (s.Peek() >= '0' && s.Peek() <= '9') { exp = exp * 10 + (s.Take() - '0'); - if (exp >= 429496729) { // Issue #313: prevent overflow exponent + if (exp >= 214748364) { // Issue #313: prevent overflow exponent while (s.Peek() >= '0' && s.Peek() <= '9') // Consume the rest of exponent s.Take(); } diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index e55380c6a..bee19a8ea 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -228,9 +228,10 @@ static void TestParseDouble() { TEST_DOUBLE(fullPrecision, "2.2250738585072011e-308", 2.2250738585072011e-308); // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ TEST_DOUBLE(fullPrecision, "1e-00011111111111", 0.0); // Issue #313 TEST_DOUBLE(fullPrecision, "-1e-00011111111111", -0.0); - TEST_DOUBLE(fullPrecision, "1e-429496729", 0.0); // Maximum supported negative exponent + TEST_DOUBLE(fullPrecision, "1e-214748363", 0.0); // Maximum supported negative exponent + TEST_DOUBLE(fullPrecision, "1e-214748364", 0.0); + TEST_DOUBLE(fullPrecision, "1e-21474836311", 0.0); TEST_DOUBLE(fullPrecision, "0.017976931348623157e+310", 1.7976931348623157e+308); // Max double in another form - // Since // abs((2^-1022 - 2^-1074) - 2.2250738585072012e-308) = 3.109754131239141401123495768877590405345064751974375599... 10^-324 From a9250d170dc7474bf4c7441de587b4933515b127 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 24 Apr 2015 13:32:00 -0500 Subject: [PATCH 04/13] Fixed to build on older versions of 32-bit MSVC --- include/rapidjson/internal/diyfp.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/rapidjson/internal/diyfp.h b/include/rapidjson/internal/diyfp.h index de3d1f01a..033a2a274 100644 --- a/include/rapidjson/internal/diyfp.h +++ b/include/rapidjson/internal/diyfp.h @@ -19,12 +19,10 @@ #ifndef RAPIDJSON_DIYFP_H_ #define RAPIDJSON_DIYFP_H_ -#if defined(_MSC_VER) +#if defined(_MSC_VER) && defined(_M_AMD64) #include -#if defined(_M_AMD64) #pragma intrinsic(_BitScanReverse64) #endif -#endif RAPIDJSON_NAMESPACE_BEGIN namespace internal { From 4f20541339bb5ba251ded2b14cef348e43eb0e7c Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 25 Apr 2015 09:49:31 +0800 Subject: [PATCH 05/13] Add change log --- CHANGELOG.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..3938cbfb3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,59 @@ +# Change Log +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] + +## [1.0.1] - 2015-04-25 + +### Added +* Changelog following [Keep a CHANGELOG](https://github.com/olivierlacan/keep-a-changelog) suggestions. + +### Fixed +* Parsing of some numbers (e.g. "1e-00011111111111") causing assertion (#314). +* Visual C++ 32-bit compilation error in `diyfp.h` (#317). + +## [1.0.0] - 2015-04-22 + +### Added +* 100% [Coverall](https://coveralls.io/r/miloyip/rapidjson?branch=master) coverage. +* Version macros (#311) + +### Fixed +* A bug in trimming long number sequence (4824f12efbf01af72b8cb6fc96fae7b097b73015). +* Double quote in unicode escape (#288). +* Negative zero roundtrip (double only) (#289). +* Standardize behavior of `memcpy()` and `malloc()` (0c5c1538dcfc7f160e5a4aa208ddf092c787be5a, #305, 0e8bbe5e3ef375e7f052f556878be0bd79e9062d). + +### Removed +* Remove an invalid `Document::ParseInsitu()` API (e7f1c6dd08b522cfcf9aed58a333bd9a0c0ccbeb). + +## [1.0 Beta] - 2015-04-8 + +### Added +* RFC 7159 (#101) +* Optional Iterative Parser (#76) +* Deep-copy values (#20) +* Error code and message (#27) +* ASCII Encoding (#70) +* `kParseStopWhenDoneFlag` (#83) +* `kParseFullPrecisionFlag` (881c91d696f06b7f302af6d04ec14dd08db66ceb) +* Add `Key()` to handler concept (#134) +* C++11 compatibility and support (#128) +* Optimized number-to-string and vice versa conversions (#137, #80) +* Short-String Optimization (#131) +* Local stream optimization by traits (#32) +* Travis & Appveyor Continuous Integration, with Valgrind verification (#24, #242) +* Redo all documentation (English, Simplified Chinese) + +### Changed +* Copyright ownership transfered to THL A29 Limited (a Tencent company). +* Migrating from Premake to CMAKE (#192) +* Resolve all warning reports + +### Removed +* Remove other JSON libraries for performance comparison (#180) + +## [0.11] - 2012-11-16 + +## [0.1] - 2011-11-18 From 316292d5189e9e7e3565b6d9423576a6a3cf73f4 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 25 Apr 2015 09:52:59 +0800 Subject: [PATCH 06/13] Change version to 1.0.1 --- CMakeLists.txt | 2 +- appveyor.yml | 2 +- include/rapidjson/rapidjson.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 559312bc9..380bdcd3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ PROJECT(RapidJSON CXX) set(LIB_MAJOR_VERSION "1") set(LIB_MINOR_VERSION "0") -set(LIB_PATCH_VERSION "0") +set(LIB_PATCH_VERSION "1") set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}") # compile in release with debug info mode by default diff --git a/appveyor.yml b/appveyor.yml index 890f9d9a5..add401782 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.0.0.{build} +version: 1.0.1.{build} configuration: - Debug diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index 938a3ce4a..0c41ab655 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -69,7 +69,7 @@ */ #define RAPIDJSON_MAJOR_VERSION 1 #define RAPIDJSON_MINOR_VERSION 0 -#define RAPIDJSON_PATCH_VERSION 0 +#define RAPIDJSON_PATCH_VERSION 1 #define RAPIDJSON_VERSION_STRING \ RAPIDJSON_STRINGIFY(RAPIDJSON_MAJOR_VERSION.RAPIDJSON_MINOR_VERSION.RAPIDJSON_PATCH_VERSION) From 2e913bfea6fd199126a0bb343fb2e86bda2359cf Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 25 Apr 2015 10:18:30 +0800 Subject: [PATCH 07/13] Update readme badge to version 1.0.1 also --- readme.md | 2 +- readme.zh-cn.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 007596a40..98f81a731 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ ![](doc/logo/rapidjson.png) -![](https://img.shields.io/badge/release-v1.0.0-blue.png) +![](https://img.shields.io/badge/release-v1.0.1-blue.png) ## A fast JSON parser/generator for C++ with both SAX/DOM style API diff --git a/readme.zh-cn.md b/readme.zh-cn.md index be3849a71..2dd27cf59 100644 --- a/readme.zh-cn.md +++ b/readme.zh-cn.md @@ -1,6 +1,6 @@ ![](doc/logo/rapidjson.png) -![](https://img.shields.io/badge/release-v1.0.0-blue.png) +![](https://img.shields.io/badge/release-v1.0.1-blue.png) Tencent is pleased to support the open source community by making RapidJSON available. From a592e199e7e9ef10a4059f2ec18f59dcd1b7ec3c Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 25 Apr 2015 15:53:51 +0800 Subject: [PATCH 08/13] Update CHANGELOG.md --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3938cbfb3..dd0e4edfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -## [1.0.1] - 2015-04-25 +## [v1.0.1] - 2015-04-25 ### Added * Changelog following [Keep a CHANGELOG](https://github.com/olivierlacan/keep-a-changelog) suggestions. @@ -13,7 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Parsing of some numbers (e.g. "1e-00011111111111") causing assertion (#314). * Visual C++ 32-bit compilation error in `diyfp.h` (#317). -## [1.0.0] - 2015-04-22 +## [v1.0.0] - 2015-04-22 ### Added * 100% [Coverall](https://coveralls.io/r/miloyip/rapidjson?branch=master) coverage. @@ -28,7 +28,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Removed * Remove an invalid `Document::ParseInsitu()` API (e7f1c6dd08b522cfcf9aed58a333bd9a0c0ccbeb). -## [1.0 Beta] - 2015-04-8 +## [v1.0 Beta] - 2015-04-8 ### Added * RFC 7159 (#101) @@ -54,6 +54,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Removed * Remove other JSON libraries for performance comparison (#180) -## [0.11] - 2012-11-16 +## 0.11 - 2012-11-16 -## [0.1] - 2011-11-18 +## 0.1 - 2011-11-18 From d2269f65f60d12b96228918619d8df606fc61de2 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sat, 25 Apr 2015 16:01:10 +0800 Subject: [PATCH 09/13] Update CHANGELOG.md --- CHANGELOG.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd0e4edfa..07d732b34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -## [v1.0.1] - 2015-04-25 +## [1.0.1] - 2015-04-25 ### Added * Changelog following [Keep a CHANGELOG](https://github.com/olivierlacan/keep-a-changelog) suggestions. @@ -13,7 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Parsing of some numbers (e.g. "1e-00011111111111") causing assertion (#314). * Visual C++ 32-bit compilation error in `diyfp.h` (#317). -## [v1.0.0] - 2015-04-22 +## [1.0.0] - 2015-04-22 ### Added * 100% [Coverall](https://coveralls.io/r/miloyip/rapidjson?branch=master) coverage. @@ -28,7 +28,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Removed * Remove an invalid `Document::ParseInsitu()` API (e7f1c6dd08b522cfcf9aed58a333bd9a0c0ccbeb). -## [v1.0 Beta] - 2015-04-8 +## 1.0-beta - 2015-04-8 ### Added * RFC 7159 (#101) @@ -57,3 +57,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## 0.11 - 2012-11-16 ## 0.1 - 2011-11-18 + +[Unreleased]: https://github.com/miloyip/rapidjson/compare/v1.0.1...HEAD +[1.0.1]: https://github.com/miloyip/rapidjson/compare/v1.0.0...v1.0.1 +[1.0.0]: https://github.com/miloyip/rapidjson/compare/v1.0-beta...v1.0.0 From 8f891403bc22f691173898c2e7b76574eac2a86b Mon Sep 17 00:00:00 2001 From: Guo Xiao Date: Sun, 26 Apr 2015 20:54:03 +0800 Subject: [PATCH 10/13] Fix warnings when visited via https --- doc/faq.md | 2 +- doc/misc/footer.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/faq.md b/doc/faq.md index 85afcd3d5..b00b4c62d 100644 --- a/doc/faq.md +++ b/doc/faq.md @@ -28,7 +28,7 @@ 6. How to install RapidJSON? - Check [Installation section](http://miloyip.github.io/rapidjson/). + Check [Installation section](https://miloyip.github.io/rapidjson/). 7. Can RapidJSON run on my platform? diff --git a/doc/misc/footer.html b/doc/misc/footer.html index edf3e6911..843aa1104 100644 --- a/doc/misc/footer.html +++ b/doc/misc/footer.html @@ -18,10 +18,10 @@ (document.getElementsByClassName('contents')[0]).appendChild(dt); var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; - dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; + dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); - \ No newline at end of file + From dba6d6f1b51f03016fcd62dd90b480ea50f29dc8 Mon Sep 17 00:00:00 2001 From: miloyip Date: Tue, 28 Apr 2015 10:09:37 +0800 Subject: [PATCH 11/13] Include rapidjson.h in error/error.h and internal/*.h Fixes #321 --- CHANGELOG.md | 2 ++ include/rapidjson/error/error.h | 2 ++ include/rapidjson/internal/diyfp.h | 2 ++ include/rapidjson/internal/meta.h | 4 +--- include/rapidjson/internal/pow10.h | 2 ++ include/rapidjson/internal/stack.h | 2 ++ include/rapidjson/internal/strfunc.h | 2 ++ 7 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07d732b34..92a405493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +* Include rapidjson.h for all internal/error headers. + ## [1.0.1] - 2015-04-25 ### Added diff --git a/include/rapidjson/error/error.h b/include/rapidjson/error/error.h index aa5700ca8..f9094fb95 100644 --- a/include/rapidjson/error/error.h +++ b/include/rapidjson/error/error.h @@ -15,6 +15,8 @@ #ifndef RAPIDJSON_ERROR_ERROR_H__ #define RAPIDJSON_ERROR_ERROR_H__ +#include "../rapidjson.h" + /*! \file error.h */ /*! \defgroup RAPIDJSON_ERRORS RapidJSON error handling */ diff --git a/include/rapidjson/internal/diyfp.h b/include/rapidjson/internal/diyfp.h index 033a2a274..4ef53d9d1 100644 --- a/include/rapidjson/internal/diyfp.h +++ b/include/rapidjson/internal/diyfp.h @@ -19,6 +19,8 @@ #ifndef RAPIDJSON_DIYFP_H_ #define RAPIDJSON_DIYFP_H_ +#include "../rapidjson.h" + #if defined(_MSC_VER) && defined(_M_AMD64) #include #pragma intrinsic(_BitScanReverse64) diff --git a/include/rapidjson/internal/meta.h b/include/rapidjson/internal/meta.h index 594e2597b..2daad964e 100644 --- a/include/rapidjson/internal/meta.h +++ b/include/rapidjson/internal/meta.h @@ -15,9 +15,7 @@ #ifndef RAPIDJSON_INTERNAL_META_H_ #define RAPIDJSON_INTERNAL_META_H_ -#ifndef RAPIDJSON_RAPIDJSON_H_ -#error not yet included. Do not include this file directly. -#endif +#include "../rapidjson.h" #ifdef __GNUC__ RAPIDJSON_DIAG_PUSH diff --git a/include/rapidjson/internal/pow10.h b/include/rapidjson/internal/pow10.h index c552d9f8d..1d2dff06a 100644 --- a/include/rapidjson/internal/pow10.h +++ b/include/rapidjson/internal/pow10.h @@ -15,6 +15,8 @@ #ifndef RAPIDJSON_POW10_ #define RAPIDJSON_POW10_ +#include "../rapidjson.h" + RAPIDJSON_NAMESPACE_BEGIN namespace internal { diff --git a/include/rapidjson/internal/stack.h b/include/rapidjson/internal/stack.h index 2f2c76a36..bb31cc0d3 100644 --- a/include/rapidjson/internal/stack.h +++ b/include/rapidjson/internal/stack.h @@ -15,6 +15,8 @@ #ifndef RAPIDJSON_INTERNAL_STACK_H_ #define RAPIDJSON_INTERNAL_STACK_H_ +#include "../rapidjson.h" + RAPIDJSON_NAMESPACE_BEGIN namespace internal { diff --git a/include/rapidjson/internal/strfunc.h b/include/rapidjson/internal/strfunc.h index e6d1c2122..f6c99dbf4 100644 --- a/include/rapidjson/internal/strfunc.h +++ b/include/rapidjson/internal/strfunc.h @@ -15,6 +15,8 @@ #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ #define RAPIDJSON_INTERNAL_STRFUNC_H_ +#include "../rapidjson.h" + RAPIDJSON_NAMESPACE_BEGIN namespace internal { From c1b66cc082b5500f3410be0d367b0044c46e3153 Mon Sep 17 00:00:00 2001 From: miloyip Date: Tue, 28 Apr 2015 22:41:31 +0800 Subject: [PATCH 12/13] Fix incorrect API in tutorial document. --- doc/tutorial.md | 2 +- doc/tutorial.zh-cn.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 811833d3c..350891893 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -192,7 +192,7 @@ Checking | Obtaining `bool IsNumber()` | N/A `bool IsUint()` | `unsigned GetUint()` `bool IsInt()` | `int GetInt()` -`bool IsUint64()` | `uint64_t GetUint()` +`bool IsUint64()` | `uint64_t GetUint64()` `bool IsInt64()` | `int64_t GetInt64()` `bool IsDouble()` | `double GetDouble()` diff --git a/doc/tutorial.zh-cn.md b/doc/tutorial.zh-cn.md index 24456d527..d1381beba 100644 --- a/doc/tutorial.zh-cn.md +++ b/doc/tutorial.zh-cn.md @@ -192,7 +192,7 @@ JSON只提供一种数值类型──Number。数字可以是整数或实数。R `bool IsNumber()` | 不适用 `bool IsUint()` | `unsigned GetUint()` `bool IsInt()` | `int GetInt()` -`bool IsUint64()` | `uint64_t GetUint()` +`bool IsUint64()` | `uint64_t GetUint64()` `bool IsInt64()` | `int64_t GetInt64()` `bool IsDouble()` | `double GetDouble()` From ea7b39b960fa1f2baed5d3587dffe1b42f39e3fe Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Fri, 1 May 2015 08:10:21 +0800 Subject: [PATCH 13/13] Update installation section of zh-cn readme --- readme.zh-cn.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/readme.zh-cn.md b/readme.zh-cn.md index 2dd27cf59..eb6c21d63 100644 --- a/readme.zh-cn.md +++ b/readme.zh-cn.md @@ -2,6 +2,8 @@ ![](https://img.shields.io/badge/release-v1.0.1-blue.png) +## 高效的C++ JSON解析/生成器,提供SAX及DOM风格API + Tencent is pleased to support the open source community by making RapidJSON available. Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. @@ -60,21 +62,21 @@ RapidJSON是跨平台的。以下是一些曾测试的平台/编译器组合 RapidJSON是只有头文件的C++库。只需把`include/rapidjson`目录复制至系统或项目的include目录中。 +RapidJSON依赖于以下软件: +* [CMake](http://www.cmake.org) 作为通用生成工具 +* (optional)[Doxygen](http://www.doxygen.org)用于生成文档 +* (optional)[googletest](https://code.google.com/p/googletest/)用于单元及性能测试 + 生成测试及例子的步骤: 1. 执行 `git submodule update --init` 去获取 thirdparty submodules (google test)。 -2. 下载 [premake4](http://industriousone.com/premake/download)。 -3. 复制 premake4 可执行文件至 `rapidjson/build` (或系统路径)。 -4. 进入`rapidjson/build/`目录,在Windows下执行`premake.bat`,在Linux或其他平台下执行`premake.sh`。 -5. 在Windows上,生成位于`rapidjson/build/vs2008/`或`/vs2010/`内的项目方案. -6. 在其他平台上,在`rapidjson/build/gmake/`目录执行GNU `make`(如 `make -f test.make config=release32`、`make -f example.make config=debug32`)。 -7. 若成功,可执行文件会生成在`rapidjson/bin`目录。 - -生成[Doxygen](http://doxygen.org)文档的步骤: - -1. 下载及安装[Doxygen](http://doxygen.org/download.html)。 -2. 在顶层目录执行`doxygen build/Doxyfile`。 -3. 在`doc/html`浏览文档。 +2. 在rapidjson目渌下,建立一个`build`目录。 +3. 在`build`目录下执行`cmake ..`命令以设置生成。Windows用户可使用cmake-gui应用程序。 +4. 在Windows下,编译生成在build目录中的solution。在Linux下,于build目录运行`make`。 + +成功生成后,你会在`bin`的目录下找到编译后的测试及例子可执行文件。而生成的文档将位于build下的`doc/html`目录。要执行测试,请在build下执行`make test`或`ctest`。使用`ctest -V`命令可获取详细的输出。 + +我们也可以把程序库安装至全系统中,只要在具管理權限下从build目录执行`make install`命令。这样会按系统的偏好设置安装所有文件。当安装RapidJSON后,其他的CMake项目需要使用它时,可以通过在`CMakeLists.txt`加入一句`find_package(RapidJSON)`。 ## 用法一览