As discovered by @felipegb94, there are missing overloads to the
`GenericValue::AddMember<T>` template function, taking an explicit
`GenericValue&` as a name and accepting arbitrary primitive values.
This patch adds the missing overloads. The `StringRefType` overload
is needed to disambiguate the addition of a string literal as
value.
Some tests are added to `TEST(Value, Object)` in `valuetest.cpp`.
In C++'98/03, trailing commas in enumerations are not allowed, but have
been introduced in C++11. This patch drops the trailing commas in order
to avoid compiler warnings (e.g. GCC with -pedantic).
See #9 and http://code.google.com/p/rapidjson/issues/detail?id=49 for
previous instances of this issue.
The code goes to the trouble of ensuring that data is aligned at a
16-byte boundary, then goes ahead and uses the unaligned form of the
load intrinsic _mm_loadu_si128.
Either the code shouldn't bother aligning the data to the start of the
whitespace, or it should use the aligned form of the intrinsic.
The GenericValue "copy" constructor (with Allocator) uses a temporary
GenericDocument object to perform the deep copying with the provided
allocator. This leads to the temporary allocation of the `Stack`
memory, even in case of shallow values (numbers, etc.).
This patch improves the performance of this operation by only resorting
the the SAX Handler implementation in case of Array or Object values.
In order to make the constructors more efficient, especially
in the context of C++11 move semantics, the (dynamic) allocations
in MemoryPoolAllocator and Stack should be performed lazily.
Move the allocations to the first use of the allocator in both
classes.
As mentioned in #181, some environments may require adaptations to
the internal calls to the global `new`/`delete` operators, like
adding explicit `NULL` checks to `delete.
This patch adds two new macros
* RAPIDJSON_NEW(x)
* RAPIDJSON_DELETE(x)
to allow user-defined expressions in these cases.
This fixes#181 in an alternative manner.
In the original disambiguation fix for `GenericValue::operator[]` (#170),
the documentation has been missing, which led to quite badly rendered
Doxygen pages.
During a cleanup, I've realized that a much simpler disambiguation is
possible:
````cpp
GenericValue& operator[](SizeType idx); // array
template <typename T>
GenericValue& operator[](T* name); // object
````
This approach works, as non-template functions are preferred over
template functions.
In order to improve the error messages, the pointer type is restricted
to `(const) Ch`.
Update `tutorial.md` to drop the ambiguity warning.