1136 Commits

Author SHA1 Message Date
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
Milo Yip
dfbe1db9da
Merge pull request #1502 from ylavic/compilation_fixes
Compilation fixes
2019-12-03 09:51:05 +08:00
Joshua Watt
134af9d811 Remove shadow typedef
Removes a duplicate and identical typedef that was causing a
'declaration shadows typedef' (-Wshadow) warning in clang.
2019-12-02 09:19:16 -06:00
Charles Milette
e54aca7006
Merge branch 'master' of https://github.com/Tencent/rapidjson 2019-10-31 21:10:28 -04:00
Milo Yip
1a825d24fa
Merge pull request #1529 from rkoshy/master
Fixed a build issue by initializing "index" in the header file
2019-10-15 09:49:27 +08:00
Ross Younger
4116912cde Use C++17 fallthrough tag instead of disabling warning
Signed-off-by: Ross Younger <crazyscot@gmail.com>
2019-10-01 20:12:54 +13:00
Milo Yip
d67a69a9cf
Merge pull request #1490 from MalcolmTyrrell/fixCompileErrorInPointerH
Fix vs2017 compile error C2105: '--' needs l-value
2019-09-26 10:08:13 +08:00
Milo Yip
88a1ba9e30 Provide default implementations for move constructor/assignment in GenericMember 2019-09-25 20:20:20 +08:00
Milo Yip
c36b713c47 Disable copy constructor in GenericMember 2019-09-25 18:02:17 +08:00
Eric Rannaud
ebc003e205 Make GenericMemberIterator::Iterator public again (RAPIDJSON_NOMEMBERITERATORCLASS)
d87b698d0f made all definitions of GenericMemberIterator consistent as
classes (they were structs with RAPIDJSON_NOMEMBERITERATORCLASS
defined), but it didn't keep the member definitions public.

document.h:586:71: error: 'Iterator' is a private member of
      'rapidjson::GenericMemberIterator<false, rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >'
    typedef typename GenericMemberIterator<false,Encoding,Allocator>::Iterator MemberIterator;  //!< Member iterator for i...
                                                                      ^
document.h:2124:32: note: in instantiation of template class
      'rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> >' requested here
class GenericDocument : public GenericValue<Encoding, Allocator> {
2019-09-12 09:08:11 -07:00
Etienne Laurin
6102f0bd06 fix template parameter 2019-09-11 17:23:15 +01:00
Etienne Laurin
6fe99777e4 Allow pointer tokens to have non-null-terminated strings 2019-09-11 17:03:35 +01:00
Charles Milette
02230fecbf
Change #ifdef to #if defined 2019-07-25 17:17:52 -04:00
Charles Milette
dfc0b35360
Update comment 2019-07-25 17:12:48 -04:00
Charles Milette
0d671a2e19
Fix signedness error 2019-07-25 17:11:20 -04:00
Charles Milette
07e1d7870a
Fix build error under non-Clang compilers 2019-07-25 16:55:34 -04:00
Charles Milette
d5d7171f6d
Fix ARM NEON under MSVC 2019-07-25 16:38:34 -04:00
Milo Yip
d87b698d0f Change all GenericMemberIterator from struct to class 2019-06-28 10:37:13 +08:00
Renny Koshy
c43697c16c - Fixed a build issue by initializing "index" in the header file 2019-06-21 23:55:32 -04:00
ylavic
92f99bc2ee RAPIDJSON_NOEXCEPT_ASSERT() should never throw.
clang warns about throwing from RAPIDJSON_NOEXCEPT_ASSERT() in a nothrow
context.

If RAPIDJSON_ASSERT() throws it can never be used for _NOEXCEPT_ASSERT(),
so use C assert() instead.

Finally (and originally), since RAPIDJSON_ASSERT() in "unittest.h" throws,
make it define RAPIDJSON_ASSERT_THROWS for RAPIDJSON_NOEXCEPT_ASSERT() to
now do the right thing.
2019-05-09 13:37:49 +02:00
ylavic
94fc463801 Add missing curly brackets in STDREGEX's CreatePattern(). 2019-04-29 15:06:52 +02:00
Malcolm Tyrrell
c840a7ae15 Fix vs2017 compile error C2105: '--' needs l-value 2019-04-15 10:00:14 +01:00
Liang ZOU
13687a6e3e
add missing header "ios"
add missing header "ios" for symbol "std:: streamsize"
2019-04-09 10:55:57 +08:00
eisaev
9264a9a7ef
Update allocators.h
Fixed typo
2019-04-03 22:10:30 +05:00
Luka Rahne
40cae03b0d Allow user to define custom RAPIDJSON_NOEXCEPT_ASSERT macro 2019-03-10 20:07:59 +01:00
Milo Yip
3cf4f7c5a0
Merge pull request #727 from mapbox/silence-dereference-null-pointer
Silence false positive clang-tidy warning
2019-03-06 09:33:13 +08:00
Gaspard Petit
cef07fb1b3 Added parameters to RAPIDJSON_MALLOC, RAPIDJSON_REALLOC and RAPIDJSON_FREE
Signed-off-by: Gaspard Petit <gaspard.petit@eidosmontreal.com>
2019-02-10 01:15:35 -05:00
Gaspard Petit
ad2e5369b9 Adding a single customization point that ensures all allocations within rapidjson can be performed with a custom memory allocator; Introduces the macros RAPIDJSON_MALLOC, RAPIDJSON_REALLOC, and RAPIDJSON_FREE.
Signed-off-by: Gaspard Petit <gaspard.petit@eidosmontreal.com>
2019-02-10 00:32:26 -05:00
Milo Yip
b94c2a1203 Adding swap() for GenericMember 2019-02-08 11:39:25 +08:00
Milo Yip
79a6dabd08
Merge pull request #1439 from ylavic/schema_pointer_allocator
Use the allocator of the Schema for its Pointer.
2019-02-06 19:31:03 +08:00
Léonard Gérard
bf09397285
Correct complexity claim 2019-01-31 22:29:07 -08:00
ylavic
dbb594bdb3 Use the allocator of the Schema for its Pointer.
The Pointer passed to construct the Schema can be from the stack or any
transient storage, so the copy stored in the Schema must have the same
lifetime/allocator as the Schema itself.
2019-01-10 18:42:16 +01:00
Milo Yip
b56eb28575
Merge branch 'master' into pointer_less_than 2018-12-18 09:32:09 +08:00
ylavic
a66cf7924c Allow to (std::)Swap two pointers. 2018-12-17 14:33:32 +01:00
ylavic
eb6ee17d2d Speed up Pointer::operator<().
Speed is more important than alphabetical order (which makes few sense in
JSON in general, and with pointers especially). The use case is indexing
in std containers, i.e. O(log n) with rbtree, so the faster comparison
the better.
2018-12-12 22:32:56 +01:00
ylavic
0e34ed43f4 Rework Pointer::operator<() loop.
I must be too dumb to understand the mess MSVC (32bit only) did with the
previous loop, and to figure out how it might have make it never end.
Anyway, hopefully any compiler can grok this new loop...
2018-12-12 15:15:43 +01:00
ylavic
055f1fa61e Add less than operator to Pointer.
Allows to sort pointers in (std-)containers and/or index by them.
2018-12-10 22:02:25 +01:00
Milo Yip
66eb6067b1
Merge pull request #1425 from ylavic/filereadstream_peek4
Fix off by one in FileReadStream::Peek4()
2018-12-06 23:44:10 +08:00
Milo Yip
b4b0e13b4d
Merge pull request #1424 from ylavic/file_input_streams
Optimize FileReadStream and BasicIStreamWrapper.
2018-12-06 23:43:48 +08:00
ylavic
38d25d7458 Fix FileReadStream::Peek4().
Until Read() reaches EOF, Peek4() must not take off by one in
bufferLast_ into account; otherwise a buffer of size exactly 4 always
returns NULL.
2018-12-06 08:38:21 +01:00
ylavic
8aab3db129 Base buffered BasicIStreamWrapper on the original (better performing) FileReadStream algorithm. 2018-12-06 00:21:05 +01:00
ylavic
2498c5776f Optimize FileReadStream and BasicIStreamWrapper.
On (my) linux, perftest reports:
- ~40% gain for FileReadStream (Take() loop),
- ~10% gain for ReaderParse_DummyHandler_FileReadStream.

With the same logic applied to BasicIStreamWrapper, which thus can now
also be created with a user buffer, performances align with those of
FileReadStream (same buffer size).

The "unbuffered" versions (added for FileReadStream) work solely with
the internal peekBuffer (Ch[4]) and are measured in perftest.  When
performances don't matter much, they can avoid the use of large
stack/heap buffers.
2018-12-05 16:43:54 +01:00
ylavic
be96f4d7fb GenericRegex: don't throw/abort on syntax error (unclosed parenthesis). 2018-12-03 11:42:29 +01:00
Milo Yip
30d92a6399
Merge pull request #1413 from ylavic/schema_regex_leak
Fix a memory leak for invalid std::regex in Schema.
2018-12-03 09:53:39 +08:00
ylavic
3e6956767e Fix a memory leak for invalid std::regex in Schema. 2018-12-01 23:36:45 +01:00
ylavic
b0c96f9baf Use passed in allocator for internal regex parser. 2018-12-01 22:02:48 +01:00
Jean-Claude Monnin
51ca982aa1 Fix warning when NDEBUG is defined [-Wunused-variable]
Because `isPeek()` is side effect free this should not change anything.

The reason this warning is not shown in the unit tests is because the asserts
are always evaluated in the unit test:

#define RAPIDJSON_ASSERT(x) (!(x) ? throw AssertException(RAPIDJSON_STRINGIFY(x)) : (void)0u)
2018-11-21 13:24:06 +01:00