From 1b9cab7f12cff1b820bce66afa6ed887314b788e Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Fri, 10 Apr 2015 21:40:18 +0800 Subject: [PATCH] Try to fix more gcc/clang compilation errors --- include/rapidjson/pointer.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h index 99a4c1a..2000b21 100644 --- a/include/rapidjson/pointer.h +++ b/include/rapidjson/pointer.h @@ -26,7 +26,7 @@ public: typedef typename EncodingType::Ch Ch; struct Token { - const typename Ch* name; + const Ch* name; SizeType length; SizeType index; //!< A valid index if not equal to kInvalidIndex. }; @@ -149,11 +149,12 @@ public: ValueType* v = &root; bool exist = true; for (Token *t = tokens_; t != tokens_ + tokenCount_; ++t) { - if (v->GetType() != kObjectType && v->GetType() != kArrayType) + if (v->GetType() != kObjectType && v->GetType() != kArrayType) { if (t->index == kInvalidIndex) v->SetObject(); else v->SetArray(); + } switch (v->GetType()) { case kObjectType: @@ -220,8 +221,10 @@ public: ValueType& GetWithDefault(ValueType& root, const ValueType& defaultValue, typename ValueType::AllocatorType& allocator) const { bool alreadyExist; Value& v = Create(root, allocator, &alreadyExist); - if (!alreadyExist) - v = Value(defaultValue, allocator); + if (!alreadyExist) { + Value clone(defaultValue, allocator); + v = clone; + } return v; } @@ -332,7 +335,7 @@ typename T::ValueType& CreateValueByPointer(T& root, const GenericPointer typename T::ValueType& CreateValueByPointer(T& root, const CharType(&source)[N], typename T::AllocatorType& a) { - const Pointer pointer(source, N - 1); + const GenericPointer pointer(source, N - 1); return pointer.Create(root, a); } @@ -348,13 +351,13 @@ const typename T::ValueType* GetValueByPointer(const T& root, const GenericPoint template typename T::ValueType* GetValueByPointer(T& root, const CharType (&source)[N]) { - const Pointer pointer(source, N - 1); + const GenericPointer pointer(source, N - 1); return pointer.Get(root); } template const typename T::ValueType* GetValueByPointer(const T& root, const CharType(&source)[N]) { - const Pointer pointer(source, N - 1); + const GenericPointer pointer(source, N - 1); return pointer.Get(root); } @@ -365,7 +368,7 @@ typename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointe template typename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::ValueType& defaultValue, typename T::AllocatorType& a) { - const Pointer pointer(source, N - 1); + const GenericPointer pointer(source, N - 1); return pointer.GetWithDefault(root, defaultValue, a); } @@ -376,7 +379,7 @@ typename T::ValueType& SetValueByPointer(T& root, const GenericPointer typename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) { - const Pointer pointer(source, N - 1); + const GenericPointer pointer(source, N - 1); return pointer.Set(root, value , a); } @@ -387,7 +390,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 Pointer pointer(source, N - 1); + const GenericPointer pointer(source, N - 1); return pointer.Swap(root, value, a); }