diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h index 2d42412..b60e84b 100644 --- a/include/rapidjson/pointer.h +++ b/include/rapidjson/pointer.h @@ -42,61 +42,25 @@ public: SizeType index; //!< A valid index if not equal to kPointerInvalidIndex. }; - GenericPointer() : - allocator_(), - ownAllocator_(), - nameBuffer_(), - tokens_(), - tokenCount_(), - parseErrorOffset_(), - parseErrorCode_(kPointerParseErrorNone) - { - } + GenericPointer() : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {} - explicit GenericPointer(const Ch* source, Allocator* allocator = 0) : - allocator_(allocator), - ownAllocator_(), - nameBuffer_(), - tokens_(), - tokenCount_(), - parseErrorOffset_(), - parseErrorCode_(kPointerParseErrorNone) - { + explicit GenericPointer(const Ch* source, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) { Parse(source, internal::StrLen(source)); } - GenericPointer(const Ch* source, size_t length, Allocator* allocator = 0) : - allocator_(allocator), - ownAllocator_(), - nameBuffer_(), - tokens_(), - tokenCount_(), - parseErrorOffset_(), - parseErrorCode_(kPointerParseErrorNone) - { +#if RAPIDJSON_HAS_STDSTRING + explicit GenericPointer(const std::basic_string& source, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) { + Parse(source.c_str(), source.size()); + } +#endif + + GenericPointer(const Ch* source, size_t length, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) { Parse(source, length); } - GenericPointer(const Token* tokens, size_t tokenCount) : - allocator_(), - ownAllocator_(), - nameBuffer_(), - tokens_(const_cast(tokens)), - tokenCount_(tokenCount), - parseErrorOffset_(), - parseErrorCode_(kPointerParseErrorNone) - { - } + GenericPointer(const Token* tokens, size_t tokenCount) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(const_cast(tokens)), tokenCount_(tokenCount), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {} - GenericPointer(const GenericPointer& rhs) : - allocator_(), - ownAllocator_(), - nameBuffer_(), - tokens_(), - tokenCount_(), - parseErrorOffset_(), - parseErrorCode_(kPointerParseErrorNone) - { + GenericPointer(const GenericPointer& rhs) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) { *this = rhs; } @@ -255,9 +219,7 @@ public: return v; } - const ValueType* Get(const ValueType& root) const { - return Get(const_cast(root)); - } + const ValueType* Get(const ValueType& root) const { return Get(const_cast(root)); } ValueType& GetWithDefault(ValueType& root, const ValueType& defaultValue, typename ValueType::AllocatorType& allocator) const { bool alreadyExist; @@ -284,6 +246,18 @@ public: return v; } +#if RAPIDJSON_HAS_STDSTRING + ValueType& GetWithDefault(ValueType& root, const std::basic_string& defaultValue, typename ValueType::AllocatorType& allocator) const { + bool alreadyExist; + Value& v = Create(root, allocator, &alreadyExist); + if (!alreadyExist) { + Value clone(defaultValue, allocator); // This has overhead, so do it inside if. + v = clone; + } + return v; + } +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) GetWithDefault(ValueType& root, T defaultValue, typename ValueType::AllocatorType& allocator) const { @@ -306,6 +280,13 @@ public: return GetWithDefault(root, defaultValue, root.GetAllocator()); } +#if RAPIDJSON_HAS_STDSTRING + template + ValueType& GetWithDefault(GenericDocument& root, const std::basic_string& defaultValue) const { + return GetWithDefault(root, defaultValue, root.GetAllocator()); + } +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) GetWithDefault(GenericDocument& root, T defaultValue) const { @@ -332,6 +313,13 @@ public: return Create(root, allocator) = v; } +#if RAPIDJSON_HAS_STDSTRING + ValueType& Set(ValueType& root, const std::basic_string& value, typename ValueType::AllocatorType& allocator) const { + ValueType v(value, allocator); + return Create(root, allocator) = v; + } +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) Set(ValueType& root, T value, typename ValueType::AllocatorType& allocator) const { @@ -351,21 +339,25 @@ public: template ValueType& Set(GenericDocument& root, GenericStringRef value) const { - ValueType v(value); - return Create(root) = v; + return Create(root) = value; } template ValueType& Set(GenericDocument& root, const Ch* value) const { - ValueType v(value, root.GetAllocator()); - return Create(root) = v; + return Create(root) = ValueType(value, root.GetAllocator()).Move(); } +#if RAPIDJSON_HAS_STDSTRING + template + ValueType& Set(GenericDocument& root, const std::basic_string& value) const { + return Create(root) = ValueType(value, root.GetAllocator()).Move(); + } +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (ValueType&)) Set(GenericDocument& root, T value) const { - ValueType v(value); - return Create(root) = v; + return Create(root) = value; } // Create parents if non-exist @@ -628,8 +620,7 @@ typename T::ValueType& CreateValueByPointer(T& root, const GenericPointer typename T::ValueType& CreateValueByPointer(T& root, const CharType(&source)[N], typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return CreateValueByPointer(root, pointer, a); + return GenericPointer(source, N - 1).Create(root, a); } // No allocator parameter @@ -641,8 +632,7 @@ typename T::ValueType& CreateValueByPointer(T& root, const GenericPointer typename T::ValueType& CreateValueByPointer(T& root, const CharType(&source)[N]) { - const GenericPointer pointer(source, N - 1); - return CreateValueByPointer(root, pointer); + return GenericPointer(source, N - 1).Create(root); } ////////////////////////////////////////////////////////////////////////////// @@ -659,14 +649,12 @@ const typename T::ValueType* GetValueByPointer(const T& root, const GenericPoint template typename T::ValueType* GetValueByPointer(T& root, const CharType (&source)[N]) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointer(root, pointer); + return GenericPointer(source, N - 1).Get(root); } template const typename T::ValueType* GetValueByPointer(const T& root, const CharType(&source)[N]) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointer(root, pointer); + return GenericPointer(source, N - 1).Get(root); } ////////////////////////////////////////////////////////////////////////////// @@ -686,6 +674,13 @@ typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointe return pointer.GetWithDefault(root, defaultValue, a); } +#if RAPIDJSON_HAS_STDSTRING +template +typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer& pointer, const std::basic_string& defaultValue, typename T::AllocatorType& a) { + return pointer.GetWithDefault(root, defaultValue, a); +} +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) GetValueByPointerWithDefault(T& root, const GenericPointer& pointer, T2 defaultValue, typename T::AllocatorType& a) { @@ -694,27 +689,30 @@ GetValueByPointerWithDefault(T& root, const GenericPointer typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::ValueType& defaultValue, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointerWithDefault(root, pointer, defaultValue, a); + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); } template typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], GenericStringRef defaultValue, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointerWithDefault(root, pointer, defaultValue, a); + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); } template typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::Ch* defaultValue, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointerWithDefault(root, pointer, defaultValue, a); + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); } +#if RAPIDJSON_HAS_STDSTRING +template +typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const std::basic_string& defaultValue, typename T::AllocatorType& a) { + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); +} +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) GetValueByPointerWithDefault(T& root, const CharType(&source)[N], T2 defaultValue, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointerWithDefault(root, pointer, defaultValue, a); + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue, a); } // No allocator parameter @@ -734,6 +732,13 @@ typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointe return pointer.GetWithDefault(root, defaultValue); } +#if RAPIDJSON_HAS_STDSTRING +template +typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer& pointer, const std::basic_string& defaultValue) { + return pointer.GetWithDefault(root, defaultValue); +} +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) GetValueByPointerWithDefault(T& root, const GenericPointer& pointer, T2 defaultValue) { @@ -742,27 +747,30 @@ GetValueByPointerWithDefault(T& root, const GenericPointer typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::ValueType& defaultValue) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointerWithDefault(root, pointer, defaultValue); + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue); } template typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], GenericStringRef defaultValue) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointerWithDefault(root, pointer, defaultValue); + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue); } template typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::Ch* defaultValue) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointerWithDefault(root, pointer, defaultValue); + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue); } +#if RAPIDJSON_HAS_STDSTRING +template +typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const std::basic_string& defaultValue) { + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue); +} +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) GetValueByPointerWithDefault(T& root, const CharType(&source)[N], T2 defaultValue) { - const GenericPointer pointer(source, N - 1); - return GetValueByPointerWithDefault(root, pointer, defaultValue); + return GenericPointer(source, N - 1).GetWithDefault(root, defaultValue); } ////////////////////////////////////////////////////////////////////////////// @@ -782,6 +790,13 @@ typename T::ValueType& SetValueByPointer(T& root, const GenericPointer +typename T::ValueType& SetValueByPointer(T& root, const GenericPointer& pointer, const std::basic_string& value, typename T::AllocatorType& a) { + return pointer.Set(root, value, a); +} +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) SetValueByPointer(T& root, const GenericPointer& pointer, T2 value, typename T::AllocatorType& a) { @@ -790,27 +805,30 @@ SetValueByPointer(T& root, const GenericPointer& pointer, template typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return SetValueByPointer(root, pointer, value, a); + return GenericPointer(source, N - 1).Set(root, value, a); } template typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], GenericStringRef value, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return SetValueByPointer(root, pointer, value, a); + return GenericPointer(source, N - 1).Set(root, value, a); } template typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const typename T::Ch* value, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return SetValueByPointer(root, pointer, value, a); + return GenericPointer(source, N - 1).Set(root, value, a); } +#if RAPIDJSON_HAS_STDSTRING +template +typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const std::basic_string& value, typename T::AllocatorType& a) { + return GenericPointer(source, N - 1).Set(root, value, a); +} +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) SetValueByPointer(T& root, const CharType(&source)[N], T2 value, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return SetValueByPointer(root, pointer, value, a); + return GenericPointer(source, N - 1).Set(root, value, a); } // No allocator parameter @@ -830,6 +848,13 @@ typename T::ValueType& SetValueByPointer(T& root, const GenericPointer +typename T::ValueType& SetValueByPointer(T& root, const GenericPointer& pointer, const std::basic_string& value) { + return pointer.Set(root, value); +} +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) SetValueByPointer(T& root, const GenericPointer& pointer, T2 value) { @@ -838,27 +863,30 @@ SetValueByPointer(T& root, const GenericPointer& pointer, template typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value) { - const GenericPointer pointer(source, N - 1); - return SetValueByPointer(root, pointer, value); + return GenericPointer(source, N - 1).Set(root, value); } template typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], GenericStringRef value) { - const GenericPointer pointer(source, N - 1); - return SetValueByPointer(root, pointer, value); + return GenericPointer(source, N - 1).Set(root, value); } template typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const typename T::Ch* value) { - const GenericPointer pointer(source, N - 1); - return SetValueByPointer(root, pointer, value); + return GenericPointer(source, N - 1).Set(root, value); } +#if RAPIDJSON_HAS_STDSTRING +template +typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const std::basic_string& value) { + return GenericPointer(source, N - 1).Set(root, value); +} +#endif + template RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr, internal::IsGenericValue >), (typename T::ValueType&)) SetValueByPointer(T& root, const CharType(&source)[N], T2 value) { - const GenericPointer pointer(source, N - 1); - return SetValueByPointer(root, pointer, value); + return GenericPointer(source, N - 1).Set(root, value); } ////////////////////////////////////////////////////////////////////////////// @@ -870,8 +898,7 @@ typename T::ValueType& SwapValueByPointer(T& root, const GenericPointer typename T::ValueType& SwapValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) { - const GenericPointer pointer(source, N - 1); - return SwapValueByPointer(root, pointer, value, a); + return GenericPointer(source, N - 1).Swap(root, value, a); } template @@ -881,8 +908,7 @@ typename T::ValueType& SwapValueByPointer(T& root, const GenericPointer typename T::ValueType& SwapValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value) { - const GenericPointer pointer(source, N - 1); - return SwapValueByPointer(root, pointer, value); + return GenericPointer(source, N - 1).Swap(root, value); } RAPIDJSON_NAMESPACE_END diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 6a776ec..1ff88b1 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -22,6 +22,8 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) endif() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRAPIDJSON_HAS_STDSTRING=1") + add_library(namespacetest STATIC namespacetest.cpp) add_executable(unittest ${UNITTEST_SOURCES}) diff --git a/test/unittest/pointertest.cpp b/test/unittest/pointertest.cpp index 3a6742e..417893a 100644 --- a/test/unittest/pointertest.cpp +++ b/test/unittest/pointertest.cpp @@ -53,6 +53,16 @@ TEST(Pointer, Parse) { EXPECT_STREQ("foo", p.GetTokens()[0].name); } + #if RAPIDJSON_HAS_STDSTRING + { + Pointer p(std::string("/foo")); + EXPECT_TRUE(p.IsValid()); + EXPECT_EQ(1u, p.GetTokenCount()); + EXPECT_EQ(3u, p.GetTokens()[0].length); + EXPECT_STREQ("foo", p.GetTokens()[0].name); + } + #endif + { Pointer p("/foo/0"); EXPECT_TRUE(p.IsValid()); @@ -611,6 +621,10 @@ TEST(Pointer, GetWithDefault) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + EXPECT_STREQ("C++", Pointer("/foo/C++").GetWithDefault(d, std::string("C++"), a).GetString()); +#endif } TEST(Pointer, GetWithDefault_NoAllocator) { @@ -659,6 +673,10 @@ TEST(Pointer, GetWithDefault_NoAllocator) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + EXPECT_STREQ("C++", Pointer("/foo/C++").GetWithDefault(d, std::string("C++")).GetString()); +#endif } TEST(Pointer, Set) { @@ -709,6 +727,11 @@ TEST(Pointer, Set) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + Pointer("/foo/c++").Set(d, std::string("C++"), a); + EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString()); +#endif } TEST(Pointer, Set_NoAllocator) { @@ -758,6 +781,11 @@ TEST(Pointer, Set_NoAllocator) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + Pointer("/foo/c++").Set(d, std::string("C++")); + EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString()); +#endif } TEST(Pointer, Swap) { @@ -864,6 +892,10 @@ TEST(Pointer, GetValueByPointerWithDefault_Pointer) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, Pointer("/foo/world"))->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + EXPECT_STREQ("C++", GetValueByPointerWithDefault(d, Pointer("/foo/C++"), std::string("C++"), a).GetString()); +#endif } TEST(Pointer, GetValueByPointerWithDefault_String) { @@ -913,6 +945,10 @@ TEST(Pointer, GetValueByPointerWithDefault_String) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + EXPECT_STREQ("C++", GetValueByPointerWithDefault(d, "/foo/C++", std::string("C++"), a).GetString()); +#endif } TEST(Pointer, GetValueByPointerWithDefault_Pointer_NoAllocator) { @@ -961,6 +997,10 @@ TEST(Pointer, GetValueByPointerWithDefault_Pointer_NoAllocator) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, Pointer("/foo/world"))->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + EXPECT_STREQ("C++", GetValueByPointerWithDefault(d, Pointer("/foo/C++"), std::string("C++")).GetString()); +#endif } TEST(Pointer, GetValueByPointerWithDefault_String_NoAllocator) { @@ -1009,6 +1049,10 @@ TEST(Pointer, GetValueByPointerWithDefault_String_NoAllocator) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + EXPECT_STREQ("C++", GetValueByPointerWithDefault(d, Pointer("/foo/C++"), std::string("C++")).GetString()); +#endif } TEST(Pointer, SetValueByPointer_Pointer) { @@ -1056,6 +1100,11 @@ TEST(Pointer, SetValueByPointer_Pointer) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + SetValueByPointer(d, Pointer("/foo/c++"), std::string("C++"), a); + EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString()); +#endif } TEST(Pointer, SetValueByPointer_String) { @@ -1103,6 +1152,11 @@ TEST(Pointer, SetValueByPointer_String) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + SetValueByPointer(d, "/foo/c++", std::string("C++"), a); + EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString()); +#endif } TEST(Pointer, SetValueByPointer_Pointer_NoAllocator) { @@ -1149,6 +1203,11 @@ TEST(Pointer, SetValueByPointer_Pointer_NoAllocator) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + SetValueByPointer(d, Pointer("/foo/c++"), std::string("C++")); + EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString()); +#endif } TEST(Pointer, SetValueByPointer_String_NoAllocator) { @@ -1195,6 +1254,11 @@ TEST(Pointer, SetValueByPointer_String_NoAllocator) { memset(buffer, 0, sizeof(buffer)); } EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString()); + +#if RAPIDJSON_HAS_STDSTRING + SetValueByPointer(d, "/foo/c++", std::string("C++")); + EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString()); +#endif } TEST(Pointer, SwapValueByPointer) {