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.
* Safely assert upon passing NULL string without length
(requires usage of RAPIDJSON_ASSERT within an expression)
* Allow using a NULL string together with an explicit length 0
(GenericStringRef, GenericValue::SetString, ...), see #817
* Add GenericValue::SetString(StringRefType, Allocator&) overload
* Add tests for the various cases
* Use safe-bool idiom for boolean conversion to avoid accidental
misuse of ParseResult values (closes#989)
* Add operator!= to support more comparison expressions
(previously silently/erroneously used operator bool)
As reported by @Llerd in #962, the `copyConstStrings` parameter
has not been forwarded recursively to the constructors of
object members and array elements.
Copying the result of an in-situ parsing into another value/document
currently requires that the original buffer - still holding the strings
from the parsing, outlives the destination object as well.
In order to obtain a "full" copy of a GenericValue, this commit adds
an optional flag `copyConstStrings` to `CopyFrom`, which then forces
to take a copy of all embedded strings in the source value.
This solves the problem discussed in #962.
This is helpful if you’re writing code that needs to control flush
behavior and you don’t want to pass around your buffer object to each
handler function alongside the writer. Seems like an easy convenience
to add.
Assert in case users attempt to pass a char array to String() or Key()
that is not null terminated; that is not the intended use of the API.
Null terminate your string buffers.
No strlen call needs to be made when templates can auto-deduce the
string length. No strlen = faster!
Unfortunately this needs a touch of SFINAE to allow multiple overrides
to coexist cleanly.
Documented existing assertions in EndObject
Added new assertion in EndObject to catch error condition where objects
are ended with a key but no matching value.