From 8cb978dc1526089800c3546f2ae31c5caa890363 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 2 Feb 2016 18:20:36 +0800 Subject: [PATCH] Add fwd.h and extract stream.h --- include/rapidjson/encodedstream.h | 2 +- include/rapidjson/filereadstream.h | 2 +- include/rapidjson/filewritestream.h | 2 +- include/rapidjson/fwd.h | 146 +++++++++++++++++++ include/rapidjson/internal/regex.h | 3 +- include/rapidjson/internal/stack.h | 2 +- include/rapidjson/internal/strfunc.h | 2 +- include/rapidjson/internal/strtod.h | 1 - include/rapidjson/memorybuffer.h | 2 +- include/rapidjson/memorystream.h | 2 +- include/rapidjson/rapidjson.h | 161 +-------------------- include/rapidjson/reader.h | 4 +- include/rapidjson/schema.h | 2 +- include/rapidjson/stream.h | 179 +++++++++++++++++++++++ include/rapidjson/stringbuffer.h | 3 +- include/rapidjson/writer.h | 2 +- test/unittest/CMakeLists.txt | 1 + test/unittest/fwdtest.cpp | 208 +++++++++++++++++++++++++++ test/unittest/strfunctest.cpp | 1 - 19 files changed, 550 insertions(+), 175 deletions(-) create mode 100644 include/rapidjson/fwd.h create mode 100644 include/rapidjson/stream.h create mode 100644 test/unittest/fwdtest.cpp diff --git a/include/rapidjson/encodedstream.h b/include/rapidjson/encodedstream.h index e7cdf08..87c9067 100644 --- a/include/rapidjson/encodedstream.h +++ b/include/rapidjson/encodedstream.h @@ -15,7 +15,7 @@ #ifndef RAPIDJSON_ENCODEDSTREAM_H_ #define RAPIDJSON_ENCODEDSTREAM_H_ -#include "rapidjson.h" +#include "stream.h" #ifdef __GNUC__ RAPIDJSON_DIAG_PUSH diff --git a/include/rapidjson/filereadstream.h b/include/rapidjson/filereadstream.h index 6c8a86c..11aacbf 100644 --- a/include/rapidjson/filereadstream.h +++ b/include/rapidjson/filereadstream.h @@ -15,7 +15,7 @@ #ifndef RAPIDJSON_FILEREADSTREAM_H_ #define RAPIDJSON_FILEREADSTREAM_H_ -#include "rapidjson.h" +#include "stream.h" #include #ifdef __clang__ diff --git a/include/rapidjson/filewritestream.h b/include/rapidjson/filewritestream.h index 3c38329..8aeac86 100644 --- a/include/rapidjson/filewritestream.h +++ b/include/rapidjson/filewritestream.h @@ -15,7 +15,7 @@ #ifndef RAPIDJSON_FILEWRITESTREAM_H_ #define RAPIDJSON_FILEWRITESTREAM_H_ -#include "rapidjson.h" +#include "stream.h" #include #ifdef __clang__ diff --git a/include/rapidjson/fwd.h b/include/rapidjson/fwd.h new file mode 100644 index 0000000..9c0466c --- /dev/null +++ b/include/rapidjson/fwd.h @@ -0,0 +1,146 @@ +// Tencent is pleased to support the open source community by making RapidJSON available. +// +// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. +// +// Licensed under the MIT License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// http://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software distributed +// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +#ifndef RAPIDJSON_FWD_H_ +#define RAPIDJSON_FWD_H_ + +#include "rapidjson.h" + +RAPIDJSON_NAMESPACE_BEGIN + +// encodings.h + +template struct UTF8; +template struct UTF16; +template struct UTF16BE; +template struct UTF16LE; +template struct UTF32; +template struct UTF32BE; +template struct UTF32LE; +template struct ASCII; +template struct AutoUTF; + +template +struct Transcoder; + +// allocators.h + +class CrtAllocator; + +template +class MemoryPoolAllocator; + +// stream.h + +template +struct GenericStringStream; + +typedef GenericStringStream > StringStream; + +template +struct GenericInsituStringStream; + +typedef GenericInsituStringStream > InsituStringStream; + +// stringbuffer.h + +template +class GenericStringBuffer; + +typedef GenericStringBuffer, CrtAllocator> StringBuffer; + +// filereadstream.h + +class FileReadStream; + +// filewritestream.h + +class FileWriteStream; + +// memorybuffer.h + +template +struct GenericMemoryBuffer; + +typedef GenericMemoryBuffer MemoryBuffer; + +// memorystream.h + +struct MemoryStream; + +// reader.h + +template +struct BaseReaderHandler; + +template +class GenericReader; + +typedef GenericReader, UTF8, CrtAllocator> Reader; + +// writer.h + +template +class Writer; + +// document.h + +template +struct GenericMember; + +template +class GenericMemberIterator; + +template +struct GenericStringRef; + +template +class GenericValue; + +typedef GenericValue, MemoryPoolAllocator > Value; + +template +class GenericDocument; + +typedef GenericDocument, MemoryPoolAllocator, CrtAllocator> Document; + +// pointer.h + +template +class GenericPointer; + +typedef GenericPointer Pointer; + +// schema.h + +template +class IGenericRemoteSchemaDocumentProvider; + +template +class GenericSchemaDocument; + +typedef GenericSchemaDocument SchemaDocument; +typedef IGenericRemoteSchemaDocumentProvider IRemoteSchemaDocumentProvider; + +template < + typename SchemaDocumentType, + typename OutputHandler, + typename StateAllocator> +class GenericSchemaValidator; + +typedef GenericSchemaValidator, void>, CrtAllocator> SchemaValidator; + +RAPIDJSON_NAMESPACE_END + +#endif // RAPIDJSON_RAPIDJSONFWD_H_ diff --git a/include/rapidjson/internal/regex.h b/include/rapidjson/internal/regex.h index edcb974..6c1047d 100644 --- a/include/rapidjson/internal/regex.h +++ b/include/rapidjson/internal/regex.h @@ -15,7 +15,8 @@ #ifndef RAPIDJSON_INTERNAL_REGEX_H_ #define RAPIDJSON_INTERNAL_REGEX_H_ -#include "../rapidjson.h" +#include "../allocators.h" +#include "../stream.h" #include "stack.h" #ifdef __clang__ diff --git a/include/rapidjson/internal/stack.h b/include/rapidjson/internal/stack.h index 6615c46..c1beaac 100644 --- a/include/rapidjson/internal/stack.h +++ b/include/rapidjson/internal/stack.h @@ -15,7 +15,7 @@ #ifndef RAPIDJSON_INTERNAL_STACK_H_ #define RAPIDJSON_INTERNAL_STACK_H_ -#include "../rapidjson.h" +#include "../allocators.h" #include "swap.h" #if defined(__clang__) diff --git a/include/rapidjson/internal/strfunc.h b/include/rapidjson/internal/strfunc.h index 040ca1e..34d4703 100644 --- a/include/rapidjson/internal/strfunc.h +++ b/include/rapidjson/internal/strfunc.h @@ -15,7 +15,7 @@ #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ #define RAPIDJSON_INTERNAL_STRFUNC_H_ -#include "../rapidjson.h" +#include "../stream.h" RAPIDJSON_NAMESPACE_BEGIN namespace internal { diff --git a/include/rapidjson/internal/strtod.h b/include/rapidjson/internal/strtod.h index 89590c4..fd4b01e 100644 --- a/include/rapidjson/internal/strtod.h +++ b/include/rapidjson/internal/strtod.h @@ -15,7 +15,6 @@ #ifndef RAPIDJSON_STRTOD_ #define RAPIDJSON_STRTOD_ -#include "../rapidjson.h" #include "ieee754.h" #include "biginteger.h" #include "diyfp.h" diff --git a/include/rapidjson/memorybuffer.h b/include/rapidjson/memorybuffer.h index 2484b21..39bee1d 100644 --- a/include/rapidjson/memorybuffer.h +++ b/include/rapidjson/memorybuffer.h @@ -15,7 +15,7 @@ #ifndef RAPIDJSON_MEMORYBUFFER_H_ #define RAPIDJSON_MEMORYBUFFER_H_ -#include "rapidjson.h" +#include "stream.h" #include "internal/stack.h" RAPIDJSON_NAMESPACE_BEGIN diff --git a/include/rapidjson/memorystream.h b/include/rapidjson/memorystream.h index beed1ef..7381e0b 100644 --- a/include/rapidjson/memorystream.h +++ b/include/rapidjson/memorystream.h @@ -15,7 +15,7 @@ #ifndef RAPIDJSON_MEMORYSTREAM_H_ #define RAPIDJSON_MEMORYSTREAM_H_ -#include "rapidjson.h" +#include "stream.h" #ifdef __clang__ RAPIDJSON_DIAG_PUSH diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index 0cd9ee7..9cb40a9 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -545,10 +545,7 @@ RAPIDJSON_NAMESPACE_END #endif /////////////////////////////////////////////////////////////////////////////// -// Allocators and Encodings - -#include "allocators.h" -#include "encodings.h" +// Type /*! \namespace rapidjson \brief main RapidJSON namespace @@ -556,162 +553,6 @@ RAPIDJSON_NAMESPACE_END */ RAPIDJSON_NAMESPACE_BEGIN -/////////////////////////////////////////////////////////////////////////////// -// Stream - -/*! \class rapidjson::Stream - \brief Concept for reading and writing characters. - - For read-only stream, no need to implement PutBegin(), Put(), Flush() and PutEnd(). - - For write-only stream, only need to implement Put() and Flush(). - -\code -concept Stream { - typename Ch; //!< Character type of the stream. - - //! Read the current character from stream without moving the read cursor. - Ch Peek() const; - - //! Read the current character from stream and moving the read cursor to next character. - Ch Take(); - - //! Get the current read cursor. - //! \return Number of characters read from start. - size_t Tell(); - - //! Begin writing operation at the current read pointer. - //! \return The begin writer pointer. - Ch* PutBegin(); - - //! Write a character. - void Put(Ch c); - - //! Flush the buffer. - void Flush(); - - //! End the writing operation. - //! \param begin The begin write pointer returned by PutBegin(). - //! \return Number of characters written. - size_t PutEnd(Ch* begin); -} -\endcode -*/ - -//! Provides additional information for stream. -/*! - By using traits pattern, this type provides a default configuration for stream. - For custom stream, this type can be specialized for other configuration. - See TEST(Reader, CustomStringStream) in readertest.cpp for example. -*/ -template -struct StreamTraits { - //! Whether to make local copy of stream for optimization during parsing. - /*! - By default, for safety, streams do not use local copy optimization. - Stream that can be copied fast should specialize this, like StreamTraits. - */ - enum { copyOptimization = 0 }; -}; - -//! Reserve n characters for writing to a stream. -template -inline void PutReserve(Stream& stream, size_t count) { - (void)stream; - (void)count; -} - -//! Write character to a stream, presuming buffer is reserved. -template -inline void PutUnsafe(Stream& stream, typename Stream::Ch c) { - stream.Put(c); -} - -//! Put N copies of a character to a stream. -template -inline void PutN(Stream& stream, Ch c, size_t n) { - PutReserve(stream, n); - for (size_t i = 0; i < n; i++) - PutUnsafe(stream, c); -} - -/////////////////////////////////////////////////////////////////////////////// -// StringStream - -//! Read-only string stream. -/*! \note implements Stream concept -*/ -template -struct GenericStringStream { - typedef typename Encoding::Ch Ch; - - GenericStringStream(const Ch *src) : src_(src), head_(src) {} - - Ch Peek() const { return *src_; } - Ch Take() { return *src_++; } - size_t Tell() const { return static_cast(src_ - head_); } - - Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } - void Put(Ch) { RAPIDJSON_ASSERT(false); } - void Flush() { RAPIDJSON_ASSERT(false); } - size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } - - const Ch* src_; //!< Current read position. - const Ch* head_; //!< Original head of the string. -}; - -template -struct StreamTraits > { - enum { copyOptimization = 1 }; -}; - -//! String stream with UTF8 encoding. -typedef GenericStringStream > StringStream; - -/////////////////////////////////////////////////////////////////////////////// -// InsituStringStream - -//! A read-write string stream. -/*! This string stream is particularly designed for in-situ parsing. - \note implements Stream concept -*/ -template -struct GenericInsituStringStream { - typedef typename Encoding::Ch Ch; - - GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {} - - // Read - Ch Peek() { return *src_; } - Ch Take() { return *src_++; } - size_t Tell() { return static_cast(src_ - head_); } - - // Write - void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; } - - Ch* PutBegin() { return dst_ = src_; } - size_t PutEnd(Ch* begin) { return static_cast(dst_ - begin); } - void Flush() {} - - Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; } - void Pop(size_t count) { dst_ -= count; } - - Ch* src_; - Ch* dst_; - Ch* head_; -}; - -template -struct StreamTraits > { - enum { copyOptimization = 1 }; -}; - -//! Insitu string stream with UTF8 encoding. -typedef GenericInsituStringStream > InsituStringStream; - -/////////////////////////////////////////////////////////////////////////////// -// Type - //! Type of JSON value enum Type { kNullType = 0, //!< null diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 35410cf..f2670b6 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -17,8 +17,8 @@ /*! \file reader.h */ -#include "rapidjson.h" -#include "encodings.h" +#include "allocators.h" +#include "stream.h" #include "internal/meta.h" #include "internal/stack.h" #include "internal/strtod.h" diff --git a/include/rapidjson/schema.h b/include/rapidjson/schema.h index a72ace9..e47f89a 100644 --- a/include/rapidjson/schema.h +++ b/include/rapidjson/schema.h @@ -17,7 +17,7 @@ #include "document.h" #include "pointer.h" -#include // HUGE_VAL, abs, floor +#include // abs, floor #ifdef __clang__ RAPIDJSON_DIAG_PUSH diff --git a/include/rapidjson/stream.h b/include/rapidjson/stream.h new file mode 100644 index 0000000..dd2783b --- /dev/null +++ b/include/rapidjson/stream.h @@ -0,0 +1,179 @@ +// Tencent is pleased to support the open source community by making RapidJSON available. +// +// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. +// +// Licensed under the MIT License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// http://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software distributed +// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +#include "rapidjson.h" + +#ifndef RAPIDJSON_STREAM_H_ +#define RAPIDJSON_STREAM_H_ + +#include "encodings.h" + +RAPIDJSON_NAMESPACE_BEGIN + +/////////////////////////////////////////////////////////////////////////////// +// Stream + +/*! \class rapidjson::Stream + \brief Concept for reading and writing characters. + + For read-only stream, no need to implement PutBegin(), Put(), Flush() and PutEnd(). + + For write-only stream, only need to implement Put() and Flush(). + +\code +concept Stream { + typename Ch; //!< Character type of the stream. + + //! Read the current character from stream without moving the read cursor. + Ch Peek() const; + + //! Read the current character from stream and moving the read cursor to next character. + Ch Take(); + + //! Get the current read cursor. + //! \return Number of characters read from start. + size_t Tell(); + + //! Begin writing operation at the current read pointer. + //! \return The begin writer pointer. + Ch* PutBegin(); + + //! Write a character. + void Put(Ch c); + + //! Flush the buffer. + void Flush(); + + //! End the writing operation. + //! \param begin The begin write pointer returned by PutBegin(). + //! \return Number of characters written. + size_t PutEnd(Ch* begin); +} +\endcode +*/ + +//! Provides additional information for stream. +/*! + By using traits pattern, this type provides a default configuration for stream. + For custom stream, this type can be specialized for other configuration. + See TEST(Reader, CustomStringStream) in readertest.cpp for example. +*/ +template +struct StreamTraits { + //! Whether to make local copy of stream for optimization during parsing. + /*! + By default, for safety, streams do not use local copy optimization. + Stream that can be copied fast should specialize this, like StreamTraits. + */ + enum { copyOptimization = 0 }; +}; + +//! Reserve n characters for writing to a stream. +template +inline void PutReserve(Stream& stream, size_t count) { + (void)stream; + (void)count; +} + +//! Write character to a stream, presuming buffer is reserved. +template +inline void PutUnsafe(Stream& stream, typename Stream::Ch c) { + stream.Put(c); +} + +//! Put N copies of a character to a stream. +template +inline void PutN(Stream& stream, Ch c, size_t n) { + PutReserve(stream, n); + for (size_t i = 0; i < n; i++) + PutUnsafe(stream, c); +} + +/////////////////////////////////////////////////////////////////////////////// +// StringStream + +//! Read-only string stream. +/*! \note implements Stream concept +*/ +template +struct GenericStringStream { + typedef typename Encoding::Ch Ch; + + GenericStringStream(const Ch *src) : src_(src), head_(src) {} + + Ch Peek() const { return *src_; } + Ch Take() { return *src_++; } + size_t Tell() const { return static_cast(src_ - head_); } + + Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } + void Put(Ch) { RAPIDJSON_ASSERT(false); } + void Flush() { RAPIDJSON_ASSERT(false); } + size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } + + const Ch* src_; //!< Current read position. + const Ch* head_; //!< Original head of the string. +}; + +template +struct StreamTraits > { + enum { copyOptimization = 1 }; +}; + +//! String stream with UTF8 encoding. +typedef GenericStringStream > StringStream; + +/////////////////////////////////////////////////////////////////////////////// +// InsituStringStream + +//! A read-write string stream. +/*! This string stream is particularly designed for in-situ parsing. + \note implements Stream concept +*/ +template +struct GenericInsituStringStream { + typedef typename Encoding::Ch Ch; + + GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {} + + // Read + Ch Peek() { return *src_; } + Ch Take() { return *src_++; } + size_t Tell() { return static_cast(src_ - head_); } + + // Write + void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; } + + Ch* PutBegin() { return dst_ = src_; } + size_t PutEnd(Ch* begin) { return static_cast(dst_ - begin); } + void Flush() {} + + Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; } + void Pop(size_t count) { dst_ -= count; } + + Ch* src_; + Ch* dst_; + Ch* head_; +}; + +template +struct StreamTraits > { + enum { copyOptimization = 1 }; +}; + +//! Insitu string stream with UTF8 encoding. +typedef GenericInsituStringStream > InsituStringStream; + +RAPIDJSON_NAMESPACE_END + +#endif // RAPIDJSON_STREAM_H_ diff --git a/include/rapidjson/stringbuffer.h b/include/rapidjson/stringbuffer.h index 0d32859..41c8dfc 100644 --- a/include/rapidjson/stringbuffer.h +++ b/include/rapidjson/stringbuffer.h @@ -15,7 +15,8 @@ #ifndef RAPIDJSON_STRINGBUFFER_H_ #define RAPIDJSON_STRINGBUFFER_H_ -#include "rapidjson.h" +#include "stream.h" +#include "internal/stack.h" #if RAPIDJSON_HAS_CXX11_RVALUE_REFS #include // std::move diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h index 63b88f5..ffb6cb5 100644 --- a/include/rapidjson/writer.h +++ b/include/rapidjson/writer.h @@ -15,7 +15,7 @@ #ifndef RAPIDJSON_WRITER_H_ #define RAPIDJSON_WRITER_H_ -#include "rapidjson.h" +#include "stream.h" #include "internal/stack.h" #include "internal/strfunc.h" #include "internal/dtoa.h" diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt index 21a2dfb..f82645f 100644 --- a/test/unittest/CMakeLists.txt +++ b/test/unittest/CMakeLists.txt @@ -4,6 +4,7 @@ set(UNITTEST_SOURCES documenttest.cpp encodedstreamtest.cpp encodingstest.cpp + fwdtest.cpp filestreamtest.cpp itoatest.cpp jsoncheckertest.cpp diff --git a/test/unittest/fwdtest.cpp b/test/unittest/fwdtest.cpp new file mode 100644 index 0000000..3cf8f63 --- /dev/null +++ b/test/unittest/fwdtest.cpp @@ -0,0 +1,208 @@ +// Tencent is pleased to support the open source community by making RapidJSON available. +// +// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. +// +// Licensed under the MIT License (the "License"); you may not use this file except +// in compliance with the License. You may obtain a copy of the License at +// +// http://opensource.org/licenses/MIT +// +// Unless required by applicable law or agreed to in writing, software distributed +// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +#include "unittest.h" + +// Using forward declared types here. + +#include "rapidjson/fwd.h" + +using namespace rapidjson; + +struct Foo { + Foo(); + ~Foo(); + + // encodings.h + UTF8* utf8; + UTF16* utf16; + UTF16BE* utf16be; + UTF16LE* utf16le; + UTF32* utf32; + UTF32BE* utf32be; + UTF32LE* utf32le; + ASCII* ascii; + AutoUTF* autoutf; + Transcoder, UTF8 >* transcoder; + + // allocators.h + CrtAllocator* crtallocator; + MemoryPoolAllocator* memorypoolallocator; + + // stream.h + StringStream* stringstream; + InsituStringStream* insitustringstream; + + // stringbuffer.h + StringBuffer* stringbuffer; + + // filereadstream.h + FileReadStream* filereadstream; + + // filewritestream.h + FileWriteStream* filewritestream; + + // memorybuffer.h + MemoryBuffer* memorybuffer; + + // memorystream.h + MemoryStream* memorystream; + + // reader.h + BaseReaderHandler, void>* basereaderhandler; + Reader* reader; + + // writer.h + Writer, UTF8, CrtAllocator>* writer; + + // document.h + Value* value; + Document* document; + + // pointer.h + Pointer* pointer; + + // schema.h + SchemaDocument* schemadocument; + SchemaValidator* schemavalidator; + + char buffer[16]; +}; + +// Using type definitions here. + +#include "rapidjson/stringbuffer.h" +#include "rapidjson/filereadstream.h" +#include "rapidjson/filewritestream.h" +#include "rapidjson/memorybuffer.h" +#include "rapidjson/memorystream.h" +#include "rapidjson/document.h" // -> reader.h +#include "rapidjson/writer.h" +#include "rapidjson/schema.h" // -> pointer.h + +Foo::Foo() : + // encodings.h + utf8(RAPIDJSON_NEW(UTF8<>)), + utf16(RAPIDJSON_NEW(UTF16<>)), + utf16be(RAPIDJSON_NEW(UTF16BE<>)), + utf16le(RAPIDJSON_NEW(UTF16LE<>)), + utf32(RAPIDJSON_NEW(UTF32<>)), + utf32be(RAPIDJSON_NEW(UTF32BE<>)), + utf32le(RAPIDJSON_NEW(UTF32LE<>)), + ascii(RAPIDJSON_NEW(ASCII<>)), + autoutf(RAPIDJSON_NEW(AutoUTF)), + transcoder(RAPIDJSON_NEW((Transcoder, UTF8<> >))), + + // allocators.h + crtallocator(RAPIDJSON_NEW(CrtAllocator)), + memorypoolallocator(RAPIDJSON_NEW(MemoryPoolAllocator<>)), + + // stream.h + stringstream(RAPIDJSON_NEW(StringStream(0))), + insitustringstream(RAPIDJSON_NEW(InsituStringStream(0))), + + // stringbuffer.h + stringbuffer(RAPIDJSON_NEW(StringBuffer)), + + // filereadstream.h + filereadstream(RAPIDJSON_NEW(FileReadStream(stdout, buffer, sizeof(buffer)))), + + // filewritestream.h + filewritestream(RAPIDJSON_NEW(FileWriteStream(stdout, buffer, sizeof(buffer)))), + + // memorybuffer.h + memorybuffer(RAPIDJSON_NEW(MemoryBuffer)), + + // memorystream.h + memorystream(RAPIDJSON_NEW(MemoryStream(0, 0))), + + // reader.h + basereaderhandler(RAPIDJSON_NEW((BaseReaderHandler, void>))), + reader(RAPIDJSON_NEW(Reader)), + + // writer.h + writer(RAPIDJSON_NEW((Writer))), + + // document.h + value(RAPIDJSON_NEW(Value)), + document(RAPIDJSON_NEW(Document)), + + // pointer.h + pointer(RAPIDJSON_NEW(Pointer)), + + // schema.h + schemadocument(RAPIDJSON_NEW(SchemaDocument(*document))), + schemavalidator(RAPIDJSON_NEW(SchemaValidator(*schemadocument))) +{ + +} + +Foo::~Foo() { + // encodings.h + RAPIDJSON_DELETE(utf8); + RAPIDJSON_DELETE(utf16); + RAPIDJSON_DELETE(utf16be); + RAPIDJSON_DELETE(utf16le); + RAPIDJSON_DELETE(utf32); + RAPIDJSON_DELETE(utf32be); + RAPIDJSON_DELETE(utf32le); + RAPIDJSON_DELETE(ascii); + RAPIDJSON_DELETE(autoutf); + RAPIDJSON_DELETE(transcoder); + + // allocators.h + RAPIDJSON_DELETE(crtallocator); + RAPIDJSON_DELETE(memorypoolallocator); + + // stream.h + RAPIDJSON_DELETE(stringstream); + RAPIDJSON_DELETE(insitustringstream); + + // stringbuffer.h + RAPIDJSON_DELETE(stringbuffer); + + // filereadstream.h + RAPIDJSON_DELETE(filereadstream); + + // filewritestream.h + RAPIDJSON_DELETE(filewritestream); + + // memorybuffer.h + RAPIDJSON_DELETE(memorybuffer); + + // memorystream.h + RAPIDJSON_DELETE(memorystream); + + // reader.h + RAPIDJSON_DELETE(basereaderhandler); + RAPIDJSON_DELETE(reader); + + // writer.h + RAPIDJSON_DELETE(writer); + + // document.h + RAPIDJSON_DELETE(value); + RAPIDJSON_DELETE(document); + + // pointer.h + RAPIDJSON_DELETE(pointer); + + // schema.h + RAPIDJSON_DELETE(schemadocument); + RAPIDJSON_DELETE(schemavalidator); +} + +TEST(Fwd, Fwd) { + Foo f; +} diff --git a/test/unittest/strfunctest.cpp b/test/unittest/strfunctest.cpp index 186755c..cc1bb22 100644 --- a/test/unittest/strfunctest.cpp +++ b/test/unittest/strfunctest.cpp @@ -13,7 +13,6 @@ // specific language governing permissions and limitations under the License. #include "unittest.h" - #include "rapidjson/internal/strfunc.h" using namespace rapidjson;