2217 Commits

Author SHA1 Message Date
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
seky
d0188462d9 removed std::string and receiving const Value in printIt 2018-12-05 08:24:59 +01:00
seky
c9060b4a5c added example for sorting keys 2018-12-04 22:40:40 +01:00
ylavic
8c14787398 Unit test for invalid GenericRegex (unclosed parenthesis). 2018-12-03 11:49:34 +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
Milo Yip
1c5b90f409
Merge pull request #1414 from ylavic/regex_allocator
Use passed in allocator for internal regex parser.
2018-12-03 09:51:50 +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
Milo Yip
a63216054d
Merge pull request #1388 from yhager/yhager/clang-7
silence clang-7 self-assign-overloaded warning
2018-11-22 12:30:02 +08:00
Milo Yip
595ed48d54
Merge pull request #1403 from jcmonnin/fix-warning
Fix warning when NDEBUG is defined [-Wunused-variable]
2018-11-22 12:22:41 +08: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
Philipp A. Hartmann
0cc44c82c9
Update test/unittest/pointertest.cpp
Co-Authored-By: yhager <yhager@users.noreply.github.com>
2018-10-31 20:31:04 -07:00
Yuval Hager
a77b49dcb8 silence clang-7 self-assign-overloaded warning 2018-10-26 14:58:57 -07:00
Milo Yip
67fac85e96
Merge pull request #1373 from lelit/issue1368
Add test case on kParseNumbersAsStringsFlag being able to load big ints
2018-10-09 00:20:35 +08:00
Lele Gaifax
91d50c849d Add test case on kParseNumbersAsStringsFlag being able to load big ints
See issue #1368.
2018-10-08 10:21:25 +02:00
Konstantin Käfer
16872af889 Avoid pointer arithmetic on null pointer to remove undefined behavior
The existing checks triggered undefined behavior when the stack was empty (null pointer). This change avoid this:
* If `stackTop_` and `stackEnd_` are null, it results in a `ptrdiff_t` of `0`
* If `stackTop_` and `stackEnd_` are valid pointers, they produce a `ptrdiff_t` with the remaining size on the stack
2018-10-05 09:26:20 +02:00
Milo Yip
663f076c7b
Merge pull request #1362 from jiapengwen/master
fix tutorial error
2018-09-19 12:58:56 +08:00
Milo Yip
2a5e733b6f
Merge pull request #1364 from jcourtat/fixfaq
faq: fix document insertion example
2018-09-19 12:58:14 +08:00
Julien Courtat
68349ed914 faq: fix document insertion example
GenericDocument contructor requires a pointer to an Allocator, but GetAllocator() only
returns a reference.

Signed-off-by: Julien Courtat <julien.courtat@aqsacom.com>
2018-09-18 14:51:12 +02:00
jiapeng.wen
1cfa861d4c fix tutorial error 2018-09-18 10:51:16 +08:00
Milo Yip
c0ca05f6dd
Merge pull request #1329 from pah/fix-noexcept
Add RAPIDJSON_NOEXCEPT_ASSERT
2018-09-11 10:13:09 +08:00
Milo Yip
c2aa79dc88
Merge pull request #1356 from gongminmin/AppVeyor2017
Update appveyor rule to support VS2017.
2018-09-10 16:59:39 +08:00
Milo Yip
783b819e67
Update rapidjson.h 2018-09-10 13:11:17 +08:00
Minmin Gong
a6be583efa Update appveyor rule to support VS2017. 2018-09-09 20:58:02 -07:00
Milo Yip
8a96a95de2
Merge branch 'master' into fix-noexcept 2018-09-10 11:27:45 +08:00
Milo Yip
f5f6052c56
Merge pull request #1327 from gongminmin/FixCompileInVS
Fix the compiling problems in VS
2018-09-10 11:23:26 +08:00
Milo Yip
08b1a8a41e
Merge pull request #1302 from chwarr/min-max-guard
Guard against min/max being macros in reader.h
2018-09-10 11:22:28 +08:00
Milo Yip
81af404b7f
Merge pull request #1284 from mobileben/noexcept-assert
Handle non-throwing exception specifications that can still throw #1280
2018-09-10 11:21:34 +08:00
Milo Yip
73063f5002
Merge pull request #1340 from lelit/issue1336
Wrap all WriteXxx() calls within EndValue()
2018-08-05 19:01:46 +08:00
Lele Gaifax
c9eabf9e13 Extend the test on issue #1336 to cover all basic types 2018-08-05 09:44:15 +02:00
Lele Gaifax
3fc9299b84 Add simple test for issue #1336 2018-08-03 12:34:03 +02:00
Lele Gaifax
11defb7aa4 Wrap all WriteXxx() calls within EndValue(), to ensure a flush after root-level scalar value
This attempts to fix issue #1336.
2018-08-03 12:17:29 +02:00
Milo Yip
6a905f9311
Merge pull request #1331 from JPEWdev/mem-alignment-fix
Fix SIGBUS due to unaligned access
2018-08-01 11:56:25 +08:00
Milo Yip
91df56313b
Merge pull request #1335 from IceTrailer/master
Fixed parentheses in reader.h which were required to prevent the using of max macro
2018-08-01 11:55:44 +08:00
IceTrailer
cd28248611 Fixed parentheses in reader.h which were required to prevent the using of max macro 2018-07-31 22:23:53 +02:00
Veselin Georgiev
748a652f04 Fix SIGBUS due to unaligned access
Update RAPIDJSON_ALIGN() to always align on an 8-byte boundary
unless otherwise overridden.

On some platforms (such as ARM), 64-bit items (such as doubles and
64-bit integers) must be aligned to an 8 byte address, even though the
architecture is only 32-bits. On these platforms, MemoryPoolAllocator
must match the malloc() behavior and return a 8 byte aligned allocation.
This eliminates any alignment issues that may occur at the expense of
additional memory overhead.

Failure to do so caused a SIGBUS signal when calling
GenericValue::SetNull(). The size of the data_ member of the
GenericValue class is 16 bytes in 32-bit mode and its constructor
requires an 8-byte aligned access.

While parsing a JSON formatted string using Document::ParseStream(), a
stack object containing GenericValue items was constructed. Since the
stack was 8-byte aligned, the constructor calls would succeed. When the
lifetime of the object ends, SetObjectRaw() is invoked. This triggered
an allocation with 4-byte alignment to which the previously 8-byte
aligned GenericValue array was copied. After this, any call to a
GenericValue API that triggered the constructor and thus the placement
new operation on the Data type member would trigger a SIGBUS.

Signed-off-by: Veselin Georgiev <veselin.georgiev@garmin.com>
Signed-off-by: Joshua Watt <Joshua.Watt@garmin.com>
2018-07-31 09:02:26 -05:00
Philipp A Hartmann
f54f6b5aa9 Add RAPIDJSON_NOEXCEPT_ASSERT
This is an alternative implementation to #1284 to handle
asserts in noexcept contexts.

Closes #1280.
2018-07-18 12:02:24 +02:00
Minmin Gong
ff76343336 Update the code to adapt the new gtest. 2018-07-16 20:36:20 -07:00
Milo Yip
2bbd33b332
Merge pull request #1323 from pah/fix-memaccess
Fix warnings/errors on GCC 7/8 (-Wclass-memaccess, -Wsign-conversion, -Wformat-overflow)
2018-07-16 12:22:46 +08:00
Philipp A Hartmann
152511689b Suppress -Wformat-overflow warning/error
GCC 7 and later warn about overflow/truncation when using
sprintf and related functions with fixed-size buffers.

Suppress the warning in schematest.cpp.
2018-07-15 16:02:03 +02:00
Philipp A Hartmann
a26267d16d Fix -Wsign-conversion warnings/errors
GCC 8 (incorrectly) warns about sign conversions in (constant)
array size expressions:

error: conversion to 'long unsigned int' from 'int' may
change the sign of the result [-Werror=sign-conversion]
     char schemaBuffer_[128 * 1024];

Make these expressions unsigned by adding a 'u' suffix to
the first operands.
2018-07-15 16:01:02 +02:00
Philipp A Hartmann
fa5963a2f5 Fix -Wclass-memaccess warnings/errors
Recent GCC versions warn about using memcpy/memmove to
write to a class pointer (-Wclass-memaccess).

Avoid the warnings by casting to void* first.

Closes #1086.
Closes #1205.
Closes #1246.
2018-07-15 14:20:38 +02:00
Milo Yip
4b4583bdbe
Merge pull request #1320 from AnomalRoil/master
Removing always true if condition
2018-07-12 23:31:19 +08:00
Yolan Romailler
93331cb0cd Removing always true if condition 2018-07-12 15:13:19 +02:00
Christopher Warrington
960b9cfd19 Guard against min/max being macros in reader.h
Sometimes, particularly when Microsoft's windows.h is included, min/max
are defined as macros, interfering with use of
std::numeric_limits::min() and the like.

To guard against this, the function name is wrapped in an extra set of
parenthesis, which inhibits function-style macro expansion.

This is a similar commit to 6e38649ec6, but fixes uses of
std::numeric_limits added after that commit, like those introduced in
2ea43433e2.
2018-07-10 11:08:41 -07:00
Milo Yip
129d19ba7f
Merge pull request #1312 from erikfroseth/issue-1308
Detect C++11 features for Developer Studio
2018-07-03 20:28:24 +08:00
Erik Froseth
3e255af03a Detect C++11 features for Developer Studio
This patch enables various C++11 features if the code is compiled with
Developer Studio compiler version 5.14 or higher.
2018-07-03 13:02:45 +02:00
Milo Yip
b81438ea96
Merge pull request #1307 from moretromain/preprocessor_cleanup
Rename a few internal preprocessor macros to avoid naming conflicts
2018-07-03 10:34:32 +08:00
Tim Miller
fdd2db930f Updated google test to latest commit 2018-07-02 08:30:17 -04:00