diff options
| author | Josh Ferrell <josh@vector35.com> | 2020-08-24 21:58:03 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2020-10-28 18:53:24 -0400 |
| commit | 106a8a60c4f88cb45e3120544f05fb2ac48e6b28 (patch) | |
| tree | e5a71b6d91bbdfa3f64cdd2cbbd75abd5fe5d24e /rapidjson | |
| parent | be44532917b2458bb81ba838bce0a0d045957909 (diff) | |
rapidjson serialization
Diffstat (limited to 'rapidjson')
| -rw-r--r-- | rapidjson/allocators.h | 8 | ||||
| -rw-r--r-- | rapidjson/document.h | 14 | ||||
| -rw-r--r-- | rapidjson/fwd.h | 4 |
3 files changed, 18 insertions, 8 deletions
diff --git a/rapidjson/allocators.h b/rapidjson/allocators.h index 98affe03..68fc35d1 100644 --- a/rapidjson/allocators.h +++ b/rapidjson/allocators.h @@ -64,19 +64,19 @@ public: static const bool kNeedFree = true; void* Malloc(size_t size) { if (size) // behavior of malloc(0) is implementation defined. - return std::malloc(size); + return je_malloc(size); else return NULL; // standardize to returning NULL. } void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) { (void)originalSize; if (newSize == 0) { - std::free(originalPtr); + je_free(originalPtr); return NULL; } - return std::realloc(originalPtr, newSize); + return je_realloc(originalPtr, newSize); } - static void Free(void *ptr) { std::free(ptr); } + static void Free(void *ptr) { je_free(ptr); } }; /////////////////////////////////////////////////////////////////////////////// diff --git a/rapidjson/document.h b/rapidjson/document.h index e3e20dfb..f873c272 100644 --- a/rapidjson/document.h +++ b/rapidjson/document.h @@ -536,7 +536,7 @@ template <bool, typename> class GenericObject; \tparam Encoding Encoding of the value. (Even non-string values need to have the same encoding in a document) \tparam Allocator Allocator type for allocating memory of object, array and string. */ -template <typename Encoding, typename Allocator = MemoryPoolAllocator<> > +template <typename Encoding, typename Allocator = CrtAllocator > class GenericValue { public: //! Name-value pair in an object. @@ -1206,6 +1206,11 @@ public: return *this; } + GenericValue& AddMember(GenericValue& name, BinaryNinjaCore::string& value, Allocator& allocator) { + GenericValue v(value.data(), allocator); + return AddMember(name, v, allocator); + } + //! Add a constant string value as member (name-value pair) to the object. /*! \param name A string value as name of member. \param value constant string reference as value of member. @@ -1546,6 +1551,11 @@ public: return *this; } + GenericValue& PushBack(BinaryNinjaCore::string value, Allocator& allocator) { + GenericValue v(value.c_str(), allocator); + return PushBack(v, allocator); + } + #if RAPIDJSON_HAS_CXX11_RVALUE_REFS GenericValue& PushBack(GenericValue&& value, Allocator& allocator) { return PushBack(value, allocator); @@ -2020,7 +2030,7 @@ typedef GenericValue<UTF8<> > Value; \tparam StackAllocator Allocator for allocating memory for stack during parsing. \warning Although GenericDocument inherits from GenericValue, the API does \b not provide any virtual functions, especially no virtual destructor. To avoid memory leaks, do not \c delete a GenericDocument object via a pointer to a GenericValue. */ -template <typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator> +template <typename Encoding, typename Allocator = CrtAllocator, typename StackAllocator = CrtAllocator> class GenericDocument : public GenericValue<Encoding, Allocator> { public: typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding. diff --git a/rapidjson/fwd.h b/rapidjson/fwd.h index e8104e84..74f80de7 100644 --- a/rapidjson/fwd.h +++ b/rapidjson/fwd.h @@ -113,12 +113,12 @@ struct GenericStringRef; template <typename Encoding, typename Allocator> class GenericValue; -typedef GenericValue<UTF8<char>, MemoryPoolAllocator<CrtAllocator> > Value; +typedef GenericValue<UTF8<char>, CrtAllocator > Value; template <typename Encoding, typename Allocator, typename StackAllocator> class GenericDocument; -typedef GenericDocument<UTF8<char>, MemoryPoolAllocator<CrtAllocator>, CrtAllocator> Document; +typedef GenericDocument<UTF8<char>, CrtAllocator, CrtAllocator> Document; // pointer.h |
