miloyip/rapidjson — pull request #20 by pah (2014-06-25 16:14:00+00:00)
Title: GenericValue: add copy constructor and CopyFrom

To allow deep copying from an existing `GenericValue`, an explicit "copy constructor" (with required Allocator param) and a `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);
````
The strings in the source value are copied, if and only if they have been allocated as a copy during their construction (determined by `kCopyFlag`). This is needed to avoid double `free()`s or problems with differing lifetimes of the allocated string storage.

Additionally, the `Handler` implementation in `GenericDocument` is made private again, restricting access to `GenericReader` and `GenericValue`.

(resubmitted #16 against `master`)