252 Commits

Author SHA1 Message Date
Milo Yip
9fe18f71c1 Add Document::Parse() overloads 2016-02-15 17:15:27 +08:00
Milo Yip
49c982b4b7 Fix C++03 compilation error about sizeof() 2016-02-15 12:19:30 +08:00
Milo Yip
4bb6f2c089 Fix compilation errors on 32-bit gcc/clang 2016-02-15 11:39:32 +08:00
Milo Yip
e731726c56 Optimize memory consumption with RAPIDJSON_48BITPOINTER_OPTIMIZATION
#330
2016-02-15 11:20:00 +08:00
Milo Yip
6671bd50f1 Fix another compilation error 2016-02-14 14:07:19 +08:00
Milo Yip
be66450ecd Fix compilation errors 2016-02-14 14:00:27 +08:00
Milo Yip
1634395378 Add object helper 2016-02-14 13:49:52 +08:00
Milo Yip
923db0e641 Fix gcc compilation error 2016-02-14 06:14:12 +08:00
Milo Yip
effc8a8f30 Let constness of GenericArray::ValueItaertor depending on ValueType 2016-02-14 00:12:04 +08:00
Milo Yip
0b098eb38d Rectify constness of Array 2016-02-13 22:09:14 +08:00
Milo Yip
59309b5dd2 Add GenericArray helper class with range-based for 2016-02-13 19:06:03 +08:00
Milo Yip
c6946fd2c1 Merge branch 'master' into issue316_templatedaccessors 2016-02-13 17:09:15 +08:00
Milo Yip
98ddfacdf1 Another try with volatile 2016-02-13 16:53:45 +08:00
Milo Yip
58d8d9ab9b Try fixing unit test in release configuration 2016-02-12 23:35:17 +08:00
Milo Yip
513fe7894e Add templated accessors for C string 2016-02-12 23:06:49 +08:00
Milo Yip
4d648fdcd8 Add templated accessors 2016-02-12 18:23:32 +08:00
Milo Yip
e61169e61a Fix Value::GetFloat() 2016-02-12 18:13:11 +08:00
Milo Yip
8b4c999888 Add Value::GetFloat(), Value::IsLossLessFloat/Double()
Fix #341
2016-02-12 16:33:31 +08:00
Milo Yip
d43f001a36 Fix #472 Template specialization failure with SunOS compiler 2016-02-02 22:59:27 +08:00
Milo Yip
556a8975bd Add RAPIDJSON_UNLIKELY in Value::Accept() 2016-01-31 01:33:47 +08:00
Milo Yip
05968b7031 Fix schema tests and added SchemaValidatingReader 2016-01-27 13:59:14 +08:00
Milo Yip
a6eb15d274 Fix warnings in clang for C++11 2016-01-23 14:37:15 +08:00
Milo Yip
6d6381f596 Try to fix clang and gcc warnings problems again x7 2015-12-18 20:15:11 +08:00
Milo Yip
9ce381b801 Try to fix clang and gcc warnings problems again 2015-12-18 19:15:51 +08:00
Milo Yip
17f2ca6913 Try to fix clang and gcc warnings problems 2015-12-18 19:04:09 +08:00
Milo Yip
74c8dcfd57 Fix clang -Weverything 2015-12-18 18:34:04 +08:00
Philipp A. Hartmann
98959e2820 GenericDocument: add implicit conversion to ParseResult
To simplify the error handling, this commit adds an implicit conversion
of GenericDocument to ParseResult, allowing code like (already in the
documentation):

   ParseResult ok = doc.Parse(json);
   if (!ok) // ...
2015-11-26 22:30:59 +01:00
Michael Haubenwallner
07672da098 fix Document::Parse(const Ch*) for transcoding
To allow for an UTF16-Document to Parse(UTF8),
the Parse() argument has to be UTF8-compatible.
2015-11-25 19:45:47 +01:00
etiennebatise
74a021346d Add break at default switch case statements
fix issue #444
2015-10-14 15:46:26 +02:00
Philipp A. Hartmann
fa123699d3 Keep Document value unchanged on parse error, fixes #437
Keeping the DOM unchanged in case of an error is the intended
behaviour according to the [documentation] [1].

Instead of forcing the value to `kNullType` before starting the
parsing, store the parsed value upon success via regular move.

[1]: https://miloyip.github.io/rapidjson/md_doc_dom.html#ParseError
2015-10-07 21:48:39 +02:00
Rodion Malinovsky
2e11498943 Fix the usage of the stack::GetAllocator 2015-09-16 14:54:38 +03:00
Rodion Malinovsky
8604ba0f1c Add asserts to prevent UB 2015-09-16 14:53:12 +03:00
Philipp A. Hartmann
fec9e8a4f2 prohibit C++11 move from Document to Value
As reported in #387, silently moving a `GenericDocument` to a
`GenericValue` can lead to object slicing and premature deletion of
the owning allocator of the (surviving) `GenericValue`.

To reduce this risk, prohibit move construction of a `GenericValue`
from a `GenericDocument`.
2015-07-17 08:24:43 +02:00
Milo Yip
823b731896 Merge pull request #376 from pah/feature/document-swap
add GenericDocument<>::Swap with std::swap() support
2015-07-13 21:14:02 +08:00
Philipp A. Hartmann
c2b5864927 add documentation for 'swap' friend functions 2015-07-13 14:38:24 +02:00
Philipp A. Hartmann
46e1696316 add free inline swap functions 2015-07-13 09:35:15 +02:00
Philipp A. Hartmann
0ebe16e169 add and use simplified "internal::Swap"
This avoids the dependency on the <algorithm> header, as suggested by
@miloyip in #376.
2015-07-10 17:06:52 +02:00
Philipp A. Hartmann
dd901f498b add GenericDocument<>::Swap
See #368.
2015-07-04 01:57:24 +02:00
Mateusz Łoskot
8197805208 Add explicit specifier to GenericDocument ctor.
@pah recommended to mark this constructor as explicit to avoid accidentally creating a temporary GenericDocument from a Type enum value (because all arguments but the first one are optional).
2015-07-01 22:36:26 +02:00
Mateusz Loskot
a0177ca210 Add documentation for new GenericDocument ctor taking object type.
Update also documentation of the existing GenericDocument constructor.
2015-06-30 10:28:07 +02:00
Mateusz Loskot
413144a8b2 Add GenericDocument ctor overload to specify JSON type.
It unifies the interfaces with Value where kXXXType can be passed
into constructor.
It enables shortcut that helps to avoid extra SetXXX() call following
construction of a document.
2015-06-26 16:00:49 +02:00
miloyip
6e1d10ec6b Add GenericValue::EraseMember(string types) APIs 2015-05-21 16:12:33 +08:00
miloyip
2786103abd Add Value::XXXMember(...) overloads for std::string 2015-05-12 22:48:14 +08:00
miloyip
98b66e3c5a Change Document::ParseStream() to use stack allocator for Reader 2015-05-11 13:58:02 +08:00
miloyip
56568fd73f Add GenericValue::ValueType and fix warning for SetString(std::string, Allocator) 2015-05-04 10:25:31 +08:00
Milo Yip
4cd14b7c0e Merge pull request #305 from pah/fix/strict-memcpy
Avoid calling memcpy with NULL pointers
2015-04-17 12:28:37 +08:00
Philipp A. Hartmann
0c5c1538dc Avoid calling memcpy with NULL pointers
According to the C/C++ standards, calling `memcpy(NULL, NULL, 0)` is
undefined behaviour. Recent GCC versions may rely on this by optimizing
NULL pointer checks more aggressively, see [1].

This patch tries to avoid calling std::memcpy with zero elements.
As a side effect, explicitly return NULL when requesting an empty block
from MemoryPoolAllocator::Malloc.

This may be related to #301.

[1] https://gcc.gnu.org/gcc-4.9/porting_to.html
2015-04-16 21:05:08 +02:00
miloyip
76d67b7eae Improves coverage of Value::Accept() 2015-04-15 12:16:16 +08:00
miloyip
04011cdae2 Adjust spaces 2015-04-13 22:46:27 +08:00
miloyip
2d07198863 Fix compilation 2015-04-13 18:24:10 +08:00