1132 Commits

Author SHA1 Message Date
Steve Hanson
28bcbd3f35 make std::string optional 2021-06-08 10:53:10 +01:00
Steve Hanson
494447b731 remove copyright & debug statements 2021-05-21 15:55:11 +01:00
Steve Hanson
3987d82f41 Merge branch 'master' of https://github.com/Tencent/rapidjson into id-and-ref 2021-05-20 12:20:12 +01:00
N. Kolotov
3aa8d04b74 Fixed -Wshadow warning. 2021-05-03 01:56:41 +03:00
Hendrik Muhs
d179facf90 don't let the GetObject macro rewrite the GetObject method, add a GetObj alias 2021-04-19 12:29:11 -07:00
ylavic
71f0fa7eb3 Set RAPIDJSON_USE_MEMBERSMAP to use a (std::multi)map for object members.
When RAPIDJSON_USE_MEMBERSMAP is defined, an object Value will store
its members in an (re)allocated array of Members like before, but also
in an std::multimap<GenericValue::Data,SizeType> where the key and value
reference the corresponding Member by its Data and index in the array,
respectively, and in a relocatable manner.

The layout of the members map/array is now:
 {multimap*}<>{capacity}<>{Member[capacity]}<>{multimap::iterator[capacity]}
where <> stands for the RAPIDJSON_ALIGN-ment of each part, if needed.

This layout needs to be reallocated when the current capacity is
exhausted, which requires to take care of the multimap and its iterators
explicitely. The multimap is allocated separately and only its pointer is
saved in this layout, so it can easily be restored in its new position.
As for the old/alive iterators, they must move to their new offset according
to the new capacity.

With this in place, it's immediate to get the multimap::iterator from a
MemberIterator and vice versa, thus the same complexity applies for the
operations with MemberIterator or MapIterator.

For FindMember() and RemoveMember(), the complexity drops from O(n) to
the multimap/rbtree's O(log n).
For EraseMember() it drops from O(n-m) to O((log n)-m), m representing
the move/copy of the trailing members.
For AddMember() though, the complexity grows from O(1) to O(log n) due to
the insertion in the multimap too.

Consequently parsing will be slower, up to ~20% measured in perftests on
my laptop (since it's mainly composed of insertions). But later work on
the Document (usually the goal of parsing...) will be much faster; the
new DocumentFind perftest included in this commit is 8 times faster with
RAPIDJSON_USE_MEMBERSMAP (still on my laptop). Overall the tests are 4%
slower (mainly composed of parsing), and notably 15% slower for schemas
parsing/validation (which supposedly comes from the larger JSON files
parsing, still). As a side note, when RAPIDJSON_USE_MEMBERSMAP is not
defined, this commit does nothing (same results for perftest with regard
to previous versions).

Finally, the multimap is allocated and constructed using StdAllocator,
so they will use the same Allocator than for any other Value allocation,
and thus will benefit from the same performance/safety/security/whatever
provided by the user given Allocator.
2021-04-07 18:22:46 +02:00
Milo Yip
7d801bbe45
Merge pull request #1503 from ylavic/sub_value_assignment
Fix (Sub-)Value assignment
2021-04-07 17:52:51 +08:00
ylavic
683010b02d Add rvalue copy and assignment to MemoryPoolAllocator and StdAllocator. 2021-04-04 12:51:47 +02:00
ylavic
6bed9b266f Don't define StdAllocator<void> from C++17. 2021-03-30 13:47:04 +02:00
ylavic
08cf9a56c0 Make StdAllocator C++17-20 compatible. 2021-03-29 11:32:33 +02:00
ylavic
02f42604bd Make StdAllocator C++17-20 compatible. 2021-03-28 23:48:14 +02:00
ylavic
49e4dd619f Provide StdAllocator, STL compatible, for use with STL types. 2021-03-16 01:03:04 +01:00
ylavic
c033292aea Safer GenericValue& operator=(GenericValue& rhs).
When rhs is a sub-Value of *this, destroying *this also destroys/frees
rhs, thus the following RawAssign(rhs) crashes.

Address this by saving/moving rhs to a temporary first, which clears rhs
and avoids its destruction with *this.

The crash can be reproduced in test Value.MergeDuplicateKey by using the
CrtAllocator instead of the default Document's MemoryPoolAllocator.
2021-03-15 23:57:42 +01:00
ylavic
d51dd2d0e9 RAPIDJSON_NOEXCEPT_ASSERT should assert regardless of RAPIDJSON_HAS_CXX11_NOEXCEPT. 2021-03-12 15:32:17 +01:00
ylavic
cdb2d4757d Provide RAPIDJSON_HAS_CXX11 and use it for RAPIDJSON_HAS_CXX11_RVALUE_REFS and RAPIDJSON_HAS_CXX11_NOEXCEPT. 2021-03-12 15:14:30 +01:00
Steve Hanson
24b9b7e276 satisfy all compilers 2 2021-03-11 18:16:24 +00:00
Steve Hanson
32722fa31d satisfy all compilers 2021-03-11 16:53:05 +00:00
Steve Hanson
8768b5b1d6 correct #defines in uri.h 2021-03-11 15:13:17 +00:00
Steve Hanson
6c9da69abf remove comma 2021-03-11 15:06:02 +00:00
Steve Hanson
6b57738e4a handle internal refs properly 2021-03-11 14:49:28 +00:00
Steve Hanson
ad73c032e7 fix compile errors 2021-02-25 22:51:35 +00:00
Steve Hanson
892f6e3fd3 fix bracket 2021-02-25 22:21:20 +00:00
Steve Hanson
cabc3d5aa1 merge 2021-02-25 22:12:05 +00:00
Steve Hanson
7698b3cd48 code and tests 2021-02-25 21:45:29 +00:00
Milo Yip
b1a4d91a53
Merge pull request #1779 from pavel-pimenov/fix-1778-part-1
fix 1778  (part 1)
2021-02-23 10:23:34 +08:00
Laurent Stacul
24ebd51287 Fix recursive operator== call in C++20 (#1846) 2021-02-22 16:52:27 +00:00
Steve Hanson
9bb81e20ff fix crash where simple type with sub-schema has a bad value 2021-02-12 17:36:55 +00:00
Steve Hanson
a3757456fe correct workaround for issue 1805 2021-01-29 16:43:12 +00:00
Steve Hanson
c491dd5213 remove C++ 11 enum syntax 2021-01-29 10:26:05 +00:00
Steve Hanson
6f3cccd6e1 remove debug std::cout, handle empty error object in example 2021-01-28 14:21:36 +00:00
Steve Hanson
05e7b33977 code and tests 2021-01-28 12:11:43 +00:00
Krystian Chmura
cbf62de55d Add implicit conversion from Object and Array to Value (#1404)
Allows resolution of JSON Pointer on Object and Array
2021-01-05 14:20:57 +01:00
Xuanyi Zhou
3006926231 suppress enum bitwise operation warnings on msvc 2020-12-26 23:09:39 -05:00
Milo Yip
56f215e5c3
Merge pull request #1568 from ericrannaud/ericrannaud/memberiterator-public
Make GenericMemberIterator::Iterator public again (RAPIDJSON_NOMEMBER…
2020-12-23 09:41:20 +08:00
Silas S. Brown
b7734d97c0 Remove unnecessary wording from BSD license not needed for MIT license (fixes #528) 2020-10-09 10:04:27 +01:00
Pave Pimenov
3a65e2dd7f fix https://github.com/Tencent/rapidjson/issues/1778 (part 1) 2020-09-12 19:53:06 +03:00
escherstair
7f559ec80a fix naive implementation for clzll() 2020-08-06 15:55:26 +02:00
escherstair
aa5dd60865 fix naive version implementation 2020-08-04 14:39:19 +02:00
escherstair
91940e84b1 fallback to the naive version for CE6 2020-08-04 14:38:45 +02:00
escherstair
6364c8e5ab fix _BitScanReverse() usage for CE6 2020-08-04 10:01:44 +02:00
Lars Klein
ed73d7bdb4 Improve surrogate handling
Report a single low surrogate as kParseErrorStringUnicodeSurrogateInvalid.
2020-07-04 14:34:09 +02:00
Gaspard Petit
004e8e61a0 Merge branch 'master' into custom_malloc 2020-06-22 22:31:37 -04:00
Gustav
ac0fc79c76 Fixes issue #1718 2020-05-18 14:06:39 +02:00
Nikolay
ebcbd04484
Three-way comparison for CLang 10 fix (#1679)
C++20 features must enable additional functionality, not to change interface completely
2020-03-30 10:20:35 +08:00
Romain Geissler @ Amadeus
2661a17c7e
Avoid warnings when using -std=c++20 and clang 10: use three way comparision for iterators when possible. (#1667)
/data/mwrep/res/osp/RapidJson/20-0-0-0/include/rapidjson/document.h:729:58: error: use of overloaded operator '!=' is ambiguous (with operand types 'rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >::MemberIterator' (aka 'rapidjson::GenericMemberIterator<false, rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >') and 'rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >::MemberIterator')
                for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)
2020-03-20 13:39:48 +08:00
Jun
814bb27bf0
Replace RAPIDJSON_CLZLL with internal clzll (#1660)
RAPIDJSON_CLZLL is defined as macro of __builtin_clzll when
using gcc to compile. This introduces two issues:
1. in gcc __builtin_clzll returns int, not uint32_t.
2. __builtin_clzll return is undefined when input x is 0
See: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

This patch removes RAPIDJSON_CLZLL, merges __builtin_clzll to
internal clzll with input check and return value explicit cast.

Change-Id: Iac4b355dc5e5b4ed9b3f35a640b6b5537e76f22c
Signed-off-by: Jun He <jun.he@arm.com>

Co-authored-by: Jun He <jun.he@arm.com>
2020-03-11 15:11:25 +08:00
Milo Yip
563fe5bbbe
PrettyWriter constructor uninitialized member (#1654)
Fix #1653
2020-03-05 14:13:11 +08:00
Milo Yip
2bed293f48
Update biginteger.h (#1652)
Fix intel compiler macro
de6681e295 (commitcomment-37645051)
2020-03-05 11:06:01 +08:00
mdamle
b16cec1a1a
Closes #1643 (#1644)
This change comes up with compile time pre-processor directives to
tune the behavior of rapidjson wrt memory consumption. The idea is to
allow each module using this library to choose the right defaults based
on how it consumes memory and what performance it expects.

1. RAPIDJSON_DEFAULT_ALLOCATOR: If defined allows you to choose
	CrtAllocator over MemoryPoolAllocator. If it is not defined, chooses MemoryPoolAllocator by default.
2. RAPIDJSON_DEFAULT_STACK_ALLOCATOR: If defined allows you to choose
	MemoryPoolAllocator over CrtAllocator. If it is not defined, chooses CrtAllocator by default.
3. RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY and RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY: If defined and set to a
	value, uses that value for default number of objects/array elements to be pre-allocated. If not defined,
	uses value of 16: the current default.

Verified that all tests pass.
2020-02-25 11:34:28 +08:00
xpahos
a895ce150f
Allow escaped apostrophe in values (#1639)
* Allow escaped apostrophe in values

* Allow escaped apostrophe in values

* Canonical flag name

* Add translation for escaped apostrophe

Co-authored-by: Milo Yip <miloyip@gmail.com>
2020-02-13 09:53:15 +08:00