In order to activate the suppression of "-Weffc++" warnings in the
template meta function classes (non-virtual destructor), move the
inclusion of the meta-function header `internal/meta.h` after the
suppression pragma.
Add dedicated class-based member iterator to prepare the switch to a
(safe) API change to return MemberEnd() from FindMember().
Pointer-based iterator can be kept by defining
RAPIDJSON_NOMEMBERITERATORCLASS. This may be useful for platforms without
a working <iterator> header.
Parse errors is represented as enum type `ParseErrorCode`.
Error texts are optional for user.
Added `GetParseError_En()` in `error/en.h`, user can localize this file
into other files. User may dynamically change the locale in runtime.
To allow deep copying from an existing GenericValue, an
explicit "copy constructor" (with required Allocator param)
and an "CopyFrom" assignment function are added.
Document d; Document::AllocatorType& a = d.GetAllocator();
Value v1("foo");
// Value v2(v1); // not allowed
Value v2(v1,a); // make a copy
RAPIDJSON_ASSERT(v1.IsString()); // v1 untouched
d.SetArray().PushBack(v1,a).PushBack(v2,a);
RAPIDJSON_ASSERT(v1.Empty() && v2.Empty());
v2.CopyFrom(d,a); // copy whole document
RAPIDJSON_ASSERT(d.IsArray() && d.Size()); // d untouched
v1.SetObject().AddMember( "array", v2, a );
d.PushBack(v1,a);
Additionally, the Handler implementation in GenericDocument is made
private again, restricting access to GenericReader and GenericValue.
Instead of always just shallowly referencing the potentially allocated
strings when calling the Handler::String function, request a copy in
case the string has been allocated from an Allocator before.
This is necessary to avoid double free()s of the string memory,
especially when using the Handler to create a deep copy of a Value.
The explicit comparison against '0' is done to suppress the warning
C4800 on MSVC, see pah/rapidjson#5.
The ParseStream() function current requires explicitly passing
the SourceEncoding parameter as explicit template argument
while the other Parse*() functions provide overloads to omit
this parameter and use the document's own encoding by default.
This patch adds the corresponding overload for ParseStream(),
enabling the simple usage again:
rapidjson::FileStream is(fp);
rapidjson::Document d;
d.ParseStream<0>(is);
In case of overloaded functions taking either a GenericValue or another
class that can also be constructed from the same primitive types
(e.g. std::string, which can be constructed from const char*), the
overloading becomes ambiguous:
void foo( const std::string& );
void foo( const rapidjson::Value & );
Declaring the GenericValue constructors taking primitive types as
'explicit' avoids this problem. This should not have any negative
side-effects, since a GenericValue can't be copied or implicitly
converted to other types.
Fixes http://code.google.com/p/rapidjson/issues/detail?id=70.
Constructing an empty GenericValue with a specific Type has failed
for any kNumberType (Int, Int64, Double...) due to incomplete definition
of the corresponding default flag value.
This patch adds a new constant kNumberAnyFlag to the flags enumeration
in GenericValue to cover this case.
This fixes http://code.google.com/p/rapidjson/issues/detail?id=57
The original FindMember() may access out-of-bound of the 'const char*
name' parameter.
This commit firstly follows
f86af8c232
However, this must incur an StrLen() for name. A better API is by using
Value as the name, which provides the length of string internally. So a
set of new API are added:
operator[](const GenericValue& name)
FindMember(const GenericValue& name)
RemoveMember(const GenericValue& name)
During refactoring, it also adds an API:
RemoveMember(MemberIterator m)
which can be used for other purpose, such as removing a member while
iterating an object.
Fixes#7
Makes GenericValue::FindMember() public.
Added array element and object member iteration APIs in examples.
git-svn-id: https://rapidjson.googlecode.com/svn/trunk@83 c5894555-1306-4e8d-425f-1f6f381ee07c