1. 29 Jun, 2014 12 commits
  2. 28 Jun, 2014 3 commits
  3. 27 Jun, 2014 5 commits
  4. 26 Jun, 2014 17 commits
  5. 25 Jun, 2014 3 commits
    • Philipp A. Hartmann's avatar
      valuetest: add deep copy unit test · 65b4316d
      Philipp A. Hartmann authored
      This commit adds some simple tests for the deep-copying
      of values, either based on the explicit constructor, or
      the CopyFrom function.
      
      It uses the CrtAllocator to test for possible double-free
      errors due to insufficient copying.
      65b4316d
    • Philipp A. Hartmann's avatar
      GenericValue: add copy constructor and CopyFrom · 8bde3be1
      Philipp A. Hartmann authored
      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.
      8bde3be1
    • Philipp A. Hartmann's avatar
      GenericDocument::Accept: deep-copy strings, if needed · a0e5e68f
      Philipp A. Hartmann authored
      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.
      a0e5e68f