From a73f83183c82d29b69c821c0ef0214aef22271bc Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 16:21:47 +0200 Subject: [PATCH 01/76] ignore generated Doxygen documentation --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2dbbadb..d53ea43 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ /build/*.exe /build/gmake /build/vs*/ +/doc/html /thirdparty/lib /intermediate From 252e282dc69153a662c4ef54016de69c45f37ceb Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:16:50 +0200 Subject: [PATCH 02/76] Doxyfile: prepare for Markdown rendering --- build/Doxyfile | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/build/Doxyfile b/build/Doxyfile index 6e60e58..a54bd8e 100644 --- a/build/Doxyfile +++ b/build/Doxyfile @@ -52,7 +52,7 @@ PROJECT_LOGO = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = ../doc +OUTPUT_DIRECTORY = ./doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -514,7 +514,7 @@ GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = $(RAPIDJSON_SECTIONS) # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in @@ -548,7 +548,7 @@ SHOW_FILES = YES # Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. -SHOW_NAMESPACES = YES +SHOW_NAMESPACES = NO # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from @@ -638,7 +638,9 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../include/ +INPUT = ./include/ \ + ./readme.md \ + ./doc/ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -660,34 +662,12 @@ FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ *.h \ *.hh \ *.hxx \ *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py \ - *.f90 \ - *.f \ - *.for \ - *.vhd \ - *.vhdl + *.md # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. @@ -748,7 +728,7 @@ EXAMPLE_RECURSIVE = NO # directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = ./doc # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -1479,13 +1459,13 @@ ENABLE_PREPROCESSING = YES # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. From 5174fe4f652f4d31961d309ff864ebbdb4abd5b3 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:09:35 +0200 Subject: [PATCH 03/76] rapidjson.h: add some file-level doxygen documentation Although not yet complete, the rapidjson.h header contains most of the customisation macro definitions. These should be documented via Doxygen as well. This requires adding file-level documentation. Some parts are excluded via `@cond` to avoid cluttering the documentation with internals too much. Secondly, a brief description is added to the 'rapidjson' namespace to include the namespace-level elements (enums, typedefs, functions) to the generated documentation. --- include/rapidjson/rapidjson.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index a6d5c06..c73efa5 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -4,6 +4,12 @@ // Copyright (c) 2011 Milo Yip (miloyip@gmail.com) // Version 0.1 +/*!\file rapidjson.h + \brief common definitions and configuration + + \todo Complete Doxygen documentation for configure macros. + */ + #include // malloc(), realloc(), free() #include // memcpy() @@ -14,6 +20,7 @@ // (U)INT64_C constant macros. // If user have their own definition, can define RAPIDJSON_NO_INT64DEFINE to disable this. #ifndef RAPIDJSON_NO_INT64DEFINE +//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS 1 // required by C++ standard #endif @@ -25,6 +32,7 @@ #include #include #endif +//!@endcond #endif // RAPIDJSON_NO_INT64TYPEDEF /////////////////////////////////////////////////////////////////////////////// @@ -46,7 +54,7 @@ //! Endianness of the machine. /*! GCC provided macro for detecting endianness of the target machine. But other compilers may not have this. User can define RAPIDJSON_ENDIAN to either - RAPIDJSON_LITTLEENDIAN or RAPIDJSON_BIGENDIAN. + \ref RAPIDJSON_LITTLEENDIAN or \ref RAPIDJSON_BIGENDIAN. */ #ifndef RAPIDJSON_ENDIAN #ifdef __BYTE_ORDER__ @@ -115,7 +123,9 @@ typedef unsigned SizeType; // Adopt from boost #ifndef RAPIDJSON_STATIC_ASSERT +//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN namespace rapidjson { + template struct STATIC_ASSERTION_FAILURE; template <> struct STATIC_ASSERTION_FAILURE { enum { value = 1 }; }; template struct StaticAssertTest {}; @@ -130,7 +140,13 @@ template struct StaticAssertTest {}; #else #define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE #endif +//!@endcond +/*! \def RAPIDJSON_STATIC_ASSERT + \brief (internal) macro to check for conditions at compile-time + \param x compile-time condition + \hideinitializer + */ #define RAPIDJSON_STATIC_ASSERT(x) typedef ::rapidjson::StaticAssertTest<\ sizeof(::rapidjson::STATIC_ASSERTION_FAILURE)>\ RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE @@ -139,9 +155,11 @@ template struct StaticAssertTest {}; /////////////////////////////////////////////////////////////////////////////// // Helpers +//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN #define RAPIDJSON_MULTILINEMACRO_BEGIN do { #define RAPIDJSON_MULTILINEMACRO_END \ } while((void)0, 0) +//!@endcond /////////////////////////////////////////////////////////////////////////////// // Allocators and Encodings @@ -149,6 +167,7 @@ template struct StaticAssertTest {}; #include "allocators.h" #include "encodings.h" +//! main RapidJSON namespace namespace rapidjson { /////////////////////////////////////////////////////////////////////////////// From c63c40fa857fa6422db1d450890c67832cefbed2 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:03:54 +0200 Subject: [PATCH 04/76] GenericMemberIterator::Type -> GenericMemberIterator::Iterator Rename nested typedef to avoid confusion with JSON Type enum. --- include/rapidjson/document.h | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index bc2d836..faf3909 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -73,7 +73,7 @@ class GenericMemberIterator public: //! Iterator type itself - typedef GenericMemberIterator Type; + typedef GenericMemberIterator Iterator; //! Constant iterator type typedef GenericMemberIterator ConstType; //! Non-constant iterator type @@ -112,29 +112,29 @@ public: //! @name stepping //@{ - Type& operator++(){ ++ptr_; return *this; } - Type& operator--(){ --ptr_; return *this; } - Type operator++(int){ Type old(*this); ++ptr_; return old; } - Type operator--(int){ Type old(*this); --ptr_; return old; } + Iterator& operator++(){ ++ptr_; return *this; } + Iterator& operator--(){ --ptr_; return *this; } + Iterator operator++(int){ Iterator old(*this); ++ptr_; return old; } + Iterator operator--(int){ Iterator old(*this); --ptr_; return old; } //@} //! @name increment/decrement //@{ - Type operator+(DifferenceType n) const { return Type(ptr_+n); } - Type operator-(DifferenceType n) const { return Type(ptr_-n); } + Iterator operator+(DifferenceType n) const { return Iterator(ptr_+n); } + Iterator operator-(DifferenceType n) const { return Iterator(ptr_-n); } - Type& operator+=(DifferenceType n) { ptr_+=n; return *this; } - Type& operator-=(DifferenceType n) { ptr_-=n; return *this; } + Iterator& operator+=(DifferenceType n) { ptr_+=n; return *this; } + Iterator& operator-=(DifferenceType n) { ptr_-=n; return *this; } //@} //! @name relations //@{ - bool operator==(Type that) const { return ptr_ == that.ptr_; } - bool operator!=(Type that) const { return ptr_ != that.ptr_; } - bool operator<=(Type that) const { return ptr_ <= that.ptr_; } - bool operator>=(Type that) const { return ptr_ >= that.ptr_; } - bool operator< (Type that) const { return ptr_ < that.ptr_; } - bool operator> (Type that) const { return ptr_ > that.ptr_; } + bool operator==(Iterator that) const { return ptr_ == that.ptr_; } + bool operator!=(Iterator that) const { return ptr_ != that.ptr_; } + bool operator<=(Iterator that) const { return ptr_ <= that.ptr_; } + bool operator>=(Iterator that) const { return ptr_ >= that.ptr_; } + bool operator< (Iterator that) const { return ptr_ < that.ptr_; } + bool operator> (Iterator that) const { return ptr_ > that.ptr_; } //@} //! @name dereference @@ -145,7 +145,7 @@ public: //@} //! Distance - DifferenceType operator-(Type that) const { return ptr_-that.ptr_; } + DifferenceType operator-(Iterator that) const { return ptr_-that.ptr_; } private: //! Internal constructor from plain pointer @@ -165,13 +165,13 @@ struct GenericMemberIterator; template struct GenericMemberIterator { //! use plain pointer as iterator type - typedef GenericMember* Type; + typedef GenericMember* Iterator; }; //! const GenericMemberIterator template struct GenericMemberIterator { //! use plain const pointer as iterator type - typedef const GenericMember* Type; + typedef const GenericMember* Iterator; }; #endif // RAPIDJSON_NOMEMBERITERATORCLASS @@ -198,8 +198,8 @@ public: typedef Encoding EncodingType; //!< Encoding type from template parameter. typedef Allocator AllocatorType; //!< Allocator type from template parameter. typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding. - typedef typename GenericMemberIterator::Type MemberIterator; //!< Member iterator for iterating in object. - typedef typename GenericMemberIterator::Type ConstMemberIterator; //!< Constant member iterator for iterating in object. + typedef typename GenericMemberIterator::Iterator MemberIterator; //!< Member iterator for iterating in object. + typedef typename GenericMemberIterator::Iterator ConstMemberIterator; //!< Constant member iterator for iterating in object. typedef GenericValue* ValueIterator; //!< Value iterator for iterating in array. typedef const GenericValue* ConstValueIterator; //!< Constant value iterator for iterating in array. From 6ed0ac174f9750c6829b770f60520f639a3b629e Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:04:59 +0200 Subject: [PATCH 05/76] GenericDocument: improve Doxygen documentation --- include/rapidjson/document.h | 66 +++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index faf3909..3fd98b8 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -937,7 +937,7 @@ private: }; #pragma pack (pop) -//! Value with UTF8 encoding. +//! GenericValue with UTF8 encoding typedef GenericValue > Value; /////////////////////////////////////////////////////////////////////////////// @@ -948,6 +948,7 @@ typedef GenericValue > Value; \note implements Handler concept \tparam Encoding encoding for both parsing and string storage. \tparam Allocator allocator for allocating memory for the DOM, and the stack during parsing. + \warning Although GenericDocument inherits from GenericValue, the API does \b not provide any virtual functions, especially no virtual destructors. To avoid memory leaks, do not \c delete a GenericDocument object via a pointer to a GenericValue. */ template > class GenericDocument : public GenericValue { @@ -962,8 +963,13 @@ public: */ GenericDocument(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(allocator, stackCapacity), parseErrorCode_(kParseErrorNone), errorOffset_(0) {} - //! Parse JSON text from an input stream. - /*! \tparam parseFlags Combination of ParseFlag. + //!@name Parse from stream + //!@{ + + //! Parse JSON text from an input stream (with Encoding conversion) + /*! \tparam parseFlags Combination of \ref ParseFlag. + \tparam SourceEncoding Encoding of input stream + \tparam InputStream Type of input stream, implementing Stream concept \param is Input stream to be parsed. \return The document itself for fluent API. */ @@ -985,18 +991,34 @@ public: return *this; } + //! Parse JSON text from an input stream + /*! \tparam parseFlags Combination of \ref ParseFlag. + \tparam InputStream Type of input stream, implementing Stream concept + \param is Input stream to be parsed. + \return The document itself for fluent API. + */ template GenericDocument& ParseStream(InputStream& is) { return ParseStream(is); } + //! Parse JSON text from an input stream (with \ref kParseDefaultFlags) + /*! \tparam InputStream Type of input stream, implementing Stream concept + \param is Input stream to be parsed. + \return The document itself for fluent API. + */ template GenericDocument& ParseStream(InputStream& is) { return ParseStream(is); } + //!@} - //! Parse JSON text from a mutable string. - /*! \tparam parseFlags Combination of ParseFlag. + //!@name Parse in-place from mutable string + //!@{ + + //! Parse JSON text from a mutable string (with Encoding conversion) + /*! \tparam parseFlags Combination of \ref ParseFlag. + \tparam SourceEncoding Transcoding from input Encoding \param str Mutable zero-terminated string to be parsed. \return The document itself for fluent API. */ @@ -1006,17 +1028,31 @@ public: return ParseStream(s); } + //! Parse JSON text from a mutable string + /*! \tparam parseFlags Combination of \ref ParseFlag. + \param str Mutable zero-terminated string to be parsed. + \return The document itself for fluent API. + */ template GenericDocument& ParseInsitu(Ch* str) { return ParseInsitu(str); } + //! Parse JSON text from a mutable string (with \ref kParseDefaultFlags) + /*! \param str Mutable zero-terminated string to be parsed. + \return The document itself for fluent API. + */ GenericDocument& ParseInsitu(Ch* str) { return ParseInsitu(str); } + //!@} - //! Parse JSON text from a read-only string. - /*! \tparam parseFlags Combination of ParseFlag (must not contain kParseInsituFlag). + //!@name Parse from read-only string + //!@{ + + //! Parse JSON text from a read-only string (with Encoding conversion) + /*! \tparam parseFlags Combination of \ref ParseFlag (must not contain \ref kParseInsituFlag). + \tparam SourceEncoding Transcoding from input Encoding \param str Read-only zero-terminated string to be parsed. */ template @@ -1026,14 +1062,25 @@ public: return ParseStream(s); } + //! Parse JSON text from a read-only string + /*! \tparam parseFlags Combination of \ref ParseFlag (must not contain \ref kParseInsituFlag). + \param str Read-only zero-terminated string to be parsed. + */ template GenericDocument& Parse(const Ch* str) { return Parse(str); } + //! Parse JSON text from a read-only string (with \ref kParseDefaultFlags) + /*! \param str Read-only zero-terminated string to be parsed. + */ GenericDocument& Parse(const Ch* str) { return Parse(str); } + //!@} + + //!@name Handling parse errors + //!@{ //! Whether a parse error was occured in the last parsing. bool HasParseError() const { return parseErrorCode_ != kParseErrorNone; } @@ -1044,6 +1091,8 @@ public: //! Get the offset in character of the parsing error. size_t GetErrorOffset() const { return errorOffset_; } + //!@} + //! Get the allocator of this document. Allocator& GetAllocator() { return stack_.GetAllocator(); } @@ -1086,7 +1135,7 @@ private: } private: - // Prohibit assignment + //! Prohibit assignment GenericDocument& operator=(const GenericDocument&); void ClearStack() { @@ -1103,6 +1152,7 @@ private: size_t errorOffset_; }; +//! GenericDocument with UTF8 encoding typedef GenericDocument > Document; // defined here due to the dependency on GenericDocument From 7972f22fcb2b10f23ff95c45269dd812a294a082 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:05:48 +0200 Subject: [PATCH 06/76] Doxygen: document some UTF-8 typedefs --- include/rapidjson/rapidjson.h | 2 ++ include/rapidjson/stringbuffer.h | 1 + 2 files changed, 3 insertions(+) diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index c73efa5..bd500bc 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -265,6 +265,7 @@ struct StreamTraits > { enum { copyOptimization = 1 }; }; +//! String stream with UTF8 encoding. typedef GenericStringStream > StringStream; /////////////////////////////////////////////////////////////////////////////// @@ -301,6 +302,7 @@ struct StreamTraits > { enum { copyOptimization = 1 }; }; +//! Insitu string stream with UTF8 encoding. typedef GenericInsituStringStream > InsituStringStream; /////////////////////////////////////////////////////////////////////////////// diff --git a/include/rapidjson/stringbuffer.h b/include/rapidjson/stringbuffer.h index fd7aab8..162e5f1 100644 --- a/include/rapidjson/stringbuffer.h +++ b/include/rapidjson/stringbuffer.h @@ -37,6 +37,7 @@ struct GenericStringBuffer { mutable internal::Stack stack_; }; +//! String buffer with UTF8 encoding typedef GenericStringBuffer > StringBuffer; //! Implement specialized version of PutN() with memset() for better performance. From ec8f26e6e5256e6c8c10289e244e40586b1d48fc Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:06:44 +0200 Subject: [PATCH 07/76] (Pretty)Writer: improve doxygen documentation --- include/rapidjson/prettywriter.h | 23 +++++++++------ include/rapidjson/writer.h | 48 +++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h index cbbcdab..5d04433 100644 --- a/include/rapidjson/prettywriter.h +++ b/include/rapidjson/prettywriter.h @@ -24,9 +24,9 @@ public: typedef typename Base::Ch Ch; //! Constructor - /*! \param os Output os. + /*! \param os Output stream. \param allocator User supplied allocator. If it is null, it will create a private one. - \param levelDepth Initial capacity of + \param levelDepth Initial capacity of stack. */ PrettyWriter(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {} @@ -46,7 +46,9 @@ public: return *this; } - //@name Implementation of Handler. + /*! @name Implementation of Handler + \see Handler + */ //@{ PrettyWriter& Null() { PrettyPrefix(kNullType); Base::WriteNull(); return *this; } @@ -56,11 +58,6 @@ public: PrettyWriter& Int64(int64_t i64) { PrettyPrefix(kNumberType); Base::WriteInt64(i64); return *this; } PrettyWriter& Uint64(uint64_t u64) { PrettyPrefix(kNumberType); Base::WriteUint64(u64); return *this; } PrettyWriter& Double(double d) { PrettyPrefix(kNumberType); Base::WriteDouble(d); return *this; } - //! Overridden for fluent API, see \ref Writer::Double() - PrettyWriter& Double(double d, int precision) { - int oldPrecision = Base::GetDoublePrecision(); - return SetDoublePrecision(precision).Double(d).SetDoublePrecision(oldPrecision); - } PrettyWriter& String(const Ch* str, SizeType length, bool copy = false) { (void)copy; @@ -117,9 +114,19 @@ public: //@} + /*! @name Convenience extensions */ + //@{ + //! Simpler but slower overload. PrettyWriter& String(const Ch* str) { return String(str, internal::StrLen(str)); } + //! Overridden for fluent API, see \ref Writer::Double() + PrettyWriter& Double(double d, int precision) { + int oldPrecision = Base::GetDoublePrecision(); + return SetDoublePrecision(precision).Double(d).SetDoublePrecision(oldPrecision); + } + + //@} protected: void PrettyPrefix(Type type) { (void)type; diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h index 95c550c..979b781 100644 --- a/include/rapidjson/writer.h +++ b/include/rapidjson/writer.h @@ -25,8 +25,9 @@ namespace rapidjson { for example Reader::Parse() and Document::Accept(). \tparam OutputStream Type of output stream. - \tparam SourceEncoding Encoding of both source strings. - \tparam TargetEncoding Encoding of and output stream. + \tparam SourceEncoding Encoding of source string. + \tparam TargetEncoding Encoding of output stream. + \tparam Allocator Type of allocator for allocating memory of stack. \note implements Handler concept */ template, typename TargetEncoding = UTF8<>, typename Allocator = MemoryPoolAllocator<> > @@ -34,6 +35,11 @@ class Writer { public: typedef typename SourceEncoding::Ch Ch; + //! Constructor + /*! \param os Output stream. + \param allocator User supplied allocator. If it is null, it will create a private one. + \param levelDepth Initial capacity of stack. + */ Writer(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) : os_(os), level_stack_(allocator, levelDepth * sizeof(Level)), doublePrecision_(kDefaultDoublePrecision) {} @@ -53,8 +59,11 @@ public: //! \see SetDoublePrecision() int GetDoublePrecision() const { return doublePrecision_; } - //@name Implementation of Handler + /*!@name Implementation of Handler + \see Handler + */ //@{ + Writer& Null() { Prefix(kNullType); WriteNull(); return *this; } Writer& Bool(bool b) { Prefix(b ? kTrueType : kFalseType); WriteBool(b); return *this; } Writer& Int(int i) { Prefix(kNumberType); WriteInt(i); return *this; } @@ -75,20 +84,6 @@ public: */ Writer& Double(double d) { Prefix(kNumberType); WriteDouble(d); return *this; } - //! Writes the given \c double value to the stream (explicit precision) - /*! - The currently set double precision is ignored in favor of the explicitly - given precision for this value. - \see Double(), SetDoublePrecision(), GetDoublePrecision() - \param d The value to be written - \param precision The number of significant digits for this value - \return The Writer itself for fluent API. - */ - Writer& Double(double d, int precision) { - int oldPrecision = GetDoublePrecision(); - return SetDoublePrecision(precision).Double(d).SetDoublePrecision(oldPrecision); - } - Writer& String(const Ch* str, SizeType length, bool copy = false) { (void)copy; Prefix(kStringType); @@ -133,9 +128,28 @@ public: } //@} + /*! @name Convenience extensions */ + //@{ + + //! Writes the given \c double value to the stream (explicit precision) + /*! + The currently set double precision is ignored in favor of the explicitly + given precision for this value. + \see Double(), SetDoublePrecision(), GetDoublePrecision() + \param d The value to be written + \param precision The number of significant digits for this value + \return The Writer itself for fluent API. + */ + Writer& Double(double d, int precision) { + int oldPrecision = GetDoublePrecision(); + return SetDoublePrecision(precision).Double(d).SetDoublePrecision(oldPrecision); + } + //! Simpler but slower overload. Writer& String(const Ch* str) { return String(str, internal::StrLen(str)); } + //@} + protected: //! Information for each nested level struct Level { From 53b27ac8baab4dbd441409bd6794a6ea34378d96 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:07:13 +0200 Subject: [PATCH 08/76] GenericReader: improve doxygen documentation --- include/rapidjson/reader.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index dac1537..59d03b6 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -43,6 +43,8 @@ namespace rapidjson { // ParseFlag //! Combination of parseFlags +/*! \see Reader::Parse, Document::Parse, Document::ParseInsitu, Document::ParseStream + */ enum ParseFlag { kParseDefaultFlags = 0, //!< Default parse flags. Non-destructive parsing. Text strings are decoded into allocated buffer. kParseInsituFlag = 1, //!< In-situ(destructive) parsing. @@ -257,7 +259,7 @@ template<> inline void SkipWhitespace(StringStream& is) { /////////////////////////////////////////////////////////////////////////////// // GenericReader -//! SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator. +//! SAX-style JSON parser. Use \ref Reader for UTF8 encoding and default allocator. /*! GenericReader parses JSON text from a stream, and send events synchronously to an object implementing Handler concept. @@ -276,7 +278,7 @@ template<> inline void SkipWhitespace(StringStream& is) { template > class GenericReader { public: - typedef typename SourceEncoding::Ch Ch; + typedef typename SourceEncoding::Ch Ch; //!< SourceEncoding character type //! Constructor. /*! \param allocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing) @@ -285,12 +287,12 @@ public: GenericReader(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(allocator, stackCapacity), parseErrorCode_(kParseErrorNone), errorOffset_(0) {} //! Parse JSON text. - /*! \tparam parseFlags Combination of ParseFlag. - \tparam InputStream Type of input stream. - \tparam Handler Type of handler which must implement Handler concept. - \param is Input stream to be parsed. - \param handler The handler to receive events. - \return Whether the parsing is successful. + /*! \tparam parseFlags Combination of \ref ParseFlag. + \tparam InputStream Type of input stream, implementing Stream concept. + \tparam Handler Type of handler, implementing Handler concept. + \param is Input stream to be parsed. + \param handler The handler to receive events. + \return Whether the parsing is successful. */ template bool Parse(InputStream& is, Handler& handler) { @@ -321,6 +323,13 @@ public: return !HasParseError(); } + //! Parse JSON text (with \ref kParseDefaultFlags) + /*! \tparam InputStream Type of input stream, implementing Stream concept + \tparam Handler Type of handler, implementing Handler concept. + \param is Input stream to be parsed. + \param handler The handler to receive events. + \return Whether the parsing is successful. + */ template bool Parse(InputStream& is, Handler& handler) { return Parse(is, handler); From b30c3c0538bee19fa6364caf8352399179ce99a6 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:10:43 +0200 Subject: [PATCH 09/76] readme.md: prepare Markdown for GitHub and Doxygen rendering --- readme.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 6c1fa80..98a51eb 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# RapidJSON +# RapidJSON {#mainpage} Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com) @@ -37,7 +37,7 @@ Users can build and run the unit tests on their platform/compiler. ## Installation -RapidJSON is a header-only C++ library. Just copy the `rapidjson/include/rapidjson` folder to system or project's include path. +RapidJSON is a header-only C++ library. Just copy the `include/rapidjson` folder to system or project's include path. To build the tests and examples: @@ -45,15 +45,21 @@ To build the tests and examples: 2. Copy premake4 executable to RapidJSON/build (or system path) 3. Run `rapidjson/build/premake.bat` on Windows, `RapidJSON/build/premake.sh` on Linux or other platforms 4. On Windows, build the solution at `rapidjson/build/vs2008/` or `/vs2010/` -5. On other platforms, run GNU make at `rapidjson/build/gmake/` (e.g., `make -f test.make config=release32`, `make -f example.make config=debug32`) +5. On other platforms, run GNU make at `rapidjson/build/gmake/` (e.g., `make -f test.make config=release32`; `make -f example.make config=debug32`) 6. On success, the executable are generated at `rapidjson/bin` +To build the [Doxygen](http://doxygen.org) documentation: + +1. Obtain and install [Doxygen](http://doxygen.org/download.html). +2. In the top-level directory, run `doxygen build/Doxyfile`. +3. Browse the generated documentation in `doc/html`. + ## Usage at a glance This simple example parses a JSON string into a document (DOM), make a simple modification of the DOM, and finally stringify the DOM to a JSON string. [simpledom.cpp](example/simpledom/simpledom.cpp) -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" #include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" @@ -80,12 +86,12 @@ int main() { std::cout << buffer.GetString() << std::endl; return 0; } -``` +~~~~~~~~~~ Note that this example did not handle potential errors. The following diagram shows the process. -![simpledom](doc/diagram/simpledom.png?raw=true) +![simpledom](doc/diagram/simpledom.png) More [examples](example/) are available. From 2a57d97f632865b3973f9ac07e49e74be3f4b95f Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:11:15 +0200 Subject: [PATCH 10/76] features.md: prepare Markdown for GitHub and Doxygen rendering --- doc/features.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/features.md b/doc/features.md index f5d9355..3cc6309 100644 --- a/doc/features.md +++ b/doc/features.md @@ -39,10 +39,10 @@ ## API styles * SAX (Simple API for XML) style API - * Similar to [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON provides a event sequential access parser API (`GenericReader`). It also provides a generator API (`GenericWriter`) which consumes the same set of events. + * Similar to [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON provides a event sequential access parser API (`rapidjson::GenericReader`). It also provides a generator API (`rapidjson::Writer`) which consumes the same set of events. * DOM (Document Object Model) style API - * Similar to [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) for HTML/XML, RapidJSON can parse JSON into a DOM representation (`GenericDocument`), for easy manipulation, and finally stringify back to JSON if needed. - * The DOM style API (`GenericDocument`) is actually implemented with SAX style API (`GenericReader`). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios. + * Similar to [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) for HTML/XML, RapidJSON can parse JSON into a DOM representation (`rapidjson::GenericDocument`), for easy manipulation, and finally stringify back to JSON if needed. + * The DOM style API (`rapidjson::GenericDocument`) is actually implemented with SAX style API (`rapidjson::GenericReader`). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios. ## DOM (Document) @@ -59,13 +59,13 @@ ## SAX (Writer) -* Support PrettyWriter for adding newlines and indentations. +* Support `rapidjson::PrettyWriter` for adding newlines and indentations. * Support custom precision for floating point values. ## Stream -* Support `GenericStringBuffer` for storing the output JSON as string. -* Support `FileReadStream`/`FileWriteStream` for input/output `FILE` object. +* Support `rapidjson::GenericStringBuffer` for storing the output JSON as string. +* Support `rapidjson::FileReadStream`/`rapidjson::FileWriteStream` for input/output `FILE` object. * Support custom streams. ## Memory From ba05cc137750f138cb40ffd7479c2f9cc98a5fdd Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sat, 5 Jul 2014 17:14:32 +0200 Subject: [PATCH 11/76] tutorial.md: prepare Markdown for GitHub and Doxygen rendering --- doc/tutorial.md | 136 ++++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index eb6a150..804cc6a 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -13,7 +13,7 @@ Each JSON value is stored in a type called `Value`. A `Document`, representing t In this section, we will use excerpt of [`example/tutorial/tutorial.cpp`](../example/tutorial/tutorial.cpp). Assumes we have a JSON text stored in a C string (`const char* json`): -```js +~~~~~~~~~~js { "hello": "world", "t": true , @@ -23,10 +23,10 @@ Assumes we have a JSON text stored in a C string (`const char* json`): "pi": 3.1416, "a": [1, 2, 3, 4] } -``` +~~~~~~~~~~ Parse it into a `Document` -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" using namespace rapidjson; @@ -34,50 +34,50 @@ using namespace rapidjson; // ... Document document; document.Parse(json); -``` +~~~~~~~~~~ The JSON text is now parsed into `document` as a *DOM tree*: -![tutorial](diagram/tutorial.png?raw=true) +![tutorial](diagram/tutorial.png) The root of a conforming JSON should be either an object or an array. In this case, the root is an object. -```cpp +~~~~~~~~~~cpp assert(document.IsObject()); -``` +~~~~~~~~~~ Query whether a `"hello"` member exists in the root object. Since a `Value` can contain different types of value, we may need to verify its type and use suitable API to obtain the value. In this example, `"hello"` member associates with a JSON string. -```cpp +~~~~~~~~~~cpp assert(document.HasMember("hello")); assert(document["hello"].IsString()); printf("hello = %s\n", document["hello"].GetString()); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ world -``` +~~~~~~~~~~ JSON true/false values are represented as `bool`. -```cpp +~~~~~~~~~~cpp assert(document["t"].IsBool()); printf("t = %s\n", document["t"].GetBool() ? "true" : "false"); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ true -``` +~~~~~~~~~~ JSON null can be queryed by `IsNull()`. -```cpp +~~~~~~~~~~cpp printf("n = %s\n", document["n"].IsNull() ? "null" : "?"); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ null -``` +~~~~~~~~~~ JSON number type represents all numeric values. However, C++ needs more specific type for manipulation. -```cpp +~~~~~~~~~~cpp assert(document["i"].IsNumber()); // In this case, IsUint()/IsInt64()/IsUInt64() also return true. @@ -88,28 +88,28 @@ printf("i = %d\n", document["i"].GetInt()); assert(document["pi"].IsNumber()); assert(document["pi"].IsDouble()); printf("pi = %g\n", document["pi"].GetDouble()); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ i = 123 pi = 3.1416 -``` +~~~~~~~~~~ JSON array contains a number of elements. -```cpp +~~~~~~~~~~cpp // Using a reference for consecutive access is handy and faster. const Value& a = document["a"]; assert(a.IsArray()); for (SizeType i = 0; i < a.Size(); i++) // Uses SizeType instead of size_t printf("a[%d] = %d\n", i, a[i].GetInt()); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ a[0] = 1 a[1] = 2 a[2] = 3 a[3] = 4 -``` +~~~~~~~~~~ Note that, RapidJSON does not automatically convert values between JSON types. If a value is a string, it is invalid to call `GetInt()`, for example. In debug mode it will fail an assertion. In release mode, the behavior is undefined. @@ -124,10 +124,10 @@ You may access the elements in array by integer literal, for example, `a[1]`, `a * `a[0u]` Array is similar to `std::vector`, instead of using indices, you may also use iterator to access all the elements. -```cpp +~~~~~~~~~~cpp for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) printf("%d ", itr->GetInt()); -``` +~~~~~~~~~~ And other familiar query functions: * `SizeType Capacity() const` @@ -137,7 +137,7 @@ And other familiar query functions: Similar to array, we can iterate object members by iterator: -```cpp +~~~~~~~~~~cpp static const char* kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" }; @@ -147,9 +147,9 @@ for (Value::ConstMemberIterator itr = document.MemberBegin(); printf("Type of member %s is %s\n", itr->name.GetString(), kTypeNames[itr->value.GetType()]); } -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ Type of member hello is String Type of member t is True Type of member f is False @@ -157,17 +157,17 @@ Type of member n is Null Type of member i is Number Type of member pi is Number Type of member a is Array -``` +~~~~~~~~~~ Note that, when `operator[](const char*)` cannot find the member, it will fail an assertion. If we are unsure whether a member exists, we need to call `HasMember()` before calling `operator[](const char*)`. However, this incurs two lookup. A better way is to call `FindMember()`, which can check the existence of member and obtain its value at once: -```cpp +~~~~~~~~~~cpp Value::ConstMemberIterator itr = document.FindMember("hello"); if (itr != document.MemberEnd()) printf("%s %s\n", itr->value.GetString()); -``` +~~~~~~~~~~ ### Querying Number @@ -210,18 +210,18 @@ To conform RFC 4627, RapidJSON supports string containing `U+0000`. If you need For example, after parsing a the following JSON string to `Document d`. -```js +~~~~~~~~~~js { "s" : "a\u0000b" } -``` +~~~~~~~~~~ The correct length of the value `"a\u0000b"` is 3. But `strlen()` returns 1. `GetStringLength()` can also improve performance, as user may often need to call `strlen()` for allocating buffer. Besides, `std::string` also support a constructor: -```cpp +~~~~~~~~~~cpp string( const char* s, size_type count); -``` +~~~~~~~~~~ which accepts the length of string as parameter. This constructor supports storing null character within the string, and should also provide better performance. @@ -232,43 +232,43 @@ There are several ways to create values. After a DOM tree is created and/or modi ### Changing Value Type When creating a Value or Document by default constructor, its type is Null. To change its type, call `SetXXX()` or assignment operator, for example: -```cpp +~~~~~~~~~~cpp Document d; // Null d.SetObject(); Value v; // Null v.SetInt(10); v = 10; // Shortcut, same as above -``` +~~~~~~~~~~ ### Overloaded Constructors There are also overloaded constructors for several types: -```cpp +~~~~~~~~~~cpp Value b(true); // calls Value(bool) Value i(-123); // calls Value(int) Value u(123u); // calls Value(unsigned) Value d(1.5); // calls Value(double) -``` +~~~~~~~~~~ To create empty object or array, you may use `SetObject()`/`SetArray()` after default constructor, or using the `Value(Type)` in one shot: -```cpp +~~~~~~~~~~cpp Value o(kObjectType); Value a(kArrayType); -``` +~~~~~~~~~~ ### Move Semantics A very special decision during design of RapidJSON is that, assignment of value does not copy the source value to destination value. Instead, the value from source is moved to the destination. For example, -```cpp +~~~~~~~~~~cpp Value a(123); Value b(456); b = a; // a becomes a Null value, b becomes number 123. -``` +~~~~~~~~~~ -![move1](diagram/move1.png?raw=true) +![move1](diagram/move1.png) Why? What is the advantage of this semantics? @@ -276,7 +276,7 @@ The simple answer is performance. For fixed size JSON types (Number, True, False For example, if normal *copy* semantics was used: -```cpp +~~~~~~~~~~cpp Value o(kObjectType); { Value contacts(kArrayType); @@ -285,9 +285,9 @@ Value o(kObjectType); o.AddMember("contacts", contacts); // deep clone contacts (may be with lots of allocations) // destruct contacts. } -``` +~~~~~~~~~~ -![move2](diagram/move2.png?raw=true) +![move2](diagram/move2.png) The object `o` needs to allocate a buffer of same size as contacts, makes a deep clone of it, and then finally contacts is destructed. This will incur a lot of unnecessary allocations/deallocations and memory copying. @@ -297,7 +297,7 @@ To make RapidJSON simple and fast, we chose to use *move* semantics for assignme So, with move semantics, the above example becomes: -```cpp +~~~~~~~~~~cpp Value o(kObjectType); { Value contacts(kArrayType); @@ -305,9 +305,9 @@ Value o(kObjectType); o.AddMember("contacts", contacts); // just memcpy() of contacts itself to the value of new member (16 bytes) // contacts became Null here. Its destruction is trivial. } -``` +~~~~~~~~~~ -![move3](diagram/move3.png?raw=true) +![move3](diagram/move3.png) This is called move assignment operator in C++11. As RapidJSON supports C++03, it adopts move semantics using assignment operator, and all other modifying function like `AddMember()`, `PushBack()`. @@ -323,7 +323,7 @@ To make memory allocation customizable, RapidJSON requires user to pass an insta Therefore, when we assign a copy-string, we call this overloaded `SetString()` with allocator: -```cpp +~~~~~~~~~~cpp Document document; Value author; char buffer[10]; @@ -331,7 +331,7 @@ int len = sprintf(buffer, "%s %s", "Milo", "Yip"); // dynamically created string author.SetString(buffer, len, document.GetAllocator()); memset(buffer, 0, sizeof(buffer)); // author.GetString() still contains "Milo Yip" after buffer is destroyed -``` +~~~~~~~~~~ In this example, we get the allocator from a `Document` instance. This is a common idiom when using RapidJSON. But you may use other instances of allocator. @@ -339,12 +339,12 @@ Besides, the above `SetString()` requires length. This can handle null character Finally, for literal string or string with safe life-cycle can use const-string version of `SetString()`, which lacks allocator parameter: -```cpp +~~~~~~~~~~cpp Value s; s.SetString("rapidjson", 9); // faster, can contain null character s.SetString("rapidjson"); // slower, assumes null-terminated s = "rapidjson"; // shortcut, same as above -``` +~~~~~~~~~~ ### Modify Array Value with array type provides similar APIs as `std::vector`. @@ -359,7 +359,7 @@ Note that, `Reserve(...)` and `PushBack(...)` may allocate memory, therefore req Here is an example of `PushBack()`: -```cpp +~~~~~~~~~~cpp Value a(kArrayType); Document::AllocatorType& allocator = document.GetAllocator(); @@ -368,7 +368,7 @@ for (int i = 5; i <= 10; i++) // Fluent interface a.PushBack("Lua", allocator).PushBack("Mio", allocator); -``` +~~~~~~~~~~ Differs from STL, `PushBack()`/`PopBack()` returns the array reference itself. This is called fluent interface. @@ -382,16 +382,16 @@ Object is a collection of key-value pairs. Each key must be a string value. The Here is an example. -```cpp -Value contact(kObejct); +~~~~~~~~~~cpp +Value contact(kObject); contact.AddMember("name", "Milo", document.GetAllocator()); contact.AddMember("married", true, document.GetAllocator()); -``` +~~~~~~~~~~ ### Deep Copy Value If we really need to copy a DOM tree, we can use two APIs for deep copy: constructor with allocator, and `CopyFrom()`. -```cpp +~~~~~~~~~~cpp Document d; Document::AllocatorType& a = d.GetAllocator(); Value v1("foo"); @@ -406,19 +406,19 @@ v2.CopyFrom(d, a); // copy whole document to v2 assert(d.IsArray() && d.Size() == 2); // d untouched v1.SetObject().AddMember( "array", v2, a ); d.PushBack(v1,a); -``` +~~~~~~~~~~ ### Swap Values `Swap()` is also provided. -```cpp +~~~~~~~~~~cpp Value a(123); Value b("Hello"); a.Swap(b); assert(a.IsString()); assert(b.IsInt()); -``` +~~~~~~~~~~ Swapping two DOM trees is fast (constant time), despite the complexity of the tress. @@ -433,4 +433,4 @@ This tutorial shows the basics of DOM tree query and manipulation. There are sev 5. [Performance](performance.md) shows some in-house and third-party benchmarks. 6. [Internals](internals.md) describes some internal designs and techniques of RapidJSON. -You may also refer to the FAQ, API documentation, examples and unit tests. +You may also refer to the [FAQ](faq.md), API documentation, examples and unit tests. From b197be2f303123afc2482434b22df7041d275885 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sun, 6 Jul 2014 15:14:32 +0200 Subject: [PATCH 12/76] stream.md: prepare Markdown for GitHub and Doxygen rendering --- doc/stream.md | 68 ++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/doc/stream.md b/doc/stream.md index ebc34d5..84d58bc 100644 --- a/doc/stream.md +++ b/doc/stream.md @@ -1,6 +1,6 @@ # RapidJSON Stream -In RapidJSON, `Stream` is a concept for reading/writing JSON. Here we first show how to use streams provided. And then see how to create a custom streams. +In RapidJSON, `rapidjson::Stream` is a concept for reading/writing JSON. Here we first show how to use streams provided. And then see how to create a custom streams. ## Memory Streams @@ -10,7 +10,7 @@ Memory streams store JSON in memory. `StringStream` is the most basic input stream. It represents a complete, read-only JSON stored in memory. It is defined in `rapidjson/rapidjson.h`. -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" // will include "rapidjson/rapidjson.h" using namespace rapidjson; @@ -21,16 +21,16 @@ StringStream s(json); Document d; d.ParseStream(s); -``` +~~~~~~~~~~ Since this is very common usage, `Document::Parse(const char*)` is provided to do exactly the same as above: -```cpp +~~~~~~~~~~cpp // ... const char json[] = "[1, 2, 3, 4]"; Document d; d.Parse(json); -``` +~~~~~~~~~~ Note that, `StringStream` is a typedef of `GenericStringStream >`, user may use another encodings to represent the character set of the stream. @@ -38,7 +38,7 @@ Note that, `StringStream` is a typedef of `GenericStringStream >`, user m `StringBuffer` is a simple output stream. It allocates a memory buffer for writing the whole JSON. Use `GetString()` to obtain the buffer. -```cpp +~~~~~~~~~~cpp #include "rapidjson/stringbuffer.h" StringBuffer buffer; @@ -46,14 +46,14 @@ Writer writer(buffer); d.Accept(writer); const char* output = buffer.GetString(); -``` +~~~~~~~~~~ When the buffer is full, it will increases the capacity automatically. The default capacity is 256 characters (256 bytes for UTF8, 512 bytes for UTF16, etc.). User can provide an allocator and a initial capacity. -```cpp +~~~~~~~~~~cpp StringBuffer buffer1(0, 1024); // Use its allocator, initial size = 1024 StringBuffer buffer2(allocator, 1024); -``` +~~~~~~~~~~ By default, `StringBuffer` will instantiate an internal allocator. @@ -69,10 +69,12 @@ However, if the JSON is big, or memory is limited, you can use `FileReadStream`. `FileReadStream` reads the file via a `FILE` pointer. And user need to provide a buffer. -```cpp +~~~~~~~~~~cpp #include "rapidjson/filereadstream.h" #include +using namespace rapidjson; + FILE* fp = fopen("big.json", "rb"); // non-Windows use "r" char readBuffer[65536]; @@ -82,7 +84,7 @@ Document d; d.ParseStream(is); fclose(fp); -``` +~~~~~~~~~~ Different from string streams, `FileReadStream` is byte stream. It does not handle encodings. If the file is not UTF-8, the byte stream can be wrapped in a `EncodedInputStream`. It will be discussed very soon. @@ -92,10 +94,12 @@ Apart from reading file, user can also use `FileReadStream` to read `stdin`. `FileWriteStream` is buffered output stream. Its usage is very similar to `FileReadStream`. -```cpp +~~~~~~~~~~cpp #include "rapidjson/filewritestream.h" #include +using namespace rapidjson; + Document d; d.Parse(json); // ... @@ -109,7 +113,7 @@ Writer writer(os); d.Accept(writer); fclose(fp); -``` +~~~~~~~~~~ It can also directs the output to `stdout`. @@ -129,7 +133,7 @@ Note that, these encoded streams can be applied to streams other than file. For `EncodedInputStream` has two template parameters. The first one is a `Encoding` class, such as `UTF8`, `UTF16LE`, defined in `rapidjson/encodings.h`. The second one is the class of stream to be wrapped. -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" #include "rapidjson/filereadstream.h" // FileReadStream #include "rapidjson/encodedstream.h" // EncodedInputStream @@ -148,13 +152,13 @@ Document d; // Document is GenericDocument > d.ParseStream<0, UTF16LE<> >(eis); // Parses UTF-16LE file into UTF-8 in memory fclose(fp); -``` +~~~~~~~~~~ ### EncodedOutputStream `EncodedOutputStream` is similar but it has a `bool putBOM` parameter in the constructor, controlling whether to write BOM into output byte stream. -```cpp +~~~~~~~~~~cpp #include "rapidjson/filewritestream.h" // FileWriteStream #include "rapidjson/encodedstream.h" // EncodedOutputStream #include @@ -174,7 +178,7 @@ Writer, UTF8<>> writer(eos); d.Accept(writer); // This generates UTF32-LE file from UTF-8 in memory fclose(fp); -``` +~~~~~~~~~~ ### AutoUTFInputStream @@ -182,7 +186,7 @@ Sometimes an application may want to handle all supported JSON encoding. `AutoUT Since the characters (code units) may be 8-bit, 16-bit or 32-bit. `AutoUTFInputStream` requires a character type which can hold at least 32-bit. We may use `unsigned`, as in the template parameter: -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" #include "rapidjson/filereadstream.h" // FileReadStream #include "rapidjson/encodedstream.h" // AutoUTFInputStream @@ -201,7 +205,7 @@ Document d; // Document is GenericDocument > d.ParseStream<0, AutoUTF >(eis); // This parses any UTF file into UTF-8 in memory fclose(fp); -``` +~~~~~~~~~~ When specifying the encoding of stream, uses `AutoUTF` as in `ParseStream()` above. @@ -211,7 +215,9 @@ You can obtain the type of UTF via `UTFType GetType()`. And check whether a BOM Similarly, to choose encoding for output during runtime, we can use `AutoUTFOutputStream`. This class is not automatic *per se*. You need to specify the UTF type and whether to write BOM in runtime. -```cpp +~~~~~~~~~~cpp +using namespace rapidjson; + void WriteJSONFile(FILE* fp, UTFType type, bool putBOM, const Document& d) { char writeBuffer[256]; FileWriteStream bos(fp, writeBuffer, sizeof(writeBuffer)); @@ -222,7 +228,7 @@ void WriteJSONFile(FILE* fp, UTFType type, bool putBOM, const Document& d) { Writer, AutoUTF<> > writer; d.Accept(writer); } -``` +~~~~~~~~~~ `AutoUTFInputStream` and `AutoUTFOutputStream` is more convenient than `EncodedInputStream` and `EncodedOutputStream`. They just incur a little bit runtime overheads. @@ -232,7 +238,7 @@ In addition to memory/file streams, user can create their own stream classes whi RapidJSON combines different types using templates. A class containing all required interface can be a stream. The Stream interface is defined in comments of `rapidjson/rapidjson.h`: -```cpp +~~~~~~~~~~cpp concept Stream { typename Ch; //!< Character type of the stream. @@ -261,7 +267,7 @@ concept Stream { //! \return Number of characters written. size_t PutEnd(Ch* begin); } -``` +~~~~~~~~~~ For input stream, they must implement `Peek()`, `Take()` and `Tell()`. For output stream, they must implement `Put()` and `Flush()`. @@ -271,7 +277,7 @@ There are two special interface, `PutBegin()` and `PutEnd()`, which are only for The following example is a wrapper of `std::istream`, which only implements 3 functions. -```cpp +~~~~~~~~~~cpp class IStreamWrapper { public: typedef char Ch; @@ -302,18 +308,18 @@ private: std::istream& is_; }; -``` +~~~~~~~~~~ User can use it to wrap instances of `std::stringstream`, `std::ifstream`. -```cpp +~~~~~~~~~~cpp const char* json = "[1,2,3,4]"; std::stringstream ss(json); IStreamWrapper is(ss); Document d; d.Parse(is); -``` +~~~~~~~~~~ Note that, this implementation may not be as efficient as RapidJSON's memory or file streams, due to internal overheads of the standard library. @@ -321,7 +327,7 @@ Note that, this implementation may not be as efficient as RapidJSON's memory or The following example is a wrapper of `std::istream`, which only implements 2 functions. -```cpp +~~~~~~~~~~cpp class OStreamWrapper { public: typedef char Ch; @@ -344,11 +350,11 @@ private: std::ostream& os_; }; -``` +~~~~~~~~~~ User can use it to wrap instances of `std::stringstream`, `std::ofstream`. -```cpp +~~~~~~~~~~cpp Document d; // ... @@ -357,7 +363,7 @@ OSStreamWrapper os(ss); Writer writer(os); d.Accept(writer); -``` +~~~~~~~~~~ Note that, this implementation may not be as efficient as RapidJSON's memory or file streams, due to internal overheads of the standard library. From a213d2d881962bbb2a3b271b58584c2ef3d3c6f0 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sun, 6 Jul 2014 16:39:23 +0200 Subject: [PATCH 13/76] Doxygen: fixup main page To avoid the {#mainpage} tag to be rendered on GitHub, explicitly add a `\mainpage` section to `rapidjson.h`, referring to `readme.md`. --- include/rapidjson/rapidjson.h | 4 ++++ readme.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index bd500bc..b6cb2f4 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -10,6 +10,10 @@ \todo Complete Doxygen documentation for configure macros. */ +/*! \mainpage + Documentation can be found in \ref readme.md README. +*/ + #include // malloc(), realloc(), free() #include // memcpy() diff --git a/readme.md b/readme.md index 98a51eb..1741d91 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# RapidJSON {#mainpage} +# RapidJSON Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com) From 4cadecd32d6159aae434a64b35aa8a59ea9dca58 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sun, 6 Jul 2014 22:43:21 +0800 Subject: [PATCH 14/76] Wrote DOM But some examples are to be filled in. --- doc/diagram/insituparsing.dot | 65 +++++++++ doc/diagram/insituparsing.png | Bin 0 -> 24085 bytes doc/diagram/normalparsing.dot | 56 ++++++++ doc/diagram/normalparsing.png | Bin 0 -> 22674 bytes doc/dom.md | 254 +++++++++++++++++++++++++++++++++- 5 files changed, 373 insertions(+), 2 deletions(-) create mode 100644 doc/diagram/insituparsing.dot create mode 100644 doc/diagram/insituparsing.png create mode 100644 doc/diagram/normalparsing.dot create mode 100644 doc/diagram/normalparsing.png diff --git a/doc/diagram/insituparsing.dot b/doc/diagram/insituparsing.dot new file mode 100644 index 0000000..eca0e38 --- /dev/null +++ b/doc/diagram/insituparsing.dot @@ -0,0 +1,65 @@ +digraph { + compound=true + fontname="Inconsolata, Consolas" + fontsize=10 + margin="0,0" + ranksep=0.2 + penwidth=0.5 + + node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5] + edge [fontname="Inconsolata, Consolas", fontsize=10, arrowhead=normal] + + { + node [shape=record, fontsize="8", margin="0.04", height=0.2, color=gray] + oldjson [label="\{|\"|m|s|g|\"|:|\"|H|e|l|l|o|\\|n|W|o|r|l|d|!|\"|,|\"|\\|u|0|0|7|3|t|a|r|s|\"|:|1|0|\}", xlabel="Before Parsing"] + //newjson [label="\{|\"|m|s|g|\\0|:|\"|H|e|l|l|o|\\n|W|o|r|l|d|!|\\0|\"|,|\"|s|t|a|r|s|\\0|t|a|r|s|:|1|0|\}", xlabel="After Parsing"] + newjson [shape=plaintext, label=< + + + + + + + + + + +
{"msg\\0:"Hello\\nWorld!\\0","stars\\0tars:10}
+>, xlabel="After Parsing"] + } + + subgraph cluster1 { + margin="10,10" + labeljust="left" + label = "Document by In situ Parsing" + style=filled + fillcolor=gray95 + node [shape=Mrecord, style=filled, colorscheme=spectral7] + + root [label="{object|}", fillcolor=3] + + { + msg [label="{string|
}", fillcolor=5] + helloworld [label="{string|}", fillcolor=5] + stars [label="{string|}", fillcolor=5] + ten [label="{number|10}", fillcolor=6] + } + } + + oldjson -> root [label=" ParseInsitu()" lhead="cluster1"] + edge [arrowhead=vee] + root -> { msg; stars } + + edge [arrowhead="none"] + msg -> helloworld + stars -> ten + + { + edge [arrowhead=vee, arrowtail=dot, arrowsize=0.5, dir=both, tailclip=false] + msg:a:c -> newjson:a + helloworld:a:c -> newjson:b + stars:a:c -> newjson:c + } + + //oldjson -> newjson [style=invis] +} \ No newline at end of file diff --git a/doc/diagram/insituparsing.png b/doc/diagram/insituparsing.png new file mode 100644 index 0000000000000000000000000000000000000000..27b2572d95671e2f125ff8eb9e557932e858e2a6 GIT binary patch literal 24085 zcmcG$2UL{H)-BqIilV|s1Oy2N5DAJBL_k0#NtT>JL9*l=8ZaUvpajVvL2?ku8AY;y z=i|x_jK>sIPZBfk<54 z8~W9GdRj2x@>F{`3rEreDI0QAoIlH%b&;LEo8p%_HLccCWUF3ZpKABit73~_xl(Hu zftAdN{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iBZ|&2JBTqWnkuSG*rd zm(iRkl#K%mM%62da;Tt|Z(g@Vzh%uDk31J{Zr(tvDD|%w&Cy%EowaE;Dh-VF-t<9g z;d&GDvkwbZ#wUCDQEYNr+Mc-PaKne(ry=$!Dy^F4<;+uVE9bh~IN@9P)daY0AZ`l0 zyORKR0>Q_|8iH#r=01&oic|8=+h)rf=5ls2+FkN-LN7UKB!E+e|X zrA|UElS5MKOKERc(1>be8dS7zJQ6Pd&%y%FL8h*#raC zz_7l*I8+r&F-#~o+L?G?nEJfor*9Zj-^zz-NwgYRs`h%a{ov^##RjeB_aaB)>=*J( z31wGDD-1?&XOCiG?^(5v`jdR@Y00Tqm}NGSQtg@z;U5o2MsBb=E?Lj6-HfUL%Nn@< z;)QfGGYNQp5X=rOerBKVXs~R$1J!sI=)pFo$`IvD^w?H}IrB`M>2_AXdzC!MH<2R+?WVbgh01_dy^tqPWU}4$0^!POEi& zubXjhY2C-E={LXIJgCf8Tq>%d33zP>Du87)7wrSNsH(cIlcS<%)^=d+ed*h&j1E9O z>Uh^BZ*dt&Jid5kiMuMKpANa!YYPL4QH>5LRF-D2otH3r)ejI|P$aCah>#Ki9)w>| z5T_*a-`6bcyS+gFjS|rLNhLQXYmU1A0txePum^!BiX)OVz+os)*w`59<{51P4jmMD z0ik*dpot@f!_|zwsYpJS>j#kzFMP|4wqqJdK zkv~ZaO&eGZV63jas>Vf}vfuUN(VY1$*_|$V3!D&jeqp;}HH|Ghj8U literal 0 HcmV?d00001 diff --git a/doc/diagram/normalparsing.dot b/doc/diagram/normalparsing.dot new file mode 100644 index 0000000..b15941b --- /dev/null +++ b/doc/diagram/normalparsing.dot @@ -0,0 +1,56 @@ +digraph { + compound=true + fontname="Inconsolata, Consolas" + fontsize=10 + margin="0,0" + ranksep=0.2 + penwidth=0.5 + + node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5] + edge [fontname="Inconsolata, Consolas", fontsize=10, arrowhead=normal] + + { + node [shape=record, fontsize="8", margin="0.04", height=0.2, color=gray] + normaljson [label="\{|\"|m|s|g|\"|:|\"|H|e|l|l|o|\\|n|W|o|r|l|d|!|\"|,|\"|\\|u|0|0|7|3|t|a|r|s\"|:|1|0|\}"] + + { + rank = same + msgstring [label="m|s|g|\\0"] + helloworldstring [label="H|e|l|l|o|\\n|W|o|r|l|d|!|\\0"] + starsstring [label="s|t|a|r|s\\0"] + } + } + + subgraph cluster1 { + margin="10,10" + labeljust="left" + label = "Document by Normal Parsing" + style=filled + fillcolor=gray95 + node [shape=Mrecord, style=filled, colorscheme=spectral7] + + root [label="{object|}", fillcolor=3] + + { + msg [label="{string|}", fillcolor=5] + helloworld [label="{string|}", fillcolor=5] + stars [label="{string|}", fillcolor=5] + ten [label="{number|10}", fillcolor=6] + } + } + + normaljson -> root [label=" Parse()" lhead="cluster1"] + edge [arrowhead=vee] + root -> { msg; stars } + + edge [arrowhead="none"] + msg -> helloworld + stars -> ten + + edge [arrowhead=vee, arrowtail=dot, arrowsize=0.5, dir=both, tailclip=false] + msg:a:c -> msgstring:w + helloworld:a:c -> helloworldstring:w + stars:a:c -> starsstring:w + + msgstring -> helloworldstring -> starsstring [style=invis] +} \ No newline at end of file diff --git a/doc/diagram/normalparsing.png b/doc/diagram/normalparsing.png new file mode 100644 index 0000000000000000000000000000000000000000..7e9ff7df87d1c183456960f40c43bb5c83273274 GIT binary patch literal 22674 zcmb@ubzGKhvo?wW2-4jMA|)UxNJ^t3NJvPBq;$7Rcb5_hNT-x^Ng0$N-O?c4_09FX z>)mUuZ+~m={m1tCJwN33iZkY%nd6va?%-z%ve=jum?$VH*pK9-lu=NwN}`}#ak+s8 zpJWRvHoy-w!zZ#*D3{289~yFEQBZE7JdzSubxm2HbWtT5o<`d;HP7gf4!XmfAVu`V zk68wrB%@5~wliC9S;nn*X0Q5R%ak!BFoclBjp*TDd&jJ_PE5>(&p=Xom*gv2aK_cT zP1@r!d=~4bo4cMp+pl>%mPG4Z44QsSBuBHvKfV(Lf3jBMl9#Vb!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in-memory representation of JSON for query and manipulation. The basic usage of DOM is described in [Tutorial](tutorial.md). This section will describe some details and more advanced usages. + ## Template +In the tutorial, `Value` and `Document` was used. Similarly to `std::string`, these are actually `typedef` of template classes: + +~~~~~~~~~~cpp +template > +class GenericValue { + // ... +}; + +template > +class GenericDocument : public GenericValue { + // ... +}; + +typedef GenericValue > Value; +typedef GenericDocument > Document; +~~~~~~~~~~ + +User can customize these template parameters. + ### Encoding +The `Encoding` parameter specifies the encoding of JSON String value in memory. Possible options are `UTF8`, `UTF16`, `UTF32`. Note that, these 3 types are also template class. `UTF8<>` is `UTF8`, which means using char to store the characters. You may refer to [Encoding](encoding.md) for details. + +Suppose a Windows application would query localization strings stored in JSON files. Unicode-enabled functions in Windows use UTF-16 (wide character) encoding. No matter what encoding was used in JSON files, we can store the strings in UTF-16 in memory. + +~~~~~~~~~~cpp +typedef GenericDocument > WDocument; +typedef GenericValue > WValue; + +FILE* fp = fopen("localization.json", "rb"); // non-Windows use "r" + +char readBuffer[256]; +FileReadStream bis(fp, readBuffer, sizeof(readBuffer)); + +AutoUTFInputStream eis(bis); // wraps bis into eis + +WDocument d; +d.ParseStream<0, AutoUTF >(eis); + +const WValue locale(L"ja"); // Japanese + +MessageBoxW(hWnd, d[locale].GetString(), L"Test", MB_OK); +~~~~~~~~~~ + ### Allocator +The `Allocator` defines which allocator class is used when allocating/deallocating memory for `Document`/`Value`. `Document` owns, or references to an `Allocator` instance. On the other hand, `Value` does not do so, in order to reduce memory consumption. + +The default allocator used in `GenericDocument` is `MemoryPoolAllocator`. This allocator actually allocate memory sequentially, and cannot deallocate one by one. This is very suitable when parsing a JSON to generate a DOM tree. + +Another allocator is `CrtAllocator`, of which CRT is short for C RunTime library. This allocator simply calls the standard `malloc()`/`realloc()`/`free()`. When there is a lot of add and remove operations, this allocator may be preferred. But this allocator is far less efficient than `MemoryPoolAllocator`. + ## Parsing +`Document` provides several functions for parsing. In below, (1) is the fundamental function, while the others are helpers which call (1). + +~~~~~~~~~~cpp +// (1) Fundamental +template +GenericDocument& ParseStream(InputStream& is); + +// (2) Using the same Encoding for stream +template +GenericDocument& ParseStream(InputStream& is); + +// (3) Using default parse flags +template +GenericDocument& ParseStream(InputStream& is); + +// (4) In situ parsing +template +GenericDocument& ParseInsitu(Ch* str); + +// (5) In situ parsing, using same Encoding for stream +template +GenericDocument& ParseInsitu(Ch* str); + +// (6) In situ parsing, using default parse flags +GenericDocument& ParseInsitu(Ch* str); + +// (7) Normal parsing of a string +template +GenericDocument& Parse(const Ch* str); + +// (8) Normal parsing of a string, using same Encoding for stream +template +GenericDocument& Parse(const Ch* str); + +// (9) Normal parsing of a string, using default parse flags +GenericDocument& Parse(const Ch* str); +~~~~~~~~~~ + +The examples of [tutorial](tutorial.md) uses (9) for normal parsing of string. The examples of [stream](stream.md) uses the first three. *In situ* parsing will be described soon. + +The `parseFlags` are combination of the following bit-flags: + +Parse flags | Meaning +------------------------------|----------------------------------- +`kParseDefaultFlags = 0` | Default parse flags. +`kParseInsituFlag` | In-situ(destructive) parsing. +`kParseValidateEncodingFlag` | Validate encoding of JSON strings. + +By using a non-type template parameter, instead of a function parameter, C++ compiler can generate code which is optimized for specified combinations, improving speed, and reducing code size (if only using a single specialization). The downside is the flags needed to be determined in compile-time. + +The `SourceEncoding` parameter defines what encoding is in the stream. This can be differed to the `Encoding` of the `Document`. See [Transcoding and Validation](#transcoding-and-validation) section for details. + +And the `InputStream` is type of input stream. + ### Parse Error -### In situ Parsing +When the parse processing succeeded, the `Document` contains the parse results. When there is an error, the original DOM is *unchanged*. And the error state of parsing can be obtained by `bool HasParseError()`, `ParseErrorCode GetParseError()` and `size_t GetParseOffet()`. + +Parse Error Code | Description +--------------------------------------------|--------------------------------------------------- +`kParseErrorNone` | No error. +Document: | +`kParseErrorDocumentEmpty` | The document is empty. +`kParseErrorDocumentRootNotObjectOrArray` | The document root must be either object or array. +`kParseErrorDocumentRootNotSingular` | The document root must not follow by other values. +Value: | +`kParseErrorValueInvalid` | Invalid value. +Object: | +`kParseErrorObjectMissName` | Missing a name for object member. +`kParseErrorObjectMissColon` | Missing a colon after a name of object member. +`kParseErrorObjectMissCommaOrCurlyBracket` | Missing a comma or `}` after an object member. +Array: | +`kParseErrorArrayMissCommaOrSquareBracket` | Missing a comma or `]` after an array element. +String: | +`kParseErrorStringUnicodeEscapeInvalidHex` | Incorrect hex digit after `\\u` escape in string. +`kParseErrorStringUnicodeSurrogateInvalid` | The surrogate pair in string is invalid. +`kParseErrorStringEscapeInvalid` | Invalid escape character in string. +`kParseErrorStringMissQuotationMark` | Missing a closing quotation mark in string. +`kParseErrorStringInvalidEncoding` | Invalid encoding in string. +Number: | +`kParseErrorNumberTooBig` | Number too big to be stored in `double`. +`kParseErrorNumberMissFraction` | Miss fraction part in number. +`kParseErrorNumberMissExponent` | Miss exponent in number. + +The offset of error is defined as the character number from beginning of stream. Currently RapidJSON does not keep track of line number. + +To get an error message, RapidJSON provided a English messages in `rapidjson/error/en.h`. User can customize it for other locales, or use a custom localization system. + +Here shows an example of parse error handling. + +~~~~~~~~~~cpp +// TODO: example +~~~~~~~~~~ + +### In Situ Parsing + +From [Wikipedia](http://en.wikipedia.org/wiki/In_situ): + +> *In situ* ... is a Latin phrase that translates literally to "on site" or "in position". It means "locally", "on site", "on the premises" or "in place" to describe an event where it takes place, and is used in many different contexts. + +> ... + +> (In computer science) An algorithm is said to be an in situ algorithm, or in-place algorithm, if the extra amount of memory required to execute the algorithm is O(1), that is, does not exceed a constant no matter how large the input. For example, heapsort is an in situ sorting algorithm. + +In normal parsing process, a large overhead is to decode JSON strings and copy them to other buffers. *In situ* parsing decodes those JSON string at the place where it is stored. It is possible in JSON because the decoded string is always shorter than the one in JSON. In this context, decoding a JSON string means to process the escapes, such as `"\n"`, `"\u1234"`, etc., and add a null terminator (`'\0'`)at the end of string. + +The following diagrams compare normal and *in situ* parsing. The JSON string values contain pointers to the decoded string. + +![normal parsing](diagrams/normalparsing.png) + +In normal parsing, the decoded string are copied to freshly allocated buffers. `"\\n"` (2 characters) is decoded as `"\n"` (1 character). `"\\u0073"` (6 characters) is decoded as "s" (1 character). + +![instiu parsing](diagrams/insituparsing.png) + +*In situ* parsing just modified the original JSON. Updated characters are highlighted in the diagram. If the JSON string does not contain escape character, such as `"msg"`, the parsing process merely replace the closing double quotation mark with a null character. + +Since *in situ* parsing modify the input, the parsing API needs `char*` instead of `const char*`. + +~~~~~~~~~~cpp +// Read whole file into a buffer +FILE* fp = fopen("test.json", "r"); +fseek(fp, 0, SEEK_END); +size_t filesize = (size_t)ftell(fp); +fseek(fp, 0, SEEK_SET); +char* buffer = (char*)malloc(filesize + 1); +size_t readLength = fread(buffer, 1, filesize, fp); +buffer[readLength] = '\0'; +fclose(fp); + +// In situ parsing the buffer into d, buffer will also be modified +Document d; +d.ParseInsitu(buffer); + +// Query/manipulate the DOM here... + +free(buffer); +// Note: At this point, d may have dangling pointers pointed to the deallocated buffer. +~~~~~~~~~~ + +The JSON strings are marked as constant-string. But they may not be really "constant". The life cycle of it depends on the JSON buffer. + +In situ parsing minimizes allocation overheads and memory copying. Generally this improves cache coherence, which is an important factor of performance in modern computer. + +There are some limitations of *in situ* parsing: + +1. The whole JSON is in memory. +2. The source encoding in stream and target encoding in document must be the same. +3. The buffer need to be retained until the document is no longer used. +4. If the DOM need to be used for long period after parsing, and there are few JSON strings in the DOM, retaining the buffer may be a memory waste. + +*In situ* parsing is mostly suitable for short-term JSON that only need to be processed once, and then be released from memory. In practice, these situation is very common, for example, deserializing JSON to C++ objects, processing web requests represented in JSON, etc. + +### Transcoding and Validation + +RapidJSON supports conversion between Unicode formats (officially termed UCS Transformation Format) internally. During DOM parsing, the source encoding of the stream can be different from the encoding of the DOM. For example, the source stream contains a UTF-8 JSON, while the DOM is using UTF-16 encoding. There is an example code in [EncodedInputStream](stream.md#encodedinputstream). + +When writing a JSON from DOM to output stream, transcoding can also be used. An example is in [EncodedOutputStream](stream.md##encodedoutputstream). + +During transcoding, the source string is decoded to into Unicode code points, and then the code points are encoded in the target format. During decoding, it will validate the byte sequence in the source string. If it is not a valid sequence, the parser will be stopped with `kParseErrorStringInvalidEncoding` error. + +When the source encoding of stream is the same as encoding of DOM, by default, the parser will *not* validate the sequence. User may use `kParseValidateEncodingFlag` to force validation. ## Techniques -### DOM as SAX Generator +Some techniques about using DOM API is discussed here. + +### DOM as SAX Event Publisher + +In RapidJSON, stringifying a DOM with `Writer` may be look a little bit weired. + +~~~~~~~~~~cpp +// ... +Writer writer(buffer); +d.Accept(writer); +~~~~~~~~~~ + +Actually, `Value::Accept()` is responsible for publishing SAX events about the value to the handler. With this design, `Value` and `Writer` are decoupled. `Value` can generate SAX events, and `Writer` can handle those events. + +User may create customer handlers for transforming the DOM into other formats. For example, a handler which converts the DOM into XML. + +~~~~~~~~~~cpp +// TODO: example +~~~~~~~~~~ + +For more about SAX events and handler, please refer to [SAX](sax.md). + +### User Buffer + +Some applications may try to avoid memory allocations whenever possible. + +`MemoryPoolAllocator` can support this by letting user to provide a buffer. The buffer can be on the program stack, or a "scratch buffer" which is statically allocated (a static/global array) for storing temporary data. + +`MemoryPoolAllocator` will use the user buffer to satisfy allocations. When the user buffer is used up, it will allocate a chunk of memory from the base allocator (by default the `CrtAllocator`). + +Here is an example of using stack memory. + +~~~~~~~~~~cpp +char buffer[1024]; +MemoryPoolAllocator allocator(buffer, sizeof(buffer)); + +Document d(&allocator); +d.Parse(json); +~~~~~~~~~~ + +If the total size of allocation is less than 1024 during parsing, this code does not invoke any heap allocation (via `new` or `malloc()`) at all. + +User can query the current memory consumption in bytes via `MemoryPoolAllocator::Size()`. And then user can determine a suitable size of user buffer. \ No newline at end of file From 698496e3f37d785352d971faa3c9c46704cf12fc Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sun, 6 Jul 2014 22:43:52 +0800 Subject: [PATCH 15/76] Minor document adjustments --- doc/stream.md | 60 ++++++++++----------- doc/tutorial.md | 140 ++++++++++++++++++++++++------------------------ 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/doc/stream.md b/doc/stream.md index ebc34d5..441dbaa 100644 --- a/doc/stream.md +++ b/doc/stream.md @@ -10,7 +10,7 @@ Memory streams store JSON in memory. `StringStream` is the most basic input stream. It represents a complete, read-only JSON stored in memory. It is defined in `rapidjson/rapidjson.h`. -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" // will include "rapidjson/rapidjson.h" using namespace rapidjson; @@ -21,16 +21,16 @@ StringStream s(json); Document d; d.ParseStream(s); -``` +~~~~~~~~~~ Since this is very common usage, `Document::Parse(const char*)` is provided to do exactly the same as above: -```cpp +~~~~~~~~~~cpp // ... const char json[] = "[1, 2, 3, 4]"; Document d; d.Parse(json); -``` +~~~~~~~~~~ Note that, `StringStream` is a typedef of `GenericStringStream >`, user may use another encodings to represent the character set of the stream. @@ -38,7 +38,7 @@ Note that, `StringStream` is a typedef of `GenericStringStream >`, user m `StringBuffer` is a simple output stream. It allocates a memory buffer for writing the whole JSON. Use `GetString()` to obtain the buffer. -```cpp +~~~~~~~~~~cpp #include "rapidjson/stringbuffer.h" StringBuffer buffer; @@ -46,14 +46,14 @@ Writer writer(buffer); d.Accept(writer); const char* output = buffer.GetString(); -``` +~~~~~~~~~~ When the buffer is full, it will increases the capacity automatically. The default capacity is 256 characters (256 bytes for UTF8, 512 bytes for UTF16, etc.). User can provide an allocator and a initial capacity. -```cpp +~~~~~~~~~~cpp StringBuffer buffer1(0, 1024); // Use its allocator, initial size = 1024 StringBuffer buffer2(allocator, 1024); -``` +~~~~~~~~~~ By default, `StringBuffer` will instantiate an internal allocator. @@ -69,7 +69,7 @@ However, if the JSON is big, or memory is limited, you can use `FileReadStream`. `FileReadStream` reads the file via a `FILE` pointer. And user need to provide a buffer. -```cpp +~~~~~~~~~~cpp #include "rapidjson/filereadstream.h" #include @@ -82,7 +82,7 @@ Document d; d.ParseStream(is); fclose(fp); -``` +~~~~~~~~~~ Different from string streams, `FileReadStream` is byte stream. It does not handle encodings. If the file is not UTF-8, the byte stream can be wrapped in a `EncodedInputStream`. It will be discussed very soon. @@ -92,7 +92,7 @@ Apart from reading file, user can also use `FileReadStream` to read `stdin`. `FileWriteStream` is buffered output stream. Its usage is very similar to `FileReadStream`. -```cpp +~~~~~~~~~~cpp #include "rapidjson/filewritestream.h" #include @@ -109,7 +109,7 @@ Writer writer(os); d.Accept(writer); fclose(fp); -``` +~~~~~~~~~~ It can also directs the output to `stdout`. @@ -129,7 +129,7 @@ Note that, these encoded streams can be applied to streams other than file. For `EncodedInputStream` has two template parameters. The first one is a `Encoding` class, such as `UTF8`, `UTF16LE`, defined in `rapidjson/encodings.h`. The second one is the class of stream to be wrapped. -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" #include "rapidjson/filereadstream.h" // FileReadStream #include "rapidjson/encodedstream.h" // EncodedInputStream @@ -148,13 +148,13 @@ Document d; // Document is GenericDocument > d.ParseStream<0, UTF16LE<> >(eis); // Parses UTF-16LE file into UTF-8 in memory fclose(fp); -``` +~~~~~~~~~~ ### EncodedOutputStream `EncodedOutputStream` is similar but it has a `bool putBOM` parameter in the constructor, controlling whether to write BOM into output byte stream. -```cpp +~~~~~~~~~~cpp #include "rapidjson/filewritestream.h" // FileWriteStream #include "rapidjson/encodedstream.h" // EncodedOutputStream #include @@ -174,7 +174,7 @@ Writer, UTF8<>> writer(eos); d.Accept(writer); // This generates UTF32-LE file from UTF-8 in memory fclose(fp); -``` +~~~~~~~~~~ ### AutoUTFInputStream @@ -182,7 +182,7 @@ Sometimes an application may want to handle all supported JSON encoding. `AutoUT Since the characters (code units) may be 8-bit, 16-bit or 32-bit. `AutoUTFInputStream` requires a character type which can hold at least 32-bit. We may use `unsigned`, as in the template parameter: -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" #include "rapidjson/filereadstream.h" // FileReadStream #include "rapidjson/encodedstream.h" // AutoUTFInputStream @@ -201,7 +201,7 @@ Document d; // Document is GenericDocument > d.ParseStream<0, AutoUTF >(eis); // This parses any UTF file into UTF-8 in memory fclose(fp); -``` +~~~~~~~~~~ When specifying the encoding of stream, uses `AutoUTF` as in `ParseStream()` above. @@ -211,7 +211,7 @@ You can obtain the type of UTF via `UTFType GetType()`. And check whether a BOM Similarly, to choose encoding for output during runtime, we can use `AutoUTFOutputStream`. This class is not automatic *per se*. You need to specify the UTF type and whether to write BOM in runtime. -```cpp +~~~~~~~~~~cpp void WriteJSONFile(FILE* fp, UTFType type, bool putBOM, const Document& d) { char writeBuffer[256]; FileWriteStream bos(fp, writeBuffer, sizeof(writeBuffer)); @@ -222,7 +222,7 @@ void WriteJSONFile(FILE* fp, UTFType type, bool putBOM, const Document& d) { Writer, AutoUTF<> > writer; d.Accept(writer); } -``` +~~~~~~~~~~ `AutoUTFInputStream` and `AutoUTFOutputStream` is more convenient than `EncodedInputStream` and `EncodedOutputStream`. They just incur a little bit runtime overheads. @@ -232,7 +232,7 @@ In addition to memory/file streams, user can create their own stream classes whi RapidJSON combines different types using templates. A class containing all required interface can be a stream. The Stream interface is defined in comments of `rapidjson/rapidjson.h`: -```cpp +~~~~~~~~~~cpp concept Stream { typename Ch; //!< Character type of the stream. @@ -261,7 +261,7 @@ concept Stream { //! \return Number of characters written. size_t PutEnd(Ch* begin); } -``` +~~~~~~~~~~ For input stream, they must implement `Peek()`, `Take()` and `Tell()`. For output stream, they must implement `Put()` and `Flush()`. @@ -271,7 +271,7 @@ There are two special interface, `PutBegin()` and `PutEnd()`, which are only for The following example is a wrapper of `std::istream`, which only implements 3 functions. -```cpp +~~~~~~~~~~cpp class IStreamWrapper { public: typedef char Ch; @@ -302,18 +302,18 @@ private: std::istream& is_; }; -``` +~~~~~~~~~~ User can use it to wrap instances of `std::stringstream`, `std::ifstream`. -```cpp +~~~~~~~~~~cpp const char* json = "[1,2,3,4]"; std::stringstream ss(json); IStreamWrapper is(ss); Document d; d.Parse(is); -``` +~~~~~~~~~~ Note that, this implementation may not be as efficient as RapidJSON's memory or file streams, due to internal overheads of the standard library. @@ -321,7 +321,7 @@ Note that, this implementation may not be as efficient as RapidJSON's memory or The following example is a wrapper of `std::istream`, which only implements 2 functions. -```cpp +~~~~~~~~~~cpp class OStreamWrapper { public: typedef char Ch; @@ -344,11 +344,11 @@ private: std::ostream& os_; }; -``` +~~~~~~~~~~ User can use it to wrap instances of `std::stringstream`, `std::ofstream`. -```cpp +~~~~~~~~~~cpp Document d; // ... @@ -357,7 +357,7 @@ OSStreamWrapper os(ss); Writer writer(os); d.Accept(writer); -``` +~~~~~~~~~~ Note that, this implementation may not be as efficient as RapidJSON's memory or file streams, due to internal overheads of the standard library. diff --git a/doc/tutorial.md b/doc/tutorial.md index eb6a150..0b3da16 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2,18 +2,18 @@ This tutorial introduces the basics of the Document Object Model(DOM) API. -As shown in [Usage at a glance](../readme.md#usage-at-a-glance), a JSON text can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON text. +As shown in [Usage at a glance](../readme.md#usage-at-a-glance), a JSON can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON. ## Value & Document -Each JSON value is stored in a type called `Value`. A `Document`, representing the DOM, contains the root of `Value`. +Each JSON value is stored in a type called `Value`. A `Document`, representing the DOM, contains the root of `Value`. All public types and functions of RapidJSON are defined in the `rapidjson` namespace. ### Query Value In this section, we will use excerpt of [`example/tutorial/tutorial.cpp`](../example/tutorial/tutorial.cpp). -Assumes we have a JSON text stored in a C string (`const char* json`): -```js +Assumes we have a JSON stored in a C string (`const char* json`): +~~~~~~~~~~js { "hello": "world", "t": true , @@ -23,10 +23,10 @@ Assumes we have a JSON text stored in a C string (`const char* json`): "pi": 3.1416, "a": [1, 2, 3, 4] } -``` +~~~~~~~~~~ Parse it into a `Document` -```cpp +~~~~~~~~~~cpp #include "rapidjson/document.h" using namespace rapidjson; @@ -34,50 +34,50 @@ using namespace rapidjson; // ... Document document; document.Parse(json); -``` +~~~~~~~~~~ -The JSON text is now parsed into `document` as a *DOM tree*: +The JSON is now parsed into `document` as a *DOM tree*: -![tutorial](diagram/tutorial.png?raw=true) +![tutorial](diagram/tutorial.png) The root of a conforming JSON should be either an object or an array. In this case, the root is an object. -```cpp +~~~~~~~~~~cpp assert(document.IsObject()); -``` +~~~~~~~~~~ Query whether a `"hello"` member exists in the root object. Since a `Value` can contain different types of value, we may need to verify its type and use suitable API to obtain the value. In this example, `"hello"` member associates with a JSON string. -```cpp +~~~~~~~~~~cpp assert(document.HasMember("hello")); assert(document["hello"].IsString()); printf("hello = %s\n", document["hello"].GetString()); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ world -``` +~~~~~~~~~~ JSON true/false values are represented as `bool`. -```cpp +~~~~~~~~~~cpp assert(document["t"].IsBool()); printf("t = %s\n", document["t"].GetBool() ? "true" : "false"); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ true -``` +~~~~~~~~~~ JSON null can be queryed by `IsNull()`. -```cpp +~~~~~~~~~~cpp printf("n = %s\n", document["n"].IsNull() ? "null" : "?"); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ null -``` +~~~~~~~~~~ JSON number type represents all numeric values. However, C++ needs more specific type for manipulation. -```cpp +~~~~~~~~~~cpp assert(document["i"].IsNumber()); // In this case, IsUint()/IsInt64()/IsUInt64() also return true. @@ -88,28 +88,28 @@ printf("i = %d\n", document["i"].GetInt()); assert(document["pi"].IsNumber()); assert(document["pi"].IsDouble()); printf("pi = %g\n", document["pi"].GetDouble()); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ i = 123 pi = 3.1416 -``` +~~~~~~~~~~ JSON array contains a number of elements. -```cpp +~~~~~~~~~~cpp // Using a reference for consecutive access is handy and faster. const Value& a = document["a"]; assert(a.IsArray()); for (SizeType i = 0; i < a.Size(); i++) // Uses SizeType instead of size_t printf("a[%d] = %d\n", i, a[i].GetInt()); -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ a[0] = 1 a[1] = 2 a[2] = 3 a[3] = 4 -``` +~~~~~~~~~~ Note that, RapidJSON does not automatically convert values between JSON types. If a value is a string, it is invalid to call `GetInt()`, for example. In debug mode it will fail an assertion. In release mode, the behavior is undefined. @@ -124,10 +124,10 @@ You may access the elements in array by integer literal, for example, `a[1]`, `a * `a[0u]` Array is similar to `std::vector`, instead of using indices, you may also use iterator to access all the elements. -```cpp +~~~~~~~~~~cpp for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) printf("%d ", itr->GetInt()); -``` +~~~~~~~~~~ And other familiar query functions: * `SizeType Capacity() const` @@ -137,7 +137,7 @@ And other familiar query functions: Similar to array, we can iterate object members by iterator: -```cpp +~~~~~~~~~~cpp static const char* kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" }; @@ -147,9 +147,9 @@ for (Value::ConstMemberIterator itr = document.MemberBegin(); printf("Type of member %s is %s\n", itr->name.GetString(), kTypeNames[itr->value.GetType()]); } -``` +~~~~~~~~~~ -``` +~~~~~~~~~~ Type of member hello is String Type of member t is True Type of member f is False @@ -157,17 +157,17 @@ Type of member n is Null Type of member i is Number Type of member pi is Number Type of member a is Array -``` +~~~~~~~~~~ Note that, when `operator[](const char*)` cannot find the member, it will fail an assertion. If we are unsure whether a member exists, we need to call `HasMember()` before calling `operator[](const char*)`. However, this incurs two lookup. A better way is to call `FindMember()`, which can check the existence of member and obtain its value at once: -```cpp +~~~~~~~~~~cpp Value::ConstMemberIterator itr = document.FindMember("hello"); if (itr != document.MemberEnd()) printf("%s %s\n", itr->value.GetString()); -``` +~~~~~~~~~~ ### Querying Number @@ -210,18 +210,18 @@ To conform RFC 4627, RapidJSON supports string containing `U+0000`. If you need For example, after parsing a the following JSON string to `Document d`. -```js +~~~~~~~~~~js { "s" : "a\u0000b" } -``` +~~~~~~~~~~ The correct length of the value `"a\u0000b"` is 3. But `strlen()` returns 1. `GetStringLength()` can also improve performance, as user may often need to call `strlen()` for allocating buffer. Besides, `std::string` also support a constructor: -```cpp +~~~~~~~~~~cpp string( const char* s, size_type count); -``` +~~~~~~~~~~ which accepts the length of string as parameter. This constructor supports storing null character within the string, and should also provide better performance. @@ -232,43 +232,43 @@ There are several ways to create values. After a DOM tree is created and/or modi ### Changing Value Type When creating a Value or Document by default constructor, its type is Null. To change its type, call `SetXXX()` or assignment operator, for example: -```cpp +~~~~~~~~~~cpp Document d; // Null d.SetObject(); Value v; // Null v.SetInt(10); v = 10; // Shortcut, same as above -``` +~~~~~~~~~~ ### Overloaded Constructors There are also overloaded constructors for several types: -```cpp +~~~~~~~~~~cpp Value b(true); // calls Value(bool) Value i(-123); // calls Value(int) Value u(123u); // calls Value(unsigned) Value d(1.5); // calls Value(double) -``` +~~~~~~~~~~ To create empty object or array, you may use `SetObject()`/`SetArray()` after default constructor, or using the `Value(Type)` in one shot: -```cpp +~~~~~~~~~~cpp Value o(kObjectType); Value a(kArrayType); -``` +~~~~~~~~~~ ### Move Semantics A very special decision during design of RapidJSON is that, assignment of value does not copy the source value to destination value. Instead, the value from source is moved to the destination. For example, -```cpp +~~~~~~~~~~cpp Value a(123); Value b(456); b = a; // a becomes a Null value, b becomes number 123. -``` +~~~~~~~~~~ -![move1](diagram/move1.png?raw=true) +![move1](diagram/move1.png) Why? What is the advantage of this semantics? @@ -276,7 +276,7 @@ The simple answer is performance. For fixed size JSON types (Number, True, False For example, if normal *copy* semantics was used: -```cpp +~~~~~~~~~~cpp Value o(kObjectType); { Value contacts(kArrayType); @@ -285,9 +285,9 @@ Value o(kObjectType); o.AddMember("contacts", contacts); // deep clone contacts (may be with lots of allocations) // destruct contacts. } -``` +~~~~~~~~~~ -![move2](diagram/move2.png?raw=true) +![move2](diagram/move2.png) The object `o` needs to allocate a buffer of same size as contacts, makes a deep clone of it, and then finally contacts is destructed. This will incur a lot of unnecessary allocations/deallocations and memory copying. @@ -297,7 +297,7 @@ To make RapidJSON simple and fast, we chose to use *move* semantics for assignme So, with move semantics, the above example becomes: -```cpp +~~~~~~~~~~cpp Value o(kObjectType); { Value contacts(kArrayType); @@ -305,9 +305,9 @@ Value o(kObjectType); o.AddMember("contacts", contacts); // just memcpy() of contacts itself to the value of new member (16 bytes) // contacts became Null here. Its destruction is trivial. } -``` +~~~~~~~~~~ -![move3](diagram/move3.png?raw=true) +![move3](diagram/move3.png) This is called move assignment operator in C++11. As RapidJSON supports C++03, it adopts move semantics using assignment operator, and all other modifying function like `AddMember()`, `PushBack()`. @@ -323,7 +323,7 @@ To make memory allocation customizable, RapidJSON requires user to pass an insta Therefore, when we assign a copy-string, we call this overloaded `SetString()` with allocator: -```cpp +~~~~~~~~~~cpp Document document; Value author; char buffer[10]; @@ -331,7 +331,7 @@ int len = sprintf(buffer, "%s %s", "Milo", "Yip"); // dynamically created string author.SetString(buffer, len, document.GetAllocator()); memset(buffer, 0, sizeof(buffer)); // author.GetString() still contains "Milo Yip" after buffer is destroyed -``` +~~~~~~~~~~ In this example, we get the allocator from a `Document` instance. This is a common idiom when using RapidJSON. But you may use other instances of allocator. @@ -339,12 +339,12 @@ Besides, the above `SetString()` requires length. This can handle null character Finally, for literal string or string with safe life-cycle can use const-string version of `SetString()`, which lacks allocator parameter: -```cpp +~~~~~~~~~~cpp Value s; s.SetString("rapidjson", 9); // faster, can contain null character s.SetString("rapidjson"); // slower, assumes null-terminated s = "rapidjson"; // shortcut, same as above -``` +~~~~~~~~~~ ### Modify Array Value with array type provides similar APIs as `std::vector`. @@ -359,7 +359,7 @@ Note that, `Reserve(...)` and `PushBack(...)` may allocate memory, therefore req Here is an example of `PushBack()`: -```cpp +~~~~~~~~~~cpp Value a(kArrayType); Document::AllocatorType& allocator = document.GetAllocator(); @@ -368,7 +368,7 @@ for (int i = 5; i <= 10; i++) // Fluent interface a.PushBack("Lua", allocator).PushBack("Mio", allocator); -``` +~~~~~~~~~~ Differs from STL, `PushBack()`/`PopBack()` returns the array reference itself. This is called fluent interface. @@ -382,16 +382,16 @@ Object is a collection of key-value pairs. Each key must be a string value. The Here is an example. -```cpp +~~~~~~~~~~cpp Value contact(kObejct); contact.AddMember("name", "Milo", document.GetAllocator()); contact.AddMember("married", true, document.GetAllocator()); -``` +~~~~~~~~~~ ### Deep Copy Value If we really need to copy a DOM tree, we can use two APIs for deep copy: constructor with allocator, and `CopyFrom()`. -```cpp +~~~~~~~~~~cpp Document d; Document::AllocatorType& a = d.GetAllocator(); Value v1("foo"); @@ -406,19 +406,19 @@ v2.CopyFrom(d, a); // copy whole document to v2 assert(d.IsArray() && d.Size() == 2); // d untouched v1.SetObject().AddMember( "array", v2, a ); d.PushBack(v1,a); -``` +~~~~~~~~~~ ### Swap Values `Swap()` is also provided. -```cpp +~~~~~~~~~~cpp Value a(123); Value b("Hello"); a.Swap(b); assert(a.IsString()); assert(b.IsInt()); -``` +~~~~~~~~~~ Swapping two DOM trees is fast (constant time), despite the complexity of the tress. From d6497d86f8e1c913c15ba41521b8e16a7ea4826d Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Sun, 6 Jul 2014 22:51:09 +0800 Subject: [PATCH 16/76] Update dom.md Fixes diagrams URL in DOM --- doc/dom.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/dom.md b/doc/dom.md index caad770..117469a 100644 --- a/doc/dom.md +++ b/doc/dom.md @@ -166,11 +166,11 @@ In normal parsing process, a large overhead is to decode JSON strings and copy t The following diagrams compare normal and *in situ* parsing. The JSON string values contain pointers to the decoded string. -![normal parsing](diagrams/normalparsing.png) +![normal parsing](diagram/normalparsing.png) In normal parsing, the decoded string are copied to freshly allocated buffers. `"\\n"` (2 characters) is decoded as `"\n"` (1 character). `"\\u0073"` (6 characters) is decoded as "s" (1 character). -![instiu parsing](diagrams/insituparsing.png) +![instiu parsing](diagram/insituparsing.png) *In situ* parsing just modified the original JSON. Updated characters are highlighted in the diagram. If the JSON string does not contain escape character, such as `"msg"`, the parsing process merely replace the closing double quotation mark with a null character. @@ -264,4 +264,4 @@ d.Parse(json); If the total size of allocation is less than 1024 during parsing, this code does not invoke any heap allocation (via `new` or `malloc()`) at all. -User can query the current memory consumption in bytes via `MemoryPoolAllocator::Size()`. And then user can determine a suitable size of user buffer. \ No newline at end of file +User can query the current memory consumption in bytes via `MemoryPoolAllocator::Size()`. And then user can determine a suitable size of user buffer. From 6e4d8db51d2d547fbc3d0b80069e111712ff8581 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Mon, 7 Jul 2014 01:01:49 +0800 Subject: [PATCH 17/76] Fix readme issue in doxygen, customize css Imitate GitHub markdown rendering --- build/Doxyfile | 2653 ++++++++++++++++++++------------- build/a/customdoxygen.css | 1440 ++++++++++++++++++ doc/dom.md | 6 - doc/misc/doxygenextra.css | 116 ++ include/rapidjson/rapidjson.h | 4 - 5 files changed, 3173 insertions(+), 1046 deletions(-) create mode 100644 build/a/customdoxygen.css create mode 100644 doc/misc/doxygenextra.css diff --git a/build/Doxyfile b/build/Doxyfile index a54bd8e..59f5f60 100644 --- a/build/Doxyfile +++ b/build/Doxyfile @@ -1,104 +1,122 @@ -# Doxyfile 1.7.5.1 +# Doxyfile 1.8.7 # This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project +# doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. # The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. -PROJECT_NAME = rapidjson +PROJECT_NAME = RapidJSON -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "A fast JSON parser/generator for C++ with both SAX/DOM style API" -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. +# With the PROJECT_LOGO tag one can specify an logo or icon that is included in +# the documentation. The maximum height of the logo should not exceed 55 pixels +# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo +# to the output directory. -PROJECT_LOGO = +PROJECT_LOGO = -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. OUTPUT_DIRECTORY = ./doc -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. +# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. +# The default value is: YES. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ @@ -112,551 +130,661 @@ ABBREVIATE_BRIEF = "The $name class" \ an \ the -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief # description. +# The default value is: NO. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. +# The default value is: NO. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. +# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. -STRIP_FROM_PATH = +STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. JAVADOC_AUTOBRIEF = NO -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a +# new page for each member. If set to NO, the documentation of a member will be +# part of the file/class/namespace that contains it. +# The default value is: NO. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. -TAB_SIZE = 8 +TAB_SIZE = 4 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. -ALIASES = +ALIASES = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by by putting a % sign in front of the word +# or globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. +# The default value is: NO. BUILTIN_STL_SUPPORT = NO -# If you use Microsoft's C++/CLI language, you should set this option to YES to +# If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. +# The default value is: NO. CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. IDL_PROPERTY_SUPPORT = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. +# The default value is: NO. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. SUBGROUPING = YES -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. INLINE_GROUPED_CLASSES = YES -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. INLINE_SIMPLE_STRUCTS = NO -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. TYPEDEF_HIDES_STRUCT = NO -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. -SYMBOL_CACHE_SIZE = 0 +LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. EXTRACT_ALL = NO -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will +# be included in the documentation. +# The default value is: NO. EXTRACT_PRIVATE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file will be +# included in the documentation. +# The default value is: NO. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. +# This flag is only useful for Objective-C code. When set to YES local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO only methods in the interface are +# included. +# The default value is: NO. EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO these classes will be included in the various overviews. This option has +# no effect if EXTRACT_ALL is enabled. +# The default value is: NO. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO these declarations will be +# included in the documentation. +# The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. +# The default value is: system dependent. CASE_SENSE_NAMES = NO -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES the +# scope will be hidden. +# The default value is: NO. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. SHOW_INCLUDE_FILES = YES -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. FORCE_LOCAL_INCLUDES = NO -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO the members will appear in declaration order. +# The default value is: YES. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. SORT_BRIEF_DOCS = NO -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. SORT_BY_SCOPE_NAME = NO -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. STRICT_PROTO_MATCHING = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. +# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the +# todo list. This list is created by putting \todo commands in the +# documentation. +# The default value is: YES. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. +# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the +# test list. This list is created by putting \test commands in the +# documentation. +# The default value is: YES. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. +# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. +# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. ENABLED_SECTIONS = $(RAPIDJSON_SECTIONS) -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES the list +# will mention the files that were used to generate the documentation. +# The default value is: YES. SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. SHOW_NAMESPACES = NO -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. -LAYOUT_FILE = +LAYOUT_FILE = -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. Do not use file names with spaces, bibtex cannot handle them. See +# also \cite for info how to create references. -CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- -# configuration options related to warning and progress messages +# Configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. +# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. WARN_IF_DOC_ERROR = YES -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO doxygen will only warn about wrong or incomplete parameter +# documentation, but not about the absence of documentation. +# The default value is: NO. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- -# configuration options related to the input files +# Configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. +# Note: If this tag is empty the current directory is searched. INPUT = ./include/ \ ./readme.md \ ./doc/ -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank the +# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, +# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, +# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, +# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, +# *.qsf, *.as and *.js. FILE_PATTERNS = *.c \ *.cc \ @@ -669,887 +797,1260 @@ FILE_PATTERNS = *.c \ *.inc \ *.md -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. RECURSIVE = YES -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to directory from which doxygen is run. +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. -EXCLUDE = +EXCLUDE = ./include/rapidjson/msinttypes/ -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded # from the input. +# The default value is: NO. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = internal -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. EXAMPLE_PATTERNS = * -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). IMAGE_PATH = ./doc -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER ) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. FILTER_SOURCE_FILES = NO -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. -FILTER_SOURCE_PATTERNS = +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = ./readme.md #--------------------------------------------------------------------------- -# configuration options related to source browsing +# Configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. STRIP_CODE_COMMENTS = NO -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. REFERENCED_BY_RELATION = NO -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. REFERENCES_RELATION = NO -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentation. +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES, then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. VERBATIM_HEADERS = YES +# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# compiled with the --with-libclang option. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + #--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index +# Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. ALPHABETICAL_INDEX = YES -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- -# configuration options related to the HTML output +# Configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. +# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output +# The default value is: YES. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is adviced to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user- +# defined cascading style sheet that is included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefor more robust against future updates. +# Doxygen will copy the style sheet file to the output directory. For an example +# see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_FILES = +HTML_EXTRA_STYLESHEET = ./doc/misc/doxygenextra.css -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the stylesheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the stylesheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = YES -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be # written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler ( hhc.exe). If non-empty +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). +# The GENERATE_CHI flag controls if a separate .chi index file is generated ( +# YES) or that it should be included in the master .chm file ( NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. +# The BINARY_TOC flag controls whether a binary table of contents is generated ( +# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. -QCH_FILE = +QCH_FILE = -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. -QHG_LOCATION = +QHG_LOCATION = -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. -USE_INLINE_TREES = NO +ENUM_VALUES_PER_LINE = 4 -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using prerendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the -# mathjax.org site, so you can quickly see the result without installing -# MathJax, but it is strongly recommended to install a local copy of MathJax -# before deployment. +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://www.mathjax.org/mathjax -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /

+ diff --git a/doc/misc/header.html b/doc/misc/header.html new file mode 100644 index 0000000..51ab127 --- /dev/null +++ b/doc/misc/header.html @@ -0,0 +1,28 @@ + + + + + + + +$projectname: $title +$title + + + +$treeview +$search +$mathjax + +$extrastylesheet + + +
+ + + + + +
$searchbox
+ + diff --git a/doc/performance.md b/doc/performance.md index c9c9ae4..67eea11 100644 --- a/doc/performance.md +++ b/doc/performance.md @@ -1,4 +1,4 @@ -# RapidJSON Performance +# Performance The old performance article for RapidJSON 0.1 is provided [here](https://code.google.com/p/rapidjson/wiki/Performance). diff --git a/doc/sax.md b/doc/sax.md index b4a663a..6442b6b 100644 --- a/doc/sax.md +++ b/doc/sax.md @@ -1,4 +1,4 @@ -# RapidJSON SAX +# SAX ## Reader diff --git a/doc/stream.md b/doc/stream.md index 84d58bc..46d404c 100644 --- a/doc/stream.md +++ b/doc/stream.md @@ -1,4 +1,4 @@ -# RapidJSON Stream +# Stream In RapidJSON, `rapidjson::Stream` is a concept for reading/writing JSON. Here we first show how to use streams provided. And then see how to create a custom streams. diff --git a/doc/tutorial.md b/doc/tutorial.md index 721e747..b58c097 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1,4 +1,4 @@ -# RapidJSON Tutorial +# Tutorial This tutorial introduces the basics of the Document Object Model(DOM) API. From fc8bd7541d65c94932c714ad5d45a0d984c5798f Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Mon, 7 Jul 2014 22:26:44 +0800 Subject: [PATCH 20/76] Try running doxygen --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.travis.yml b/.travis.yml index 74a2a2f..71ff2af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_install: - sudo add-apt-repository -y ppa:codegear/release - sudo apt-get update -qq - sudo apt-get install -y premake4 valgrind + - sudo apt-get install doxygen install: true @@ -27,3 +28,11 @@ script: - ./unittest_${config_suffix} - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} - ./perftest_${config_suffix} + +after_script: + - doxygen build/Doxyfile + +matrix: + include: + - compiler=clang + config=release64 From 71901bc84e8a293630fefcf95ac42d8692d595d6 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Mon, 7 Jul 2014 23:08:37 +0800 Subject: [PATCH 21/76] Try again --- .travis.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 71ff2af..9b940e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,7 @@ env: before_install: - sudo add-apt-repository -y ppa:codegear/release - sudo apt-get update -qq - - sudo apt-get install -y premake4 valgrind - - sudo apt-get install doxygen + - sudo apt-get install -y premake4 valgrind doxygen install: true @@ -31,8 +30,3 @@ script: after_script: - doxygen build/Doxyfile - -matrix: - include: - - compiler=clang - config=release64 From 7384fe979c4f65196ae939c9f5bce1933723dc08 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Mon, 7 Jul 2014 23:17:09 +0800 Subject: [PATCH 22/76] Change directory --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b940e8..a103074 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,9 @@ script: - make -C build/gmake -f example.make - cd bin - ./unittest_${config_suffix} - - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} - - ./perftest_${config_suffix} +# - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} +# - ./perftest_${config_suffix} after_script: + - cd "${TRAVIS_BUILD_DIR}" - doxygen build/Doxyfile From bb7f2c8e722ec7e235e1eec71640504ffb0cf2d8 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Mon, 7 Jul 2014 23:26:40 +0800 Subject: [PATCH 23/76] Install latest doxygen --- .travis.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a103074..7063b41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ env: before_install: - sudo add-apt-repository -y ppa:codegear/release - sudo apt-get update -qq - - sudo apt-get install -y premake4 valgrind doxygen + - sudo apt-get install -y premake4 valgrind install: true @@ -29,5 +29,15 @@ script: # - ./perftest_${config_suffix} after_script: + - cd "${TRAVIS_BUILD_DIR}" + - git clone https://github.com/doxygen/doxygen.git + - cd doxygen + - ./configure + - make + - make distclean + - git pull + - ./configure + - make + - make install - cd "${TRAVIS_BUILD_DIR}" - doxygen build/Doxyfile From 1f655cb48e712ffb9b54ed48d94a3d29db5722b2 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Mon, 7 Jul 2014 23:34:41 +0800 Subject: [PATCH 24/76] Try default doxygen --- .travis.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7063b41..602db4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,15 +29,5 @@ script: # - ./perftest_${config_suffix} after_script: - - cd "${TRAVIS_BUILD_DIR}" - - git clone https://github.com/doxygen/doxygen.git - - cd doxygen - - ./configure - - make - - make distclean - - git pull - - ./configure - - make - - make install - cd "${TRAVIS_BUILD_DIR}" - doxygen build/Doxyfile From 4a49c5eff6f0642a5ab58c5446cd7b525c153194 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 00:20:10 +0800 Subject: [PATCH 25/76] build doxygen --- .travis.yml | 4 ++-- build/travis_doxygen.sh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 build/travis_doxygen.sh diff --git a/.travis.yml b/.travis.yml index 602db4a..0186840 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,6 @@ script: # - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} # - ./perftest_${config_suffix} -after_script: +after_success : - cd "${TRAVIS_BUILD_DIR}" - - doxygen build/Doxyfile + - build/travis_doxygen.sh diff --git a/build/travis_doxygen.sh b/build/travis_doxygen.sh new file mode 100644 index 0000000..76c55b5 --- /dev/null +++ b/build/travis_doxygen.sh @@ -0,0 +1,16 @@ +#!/bin/sh +if ["${config}"="release64" && "$CC"="clang"] then exit 0 fi + +cd /tmp +git clone https://github.com/doxygen/doxygen.git +cd doxygen +./configure +make +make distclean +git pull +./configure +make +make install + +cd "${TRAVIS_BUILD_DIR} +doxygen build/Doxyfile From 0e092bdb1300c4ea72ea479be5d090d008626f6b Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 00:29:08 +0800 Subject: [PATCH 26/76] Try build doxygen --- .travis.yml | 2 +- build/travis_doxygen.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0186840..d296adc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,4 @@ script: after_success : - cd "${TRAVIS_BUILD_DIR}" - - build/travis_doxygen.sh + - ./build/travis_doxygen.sh diff --git a/build/travis_doxygen.sh b/build/travis_doxygen.sh index 76c55b5..7b7a7de 100644 --- a/build/travis_doxygen.sh +++ b/build/travis_doxygen.sh @@ -10,7 +10,7 @@ make distclean git pull ./configure make -make install +sudo make install cd "${TRAVIS_BUILD_DIR} doxygen build/Doxyfile From a3b05bbcff4244a5c90123e012e1acfc5ec5ea60 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 00:34:17 +0800 Subject: [PATCH 27/76] Adding sudo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d296adc..6af5b9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,4 @@ script: after_success : - cd "${TRAVIS_BUILD_DIR}" - - ./build/travis_doxygen.sh + - sudo build/travis_doxygen.sh From 3e88c558e4a50d244b0c5ae9cbfede3e97f03b6b Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 00:43:01 +0800 Subject: [PATCH 28/76] Adding ./ --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6af5b9f..1d0d857 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,4 @@ script: after_success : - cd "${TRAVIS_BUILD_DIR}" - - sudo build/travis_doxygen.sh + - sudo ./build/travis_doxygen.sh From 461b84cf38733894c2913367ab8d2961b357d834 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 00:51:46 +0800 Subject: [PATCH 29/76] Add chmod +x --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1d0d857..a4a517c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,5 @@ script: after_success : - cd "${TRAVIS_BUILD_DIR}" - - sudo ./build/travis_doxygen.sh + - sudo chmod +x build/travis_doxygen.sh + - sudo build/travis_doxygen.sh From e5cd989d7f2455ad3b3140d4e1b2f8bae17e84a8 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 01:00:48 +0800 Subject: [PATCH 30/76] Fixes travis_doxygen.sh --- build/travis_doxygen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/travis_doxygen.sh b/build/travis_doxygen.sh index 7b7a7de..65eed81 100644 --- a/build/travis_doxygen.sh +++ b/build/travis_doxygen.sh @@ -12,5 +12,5 @@ git pull make sudo make install -cd "${TRAVIS_BUILD_DIR} +cd "${TRAVIS_BUILD_DIR}" doxygen build/Doxyfile From 4720d4a2dd5ce1759c9e953aa7b731561a8b8945 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 01:18:38 +0800 Subject: [PATCH 31/76] Change line ending --- build/travis_doxygen.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/build/travis_doxygen.sh b/build/travis_doxygen.sh index 65eed81..01f8578 100644 --- a/build/travis_doxygen.sh +++ b/build/travis_doxygen.sh @@ -1,16 +1,17 @@ #!/bin/sh -if ["${config}"="release64" && "$CC"="clang"] then exit 0 fi -cd /tmp -git clone https://github.com/doxygen/doxygen.git -cd doxygen -./configure -make -make distclean -git pull -./configure -make -sudo make install +if [ "${config}" == "release64" ] && [ "$CC" == "clang" ]; then + cd /tmp + git clone https://github.com/doxygen/doxygen.git + cd doxygen + ./configure + make + make distclean + git pull + ./configure + make + sudo make install -cd "${TRAVIS_BUILD_DIR}" -doxygen build/Doxyfile + cd "${TRAVIS_BUILD_DIR}" + doxygen build/Doxyfile +fi From bfba0d5ac90fcbfb3a82e11d7d8e72c954a24956 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 01:34:27 +0800 Subject: [PATCH 32/76] Fixes travis_doxygen.sh --- build/travis_doxygen.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/travis_doxygen.sh b/build/travis_doxygen.sh index 01f8578..90aea3f 100644 --- a/build/travis_doxygen.sh +++ b/build/travis_doxygen.sh @@ -1,6 +1,7 @@ #!/bin/sh -if [ "${config}" == "release64" ] && [ "$CC" == "clang" ]; then +if [ "${config}" = "release64" ] && [ "$CC" = "clang" ] +then cd /tmp git clone https://github.com/doxygen/doxygen.git cd doxygen From 91b5607cddf807b3457073cb29e9444936df229b Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 01:44:14 +0800 Subject: [PATCH 33/76] Try again --- build/travis_doxygen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/travis_doxygen.sh b/build/travis_doxygen.sh index 90aea3f..648d440 100644 --- a/build/travis_doxygen.sh +++ b/build/travis_doxygen.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [ "${config}" = "release64" ] && [ "$CC" = "clang" ] +if [ "${config}" = "release64" ] && [ "${CC}" = "clang" ] then cd /tmp git clone https://github.com/doxygen/doxygen.git From 925998fd1ee873a054315b993d7eee3cea2bab5c Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 01:56:16 +0800 Subject: [PATCH 34/76] Again --- .travis.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a4a517c..6210085 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,14 +21,24 @@ before_script: - cd "${TRAVIS_BUILD_DIR}" script: - - make -C build/gmake -f test.make - - make -C build/gmake -f example.make - - cd bin - - ./unittest_${config_suffix} +# - make -C build/gmake -f test.make +# - make -C build/gmake -f example.make +# - cd bin +# - ./unittest_${config_suffix} # - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} # - ./perftest_${config_suffix} after_success : - cd "${TRAVIS_BUILD_DIR}" - - sudo chmod +x build/travis_doxygen.sh - - sudo build/travis_doxygen.sh + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then cd /tmp; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then git clone https://github.com/doxygen/doxygen.git; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then cd doxygen; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then ./configure; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then make; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then make distclean; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then git pull; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then ./configure; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then make; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then sudo make install; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi + - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then doxygen build/Doxyfile; fi From af226cf2990c73a165f73dbc9e51c2ecf5dc2f49 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 02:06:22 +0800 Subject: [PATCH 35/76] Try -a --- .travis.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6210085..fc14ae9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,15 +30,15 @@ script: after_success : - cd "${TRAVIS_BUILD_DIR}" - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then cd /tmp; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then git clone https://github.com/doxygen/doxygen.git; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then cd doxygen; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then ./configure; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then make; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then make distclean; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then git pull; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then ./configure; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then make; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then sudo make install; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi - - if [ "$config" = "release64" ] && [ "$CC" = "clang" ]; then doxygen build/Doxyfile; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/doxygen/doxygen.git; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make distclean; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git pull; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo make install; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then doxygen build/Doxyfile; fi From 8fa09bc2fd3ea599d918dc13c4b86f3d97fa59bb Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 02:12:12 +0800 Subject: [PATCH 36/76] Try again --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc14ae9..01e0c80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,13 +23,12 @@ before_script: script: # - make -C build/gmake -f test.make # - make -C build/gmake -f example.make -# - cd bin + - cd bin # - ./unittest_${config_suffix} # - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} # - ./perftest_${config_suffix} -after_success : - - cd "${TRAVIS_BUILD_DIR}" +after_success: - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/doxygen/doxygen.git; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen; fi From 095857fc6eaa2f507cc8d66ad9da3856f184fc32 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 02:54:35 +0800 Subject: [PATCH 37/76] Try automatic upload --- .travis.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 01e0c80..edb3086 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,11 @@ compiler: - gcc env: - - config=debug64 config_suffix=debug_x64_gmake - - config=release64 config_suffix=release_x64_gmake + matrix: + - config=debug64 config_suffix=debug_x64_gmake + - config=release64 config_suffix=release_x64_gmake + global: + secure: HAEPpA7IxUd+X4X5VcUpSxWf3hDRDNgNpKQrRSX/X/nS0/h5PAwES7fmM6WJAsoEmczCp3OOArzyOON+KLbISvJLnHvnexd+rtyVjU2zOOVTEgzJRdAPHwocqVx5FOxtlKgbDISE6dl3H5aUCycf962jfquhKosi11rbxwcscmc= before_install: - sudo add-apt-repository -y ppa:codegear/release @@ -29,6 +32,7 @@ script: # - ./perftest_${config_suffix} after_success: +# Build latest doxygen from source - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/doxygen/doxygen.git; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen; fi @@ -40,4 +44,18 @@ after_success: - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo make install; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi + +# Run doxygen - if [ "$config" = "release64" -a "$CC" = "clang" ]; then doxygen build/Doxyfile; fi + +# Push to Github Pages + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git config --global user.name "${GIT_NAME}"; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git config --global user.email ${GIT_EMAIL}; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then mkdir build/doc; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd build/doc; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/miloyip/rapidjson; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git checkout gh-pages; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cp -r ../../doc/html/* .; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git add --all; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git commit -m "Automatic doxygen build"; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git push https://${GH_TOKEN}@github.com/miloyip/rapidjson gh-pages; fi From 0fbb05c42bc9564fe7274dd63265f323be159a21 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 03:18:57 +0800 Subject: [PATCH 38/76] Try auto upload again --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index edb3086..bb80cd7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,8 +54,9 @@ after_success: - if [ "$config" = "release64" -a "$CC" = "clang" ]; then mkdir build/doc; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd build/doc; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/miloyip/rapidjson; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd rapidjson; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git checkout gh-pages; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cp -r ../../doc/html/* .; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cp -r ../../../doc/html/* .; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git add --all; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git commit -m "Automatic doxygen build"; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git push https://${GH_TOKEN}@github.com/miloyip/rapidjson gh-pages; fi From 45e246365cfae81135585ceeb6152952c10bc52a Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 03:45:14 +0800 Subject: [PATCH 39/76] Reactivate normal building process --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb80cd7..9773057 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,12 +24,12 @@ before_script: - cd "${TRAVIS_BUILD_DIR}" script: -# - make -C build/gmake -f test.make -# - make -C build/gmake -f example.make + - make -C build/gmake -f test.make + - make -C build/gmake -f example.make - cd bin -# - ./unittest_${config_suffix} -# - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} -# - ./perftest_${config_suffix} + - ./unittest_${config_suffix} + - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} + - if [ "$config" = "release64" ]; then ./perftest_${config_suffix}; fi after_success: # Build latest doxygen from source From b85f16154f2b36608c35a0cb409948b8a60be638 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 08:33:14 +0800 Subject: [PATCH 40/76] fixes whitespaces --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9773057..e23ef62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,8 @@ before_script: script: - make -C build/gmake -f test.make - - make -C build/gmake -f example.make - - cd bin + - make -C build/gmake -f example.make + - cd bin - ./unittest_${config_suffix} - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} - if [ "$config" = "release64" ]; then ./perftest_${config_suffix}; fi From 2e8f7e95a0d894b1071e098ad6b9e23a91da00c6 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 09:04:09 +0800 Subject: [PATCH 41/76] Try using doxygen binary --- .travis.yml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index e23ef62..971e15a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,17 +33,24 @@ script: after_success: # Build latest doxygen from source +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/doxygen/doxygen.git; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make distclean; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git pull; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo make install; fi +# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi + +# Install doxygen binary distribution - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/doxygen/doxygen.git; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make distclean; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git pull; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo make install; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then curl http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.7.linux.bin.tar.gz; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then tar -xvf doxygen-1.8.7.linux.bin.tar.gz; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen-1.8.7; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo install -m 755 doxygen-1.8.7/bin/doxygen /usr/bin; fi # Run doxygen - if [ "$config" = "release64" -a "$CC" = "clang" ]; then doxygen build/Doxyfile; fi From 4287a4b2b829317d3401c6c621ca004676b4b767 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 09:13:29 +0800 Subject: [PATCH 42/76] Use wget instead of curl --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 971e15a..283110f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,7 @@ after_success: # Install doxygen binary distribution - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then curl http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.7.linux.bin.tar.gz; fi + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then wget http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.7.linux.bin.tar.gz; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then tar -xvf doxygen-1.8.7.linux.bin.tar.gz; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen-1.8.7; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo install -m 755 doxygen-1.8.7/bin/doxygen /usr/bin; fi From 8021a626f5dfefddaff39b1b122c31e9b9c3ca6a Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 09:21:50 +0800 Subject: [PATCH 43/76] Fixes path --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 283110f..34b238f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,6 @@ after_success: - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then wget http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.7.linux.bin.tar.gz; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then tar -xvf doxygen-1.8.7.linux.bin.tar.gz; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen-1.8.7; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo install -m 755 doxygen-1.8.7/bin/doxygen /usr/bin; fi # Run doxygen From 9fbb638a6523c7d82bb41f72bbb4320cd16d9014 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 09:30:59 +0800 Subject: [PATCH 44/76] Fixes another path issue --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 34b238f..55cf8ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,6 @@ after_success: # - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi # - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi # - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo make install; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi # Install doxygen binary distribution - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi @@ -52,6 +51,7 @@ after_success: - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo install -m 755 doxygen-1.8.7/bin/doxygen /usr/bin; fi # Run doxygen + - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi - if [ "$config" = "release64" -a "$CC" = "clang" ]; then doxygen build/Doxyfile; fi # Push to Github Pages From a0e2a1e03fbc70fc046636e9e48942bd0e705515 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 09:40:18 +0800 Subject: [PATCH 45/76] Remove unused sh --- build/travis_doxygen.sh | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 build/travis_doxygen.sh diff --git a/build/travis_doxygen.sh b/build/travis_doxygen.sh deleted file mode 100644 index 648d440..0000000 --- a/build/travis_doxygen.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -if [ "${config}" = "release64" ] && [ "${CC}" = "clang" ] -then - cd /tmp - git clone https://github.com/doxygen/doxygen.git - cd doxygen - ./configure - make - make distclean - git pull - ./configure - make - sudo make install - - cd "${TRAVIS_BUILD_DIR}" - doxygen build/Doxyfile -fi From 62970ee23087d0734a41abc89c4a5d6bc0e93bf5 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 14:11:08 +0800 Subject: [PATCH 46/76] Improves documentation style, TOC, fixes links. Some links will become broken in GitHub. --- build/Doxyfile | 2 +- doc/dom.md | 58 ++++++++++++++++++++---------------- doc/features.md | 2 +- doc/misc/doxygenextra.css | 62 +++++++++++++++++++++++++++++++++++---- doc/misc/header.html | 8 ++--- doc/stream.md | 32 ++++++++++---------- doc/tutorial.md | 56 ++++++++++++++++++----------------- readme.md | 16 +++++----- 8 files changed, 149 insertions(+), 87 deletions(-) diff --git a/build/Doxyfile b/build/Doxyfile index a050304..c74b79d 100644 --- a/build/Doxyfile +++ b/build/Doxyfile @@ -1035,7 +1035,7 @@ CLANG_OPTIONS = # classes, structs, unions or interfaces. # The default value is: YES. -ALPHABETICAL_INDEX = BI +ALPHABETICAL_INDEX = NO # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in # which the alphabetical index list will be split. diff --git a/doc/dom.md b/doc/dom.md index 1195b7a..90a447e 100644 --- a/doc/dom.md +++ b/doc/dom.md @@ -1,12 +1,16 @@ # DOM -Document Object Model(DOM) is a in-memory representation of JSON for query and manipulation. The basic usage of DOM is described in [Tutorial](tutorial.md). This section will describe some details and more advanced usages. +Document Object Model(DOM) is an in-memory representation of JSON for query and manipulation. The basic usage of DOM is described in [Tutorial](doc/tutorial.md). This section will describe some details and more advanced usages. -## Template +[TOC] + +# Template {#Template} In the tutorial, `Value` and `Document` was used. Similarly to `std::string`, these are actually `typedef` of template classes: ~~~~~~~~~~cpp +namespace rapidjson { + template > class GenericValue { // ... @@ -19,17 +23,21 @@ class GenericDocument : public GenericValue { typedef GenericValue > Value; typedef GenericDocument > Document; + +} // namespace rapidjson ~~~~~~~~~~ User can customize these template parameters. -### Encoding +## Encoding {#Encoding} The `Encoding` parameter specifies the encoding of JSON String value in memory. Possible options are `UTF8`, `UTF16`, `UTF32`. Note that, these 3 types are also template class. `UTF8<>` is `UTF8`, which means using char to store the characters. You may refer to [Encoding](encoding.md) for details. Suppose a Windows application would query localization strings stored in JSON files. Unicode-enabled functions in Windows use UTF-16 (wide character) encoding. No matter what encoding was used in JSON files, we can store the strings in UTF-16 in memory. ~~~~~~~~~~cpp +using namespace rapidjson; + typedef GenericDocument > WDocument; typedef GenericValue > WValue; @@ -48,7 +56,7 @@ const WValue locale(L"ja"); // Japanese MessageBoxW(hWnd, d[locale].GetString(), L"Test", MB_OK); ~~~~~~~~~~ -### Allocator +## Allocator {#Allocator} The `Allocator` defines which allocator class is used when allocating/deallocating memory for `Document`/`Value`. `Document` owns, or references to an `Allocator` instance. On the other hand, `Value` does not do so, in order to reduce memory consumption. @@ -56,44 +64,46 @@ The default allocator used in `GenericDocument` is `MemoryPoolAllocator`. This a Another allocator is `CrtAllocator`, of which CRT is short for C RunTime library. This allocator simply calls the standard `malloc()`/`realloc()`/`free()`. When there is a lot of add and remove operations, this allocator may be preferred. But this allocator is far less efficient than `MemoryPoolAllocator`. -## Parsing +# Parsing {#Parsing} `Document` provides several functions for parsing. In below, (1) is the fundamental function, while the others are helpers which call (1). ~~~~~~~~~~cpp +using namespace rapidjson; + // (1) Fundamental template -GenericDocument& ParseStream(InputStream& is); +GenericDocument& GenericDocument::ParseStream(InputStream& is); // (2) Using the same Encoding for stream template -GenericDocument& ParseStream(InputStream& is); +GenericDocument& GenericDocument::ParseStream(InputStream& is); // (3) Using default parse flags template -GenericDocument& ParseStream(InputStream& is); +GenericDocument& GenericDocument::ParseStream(InputStream& is); // (4) In situ parsing template -GenericDocument& ParseInsitu(Ch* str); +GenericDocument& GenericDocument::ParseInsitu(Ch* str); // (5) In situ parsing, using same Encoding for stream template -GenericDocument& ParseInsitu(Ch* str); +GenericDocument& GenericDocument::ParseInsitu(Ch* str); // (6) In situ parsing, using default parse flags -GenericDocument& ParseInsitu(Ch* str); +GenericDocument& GenericDocument::ParseInsitu(Ch* str); // (7) Normal parsing of a string template -GenericDocument& Parse(const Ch* str); +GenericDocument& GenericDocument::Parse(const Ch* str); // (8) Normal parsing of a string, using same Encoding for stream template -GenericDocument& Parse(const Ch* str); +GenericDocument& GenericDocument::Parse(const Ch* str); // (9) Normal parsing of a string, using default parse flags -GenericDocument& Parse(const Ch* str); +GenericDocument& GenericDocument::Parse(const Ch* str); ~~~~~~~~~~ The examples of [tutorial](tutorial.md) uses (9) for normal parsing of string. The examples of [stream](stream.md) uses the first three. *In situ* parsing will be described soon. @@ -108,11 +118,11 @@ Parse flags | Meaning By using a non-type template parameter, instead of a function parameter, C++ compiler can generate code which is optimized for specified combinations, improving speed, and reducing code size (if only using a single specialization). The downside is the flags needed to be determined in compile-time. -The `SourceEncoding` parameter defines what encoding is in the stream. This can be differed to the `Encoding` of the `Document`. See [Transcoding and Validation](#transcoding-and-validation) section for details. +The `SourceEncoding` parameter defines what encoding is in the stream. This can be differed to the `Encoding` of the `Document`. See [Transcoding and Validation](#TranscodingAndValidation) section for details. And the `InputStream` is type of input stream. -### Parse Error +## Parse Error {#ParseError} When the parse processing succeeded, the `Document` contains the parse results. When there is an error, the original DOM is *unchanged*. And the error state of parsing can be obtained by `bool HasParseError()`, `ParseErrorCode GetParseError()` and `size_t GetParseOffet()`. @@ -146,14 +156,12 @@ Here shows an example of parse error handling. // TODO: example ~~~~~~~~~~ -### In Situ Parsing +## In Situ Parsing {#InSituParsing} From [Wikipedia](http://en.wikipedia.org/wiki/In_situ): > *In situ* ... is a Latin phrase that translates literally to "on site" or "in position". It means "locally", "on site", "on the premises" or "in place" to describe an event where it takes place, and is used in many different contexts. - > ... - > (In computer science) An algorithm is said to be an in situ algorithm, or in-place algorithm, if the extra amount of memory required to execute the algorithm is O(1), that is, does not exceed a constant no matter how large the input. For example, heapsort is an in situ sorting algorithm. In normal parsing process, a large overhead is to decode JSON strings and copy them to other buffers. *In situ* parsing decodes those JSON string at the place where it is stored. It is possible in JSON because the decoded string is always shorter than the one in JSON. In this context, decoding a JSON string means to process the escapes, such as `"\n"`, `"\u1234"`, etc., and add a null terminator (`'\0'`)at the end of string. @@ -204,17 +212,17 @@ There are some limitations of *in situ* parsing: *In situ* parsing is mostly suitable for short-term JSON that only need to be processed once, and then be released from memory. In practice, these situation is very common, for example, deserializing JSON to C++ objects, processing web requests represented in JSON, etc. -### Transcoding and Validation +## Transcoding and Validation {#TranscodingAndValidation} -RapidJSON supports conversion between Unicode formats (officially termed UCS Transformation Format) internally. During DOM parsing, the source encoding of the stream can be different from the encoding of the DOM. For example, the source stream contains a UTF-8 JSON, while the DOM is using UTF-16 encoding. There is an example code in [EncodedInputStream](stream.md#encodedinputstream). +RapidJSON supports conversion between Unicode formats (officially termed UCS Transformation Format) internally. During DOM parsing, the source encoding of the stream can be different from the encoding of the DOM. For example, the source stream contains a UTF-8 JSON, while the DOM is using UTF-16 encoding. There is an example code in [EncodedInputStream](doc/stream.md#EncodedInputStream). -When writing a JSON from DOM to output stream, transcoding can also be used. An example is in [EncodedOutputStream](stream.md##encodedoutputstream). +When writing a JSON from DOM to output stream, transcoding can also be used. An example is in [EncodedOutputStream](stream.md##EncodedOutputStream). During transcoding, the source string is decoded to into Unicode code points, and then the code points are encoded in the target format. During decoding, it will validate the byte sequence in the source string. If it is not a valid sequence, the parser will be stopped with `kParseErrorStringInvalidEncoding` error. When the source encoding of stream is the same as encoding of DOM, by default, the parser will *not* validate the sequence. User may use `kParseValidateEncodingFlag` to force validation. -## Techniques +# Techniques {#Techniques} Some techniques about using DOM API is discussed here. @@ -236,9 +244,9 @@ User may create customer handlers for transforming the DOM into other formats. F // TODO: example ~~~~~~~~~~ -For more about SAX events and handler, please refer to [SAX](sax.md). +For more about SAX events and handler, please refer to [SAX](doc/sax.md). -### User Buffer +## User Buffer {#UserBuffer} Some applications may try to avoid memory allocations whenever possible. diff --git a/doc/features.md b/doc/features.md index e73df88..b0834c4 100644 --- a/doc/features.md +++ b/doc/features.md @@ -65,7 +65,7 @@ ## Stream * Support `rapidjson::GenericStringBuffer` for storing the output JSON as string. -* Support `rapidjson::FileReadStream`/`rapidjson::FileWriteStream` for input/output `FILE` object. +* Support `rapidjson::FileReadStream` and `rapidjson::FileWriteStream` for input/output `FILE` object. * Support custom streams. ## Memory diff --git a/doc/misc/doxygenextra.css b/doc/misc/doxygenextra.css index 48b02f5..ab78a09 100644 --- a/doc/misc/doxygenextra.css +++ b/doc/misc/doxygenextra.css @@ -10,6 +10,10 @@ a { color: #4183c4; } +a.el { + font-weight: normal; +} + body, table, div, p, dl { color: #333333; font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; @@ -37,6 +41,29 @@ div.headertitle { padding: 0px; } +div.toc { + background-color: #f8f8f8; + border-color: #ddd; + margin-right: 10px; + margin-left: 20px; +} +div.toc h3 { + color: #333333; + font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; + font-size: 18px; + font-style: normal; + font-variant: normal; + font-weight: normal; +} +div.toc li { + color: #333333; + font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; + font-size: 12px; + font-style: normal; + font-variant: normal; + font-weight: normal; +} + .title { font-size: 2.5em; line-height: 63.75px; @@ -47,15 +74,16 @@ div.headertitle { margin-top: 0px; } -body h2 { +body h1 { font-size: 2em; line-height: 1.7; border-bottom: 1px solid #eee; margin: 1em 0 15px; padding: 0; + overflow: hidden; } -body h3 { +body h2 { font-size: 1.5em; line-height: 1.7; margin: 1em 0 15px; @@ -106,6 +134,12 @@ div.fragment { border-radius: 3px; } +#topbanner { + position: fixed; + margin: 15px; + z-index: 101; +} + #projectname { font-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'; @@ -132,7 +166,7 @@ div.fragment { padding: 10px 0px 20px 20px; border-top: 60px solid #2980b9; background-color: #343131; - /*height: 100% !important;*/ + width: 250px !important; position: fixed } @@ -164,17 +198,26 @@ div.fragment { color: #b3b3b3; } +#github +{ + position: fixed; + left: auto; + right: auto; + width: 250px; +} + #MSearchBox { margin: 20px; + left: 40px; right: auto; position: fixed; - width: 220px; + width: 180px; } #MSearchField { - width: 161px; + width: 121px; } #MSearchResultsWindow @@ -196,3 +239,12 @@ div.fragment { { display: none; } + +/* external link icon */ +div #contents a[href ^= "http"]:after { + content: " " url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=); +} + +.githublogo { + content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNv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ZW5kPSJyIj8+jUqS1wAAApVJREFUeNq0l89rE1EQx3e3gVJoSPzZeNEWPKgHoa0HBak0iHiy/4C3WvDmoZ56qJ7txVsPQu8qlqqHIhRKJZceesmhioQEfxTEtsoSpdJg1u/ABJ7Pmc1m8zLwgWTmzcw3L+/te+tHUeQltONgCkyCi2AEDHLsJ6iBMlgHL8FeoqokoA2j4CloRMmtwTmj7erHBXPgCWhG6a3JNXKdCiDl1cidVbXZkJoXQRi5t5BrxwoY71FzU8S4JuAIqFkJ2+BFSlEh525b/hr3+k/AklDkNsf6wTT4yv46KIMNpsy+iMdMc47HNWxbsgVcUn7FmLAzzoFAWDsBx+wVP6bUpp5ewI+DOeUx0Wd9D8F70BTGNjkWtqnhmT1JQAHcUgZd8Lo3rQb1LAT8eJVUfgGvHQigGp+V2Z0iAUUl8QH47kAA1XioxIo+bRN8OG8F/oBjwv+Z1nJgX5jpdzQDw0LCjsPmrcW7I/iHScCAEDj03FtD8A0EyuChHgg4KTlJQF3wZ7WELppnBX+dBFSVpJsOBWi1qiRgSwnOgoyD5hmuJdkWCVhTgnTvW3AgYIFrSbZGh0UW/Io5Vp+DQoK7o80pztWMemZbgxeNwCNwDbw1fIfgGZjhU6xPaJgBV8BdsMw5cbZoHsenwYFxkZzl83xTSKTiviCAfCsJLysH3POfC8m8NegyGAGfLP/VmGmfSChgXroR0RSWjEFv2J/nG84cuKFMf4sTCZqXuJd4KaXFVjEG3+tw4eXbNK/YC9oXXs3O8NY8y99L4BXY5cvLY/Bb2VZ58EOJVcB18DHJq9lRsKr8inyKGVjlmh29mtHs3AHfuhCwy1vXT/Nu2GKQt+UHsGdctyX6eQyNvc+5sfX9Dl7Pe2J/BRgAl2CpwmrsHR0AAAAASUVORK5CYII=); +} \ No newline at end of file diff --git a/doc/misc/header.html b/doc/misc/header.html index 51ab127..2dbe721 100644 --- a/doc/misc/header.html +++ b/doc/misc/header.html @@ -18,11 +18,7 @@ $extrastylesheet
- - - - - -
$searchbox
+
+$searchbox diff --git a/doc/stream.md b/doc/stream.md index 46d404c..85b26b8 100644 --- a/doc/stream.md +++ b/doc/stream.md @@ -2,11 +2,13 @@ In RapidJSON, `rapidjson::Stream` is a concept for reading/writing JSON. Here we first show how to use streams provided. And then see how to create a custom streams. -## Memory Streams +[TOC] + +# Memory Streams {#MemoryStreams} Memory streams store JSON in memory. -### StringStream (Input) +## StringStream (Input) {#StringStream} `StringStream` is the most basic input stream. It represents a complete, read-only JSON stored in memory. It is defined in `rapidjson/rapidjson.h`. @@ -34,7 +36,7 @@ d.Parse(json); Note that, `StringStream` is a typedef of `GenericStringStream >`, user may use another encodings to represent the character set of the stream. -### StringBuffer (Output) +## StringBuffer (Output) {#StringBuffer} `StringBuffer` is a simple output stream. It allocates a memory buffer for writing the whole JSON. Use `GetString()` to obtain the buffer. @@ -59,13 +61,13 @@ By default, `StringBuffer` will instantiate an internal allocator. Similarly, `StringBuffer` is a typedef of `GenericStringBuffer >`. -## File Streams +# File Streams {#FileStreams} When parsing a JSON from file, you may read the whole JSON into memory and use ``StringStream`` above. However, if the JSON is big, or memory is limited, you can use `FileReadStream`. It only read a part of JSON from file into buffer, and then let the part be parsed. If it runs out of characters in the buffer, it will read the next part from file. -### FileReadStream (Input) +## FileReadStream (Input) {#FileReadStream} `FileReadStream` reads the file via a `FILE` pointer. And user need to provide a buffer. @@ -90,7 +92,7 @@ Different from string streams, `FileReadStream` is byte stream. It does not hand Apart from reading file, user can also use `FileReadStream` to read `stdin`. -### FileWriteStream (Output) +## FileWriteStream (Output) {#FileWriteStream} `FileWriteStream` is buffered output stream. Its usage is very similar to `FileReadStream`. @@ -117,7 +119,7 @@ fclose(fp); It can also directs the output to `stdout`. -## Encoded Streams +# Encoded Streams {#EncodedStreams} Encoded streams do not contain JSON itself, but they wrap byte streams to provide basic encoding/decoding function. @@ -129,7 +131,7 @@ If the encoding of stream is known in compile-time, you may use `EncodedInputStr Note that, these encoded streams can be applied to streams other than file. For example, you may have a file in memory, or a custom byte stream, be wrapped in encoded streams. -### EncodedInputStream +## EncodedInputStream {#EncodedInputStream} `EncodedInputStream` has two template parameters. The first one is a `Encoding` class, such as `UTF8`, `UTF16LE`, defined in `rapidjson/encodings.h`. The second one is the class of stream to be wrapped. @@ -154,7 +156,7 @@ d.ParseStream<0, UTF16LE<> >(eis); // Parses UTF-16LE file into UTF-8 in memory fclose(fp); ~~~~~~~~~~ -### EncodedOutputStream +## EncodedOutputStream {#EncodedOutputStream} `EncodedOutputStream` is similar but it has a `bool putBOM` parameter in the constructor, controlling whether to write BOM into output byte stream. @@ -180,7 +182,7 @@ d.Accept(writer); // This generates UTF32-LE file from UTF-8 in memory fclose(fp); ~~~~~~~~~~ -### AutoUTFInputStream +## AutoUTFInputStream {#AutoUTFInputStream} Sometimes an application may want to handle all supported JSON encoding. `AutoUTFInputStream` will detection encoding by BOM first. If BOM is unavailable, it will use characteristics of valid JSON to make detection. If neither method success, it falls back to the UTF type provided in constructor. @@ -211,7 +213,7 @@ When specifying the encoding of stream, uses `AutoUTF` as in `ParseStr You can obtain the type of UTF via `UTFType GetType()`. And check whether a BOM is found by `HasBOM()` -### AutoUTFOutputStream +## AutoUTFOutputStream {#AutoUTFOutputStream} Similarly, to choose encoding for output during runtime, we can use `AutoUTFOutputStream`. This class is not automatic *per se*. You need to specify the UTF type and whether to write BOM in runtime. @@ -232,7 +234,7 @@ void WriteJSONFile(FILE* fp, UTFType type, bool putBOM, const Document& d) { `AutoUTFInputStream` and `AutoUTFOutputStream` is more convenient than `EncodedInputStream` and `EncodedOutputStream`. They just incur a little bit runtime overheads. -## Custom Stream +# Custom Stream {#CustomStream} In addition to memory/file streams, user can create their own stream classes which fits RapidJSON's API. For example, you may create network stream, stream from compressed file, etc. @@ -273,7 +275,7 @@ For input stream, they must implement `Peek()`, `Take()` and `Tell()`. For output stream, they must implement `Put()` and `Flush()`. There are two special interface, `PutBegin()` and `PutEnd()`, which are only for *in situ* parsing. Normal streams do not implement them. However, if the interface is not needed for a particular stream, it is still need to a dummy implementation, otherwise will generate compilation error. -### Example: istream wrapper +## Example: istream wrapper {#ExampleIStreamWrapper} The following example is a wrapper of `std::istream`, which only implements 3 functions. @@ -323,7 +325,7 @@ d.Parse(is); Note that, this implementation may not be as efficient as RapidJSON's memory or file streams, due to internal overheads of the standard library. -### Example: ostream wrapper +## Example: ostream wrapper {#ExampleOStreamWrapper} The following example is a wrapper of `std::istream`, which only implements 2 functions. @@ -367,6 +369,6 @@ d.Accept(writer); Note that, this implementation may not be as efficient as RapidJSON's memory or file streams, due to internal overheads of the standard library. -## Summary +# Summary {#Summary} This section describes stream classes available in RapidJSON. Memory streams are simple. File stream can reduce the memory required during JSON parsing and generation, if the JSON is stored in file system. Encoded streams converts between byte streams and character streams. Finally, user may create custom streams using a simple interface. diff --git a/doc/tutorial.md b/doc/tutorial.md index b58c097..f35c4d3 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2,15 +2,17 @@ This tutorial introduces the basics of the Document Object Model(DOM) API. -As shown in [Usage at a glance](../readme.md#usage-at-a-glance), a JSON can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON. +As shown in [Usage at a glance](readme.md), a JSON can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON. -## Value & Document +[TOC] + +# Value & Document {#ValueDocument} Each JSON value is stored in a type called `Value`. A `Document`, representing the DOM, contains the root of `Value`. All public types and functions of RapidJSON are defined in the `rapidjson` namespace. -### Query Value +# Query Value {#QueryValue} -In this section, we will use excerpt of [`example/tutorial/tutorial.cpp`](../example/tutorial/tutorial.cpp). +In this section, we will use excerpt of `example/tutorial/tutorial.cpp`. Assumes we have a JSON stored in a C string (`const char* json`): ~~~~~~~~~~js @@ -38,7 +40,7 @@ document.Parse(json); The JSON is now parsed into `document` as a *DOM tree*: -![tutorial](diagram/tutorial.png) +![DOM in the tutorial](diagram/tutorial.png) The root of a conforming JSON should be either an object or an array. In this case, the root is an object. ~~~~~~~~~~cpp @@ -115,7 +117,7 @@ Note that, RapidJSON does not automatically convert values between JSON types. I In the following, details about querying individual types are discussed. -### Query Array +## Query Array {#QueryArray} By default, `SizeType` is typedef of `unsigned`. In most systems, array is limited to store up to 2^32-1 elements. @@ -133,7 +135,7 @@ And other familiar query functions: * `SizeType Capacity() const` * `bool Empty() const` -### Query Object +## Query Object {#QueryObject} Similar to array, we can iterate object members by iterator: @@ -169,7 +171,7 @@ if (itr != document.MemberEnd()) printf("%s %s\n", itr->value.GetString()); ~~~~~~~~~~ -### Querying Number +## Querying Number {#QueryNumber} JSON provide a single numerical type called Number. Number can be integer or real numbers. RFC 4627 says the range of Number is specified by parser. @@ -200,7 +202,7 @@ Note that, an integer value may be obtained in various ways without conversion. When obtaining the numeric values, `GetDouble()` will convert internal integer representation to a `double`. Note that, `int` and `uint` can be safely convert to `double`, but `int64_t` and `uint64_t` may lose precision (since mantissa of `double` is only 52-bits). -### Query String +## Query String {#QueryString} In addition to `GetString()`, the `Value` class also contains `GetStringLength()`. Here explains why. @@ -225,11 +227,11 @@ string( const char* s, size_type count); which accepts the length of string as parameter. This constructor supports storing null character within the string, and should also provide better performance. -## Create/Modify Values +# Create/Modify Values {#CreateModifyValues} There are several ways to create values. After a DOM tree is created and/or modified, it can be saved as JSON again using `Writer`. -### Changing Value Type +## Change Value Type {#ChangeValueType} When creating a Value or Document by default constructor, its type is Null. To change its type, call `SetXXX()` or assignment operator, for example: ~~~~~~~~~~cpp @@ -258,7 +260,7 @@ Value o(kObjectType); Value a(kArrayType); ~~~~~~~~~~ -### Move Semantics +## Move Semantics {#MoveSemantics} A very special decision during design of RapidJSON is that, assignment of value does not copy the source value to destination value. Instead, the value from source is moved to the destination. For example, @@ -268,7 +270,7 @@ Value b(456); b = a; // a becomes a Null value, b becomes number 123. ~~~~~~~~~~ -![move1](diagram/move1.png) +![Assignment with move semantics.](diagram/move1.png) Why? What is the advantage of this semantics? @@ -287,7 +289,7 @@ Value o(kObjectType); } ~~~~~~~~~~ -![move2](diagram/move2.png) +![Copy semantics makes a lots of copy operations.](diagram/move2.png) The object `o` needs to allocate a buffer of same size as contacts, makes a deep clone of it, and then finally contacts is destructed. This will incur a lot of unnecessary allocations/deallocations and memory copying. @@ -307,11 +309,11 @@ Value o(kObjectType); } ~~~~~~~~~~ -![move3](diagram/move3.png) +![Move semantics makes no copying.](diagram/move3.png) This is called move assignment operator in C++11. As RapidJSON supports C++03, it adopts move semantics using assignment operator, and all other modifying function like `AddMember()`, `PushBack()`. -### Create String +## Create String {#CreateString} RapidJSON provide two strategies for storing string. 1. copy-string: allocates a buffer, and then copy the source data into it. @@ -346,7 +348,7 @@ s.SetString("rapidjson"); // slower, assumes null-terminated s = "rapidjson"; // shortcut, same as above ~~~~~~~~~~ -### Modify Array +## Modify Array {#ModifyArray} Value with array type provides similar APIs as `std::vector`. * `Clear()` @@ -372,7 +374,7 @@ a.PushBack("Lua", allocator).PushBack("Mio", allocator); Differs from STL, `PushBack()`/`PopBack()` returns the array reference itself. This is called fluent interface. -### Modify Object +## Modify Object {#ModifyObject} Object is a collection of key-value pairs. Each key must be a string value. The way to manipulating object is to add/remove members: * `Value& AddMember(Value&, Value&, Allocator& allocator)` @@ -388,7 +390,7 @@ contact.AddMember("name", "Milo", document.GetAllocator()); contact.AddMember("married", true, document.GetAllocator()); ~~~~~~~~~~ -### Deep Copy Value +## Deep Copy Value {#DeepCopyValue} If we really need to copy a DOM tree, we can use two APIs for deep copy: constructor with allocator, and `CopyFrom()`. ~~~~~~~~~~cpp @@ -408,7 +410,7 @@ v1.SetObject().AddMember( "array", v2, a ); d.PushBack(v1,a); ~~~~~~~~~~ -### Swap Values +## Swap Values {#SwapValues} `Swap()` is also provided. @@ -422,15 +424,15 @@ assert(b.IsInt()); Swapping two DOM trees is fast (constant time), despite the complexity of the tress. -## What's next +# What's next {#WhatsNext} This tutorial shows the basics of DOM tree query and manipulation. There are several important concepts in RapidJSON: -1. [Streams](stream.md) are channels for reading/writing JSON, which can be a in-memory string, or file stream, etc. User can also create their streams. -2. [Encoding](encoding.md) defines which character set is used in streams and memory. RapidJSON also provide Unicode conversion/validation internally. -3. [DOM](dom.md)'s basics are already covered in this tutorial. Uncover more advanced features such as *in situ* parsing, other parsing options and advanced usages. -4. [SAX](sax.md) is the foundation of parsing/generating facility in RapidJSON. Learn how to use `Reader`/`Writer` to implement even faster applications. Also try `PrettyWriter` to format the JSON. -5. [Performance](performance.md) shows some in-house and third-party benchmarks. -6. [Internals](internals.md) describes some internal designs and techniques of RapidJSON. +1. [Streams](doc/stream.md) are channels for reading/writing JSON, which can be a in-memory string, or file stream, etc. User can also create their streams. +2. [Encoding](doc/encoding.md) defines which character set is used in streams and memory. RapidJSON also provide Unicode conversion/validation internally. +3. [DOM](doc/dom.md)'s basics are already covered in this tutorial. Uncover more advanced features such as *in situ* parsing, other parsing options and advanced usages. +4. [SAX](doc/sax.md) is the foundation of parsing/generating facility in RapidJSON. Learn how to use `Reader`/`Writer` to implement even faster applications. Also try `PrettyWriter` to format the JSON. +5. [Performance](doc/performance.md) shows some in-house and third-party benchmarks. +6. [Internals](doc/internals.md) describes some internal designs and techniques of RapidJSON. You may also refer to the [FAQ](faq.md), API documentation, examples and unit tests. diff --git a/readme.md b/readme.md index 1741d91..dc4c4b8 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,9 @@ Copyright (c) 2011-2014 Milo Yip (miloyip@gmail.com) -https://github.com/miloyip/rapidjson/ +[RapidJSON GitHub](https://github.com/miloyip/rapidjson/) + +[RapidJSON Documentation](http://miloyip.github.io/rapidjson/) ## Introduction @@ -42,11 +44,11 @@ RapidJSON is a header-only C++ library. Just copy the `include/rapidjson` folder To build the tests and examples: 1. Obtain [premake4](http://industriousone.com/premake/download). -2. Copy premake4 executable to RapidJSON/build (or system path) -3. Run `rapidjson/build/premake.bat` on Windows, `RapidJSON/build/premake.sh` on Linux or other platforms -4. On Windows, build the solution at `rapidjson/build/vs2008/` or `/vs2010/` -5. On other platforms, run GNU make at `rapidjson/build/gmake/` (e.g., `make -f test.make config=release32`; `make -f example.make config=debug32`) -6. On success, the executable are generated at `rapidjson/bin` +2. Copy premake4 executable to RapidJSON/build (or system path). +3. Run `rapidjson/build/premake.bat` on Windows, `RapidJSON/build/premake.sh` on Linux or other platforms. +4. On Windows, build the solution at `rapidjson/build/vs2008/` or `/vs2010/`. +5. On other platforms, run GNU make at `rapidjson/build/gmake/` (e.g., `make -f test.make config=release32`; `make -f example.make config=debug32`). +6. On success, the executable are generated at `rapidjson/bin`. To build the [Doxygen](http://doxygen.org) documentation: @@ -58,8 +60,8 @@ To build the [Doxygen](http://doxygen.org) documentation: This simple example parses a JSON string into a document (DOM), make a simple modification of the DOM, and finally stringify the DOM to a JSON string. -[simpledom.cpp](example/simpledom/simpledom.cpp) ~~~~~~~~~~cpp +// rapidjson/example/simpledom/simpledom.cpp` #include "rapidjson/document.h" #include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" From 3600c6b47431f0820bc8de4fe4049bdce4f1213d Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 14:21:17 +0800 Subject: [PATCH 47/76] Update table CSS --- doc/misc/doxygenextra.css | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/misc/doxygenextra.css b/doc/misc/doxygenextra.css index ab78a09..b592d4e 100644 --- a/doc/misc/doxygenextra.css +++ b/doc/misc/doxygenextra.css @@ -99,6 +99,16 @@ pre.fragment { line-height: 19px; } +table.doxtable th { + background-color: #f8f8f8; + color: #333333; + font-size: 15px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #ddd; +} + #doc-content { background-color: #fff; width: 918px; From 9ff95ca2cf09c9ab2cb07f7cfdeaa803512c1af6 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Tue, 8 Jul 2014 14:38:25 +0800 Subject: [PATCH 48/76] Minor changes of doc --- doc/dom.md | 2 +- doc/misc/doxygenextra.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/dom.md b/doc/dom.md index 90a447e..d2274de 100644 --- a/doc/dom.md +++ b/doc/dom.md @@ -226,7 +226,7 @@ When the source encoding of stream is the same as encoding of DOM, by default, t Some techniques about using DOM API is discussed here. -### DOM as SAX Event Publisher +## DOM as SAX Event Publisher In RapidJSON, stringifying a DOM with `Writer` may be look a little bit weired. diff --git a/doc/misc/doxygenextra.css b/doc/misc/doxygenextra.css index b592d4e..8cc943f 100644 --- a/doc/misc/doxygenextra.css +++ b/doc/misc/doxygenextra.css @@ -251,7 +251,7 @@ div.fragment { } /* external link icon */ -div #contents a[href ^= "http"]:after { +div.contents a[href ^= "http"]:after { content: " " url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=); } From 813da24d72043882ed609150338c38fa3fd4faf9 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 8 Jul 2014 14:45:19 +0200 Subject: [PATCH 49/76] Add RAPIDJSON_DIAG_* macros to handle compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Warning push/pop support has been added to GCC in version 4.6.0, and pragmas to ignore certain warnings are present since 4.2.0. This patch hides the compiler-specific warning push/pop/disable pragmas behind a macro-based implementation (currently for MSVC and clang /GCC. This avoids warnings, as seen e.g. on GCC 4.4: ../../include/rapidjson/document.h:14: error: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’ and earlier versions complaining about unknown pragmas being ignored. Note: unittest.h and perftest.h need to check for compilers explicitly, as rapidjson.h is not included there. --- include/rapidjson/document.h | 20 +++++-------- include/rapidjson/encodedstream.h | 6 ++-- include/rapidjson/encodings.h | 6 ++-- include/rapidjson/prettywriter.h | 6 ++-- include/rapidjson/rapidjson.h | 47 +++++++++++++++++++++++++++++++ test/perftest/perftest.h | 8 ++++-- test/perftest/rapidjsontest.cpp | 6 ++-- test/unittest/readertest.cpp | 6 ++-- test/unittest/unittest.h | 8 ++++-- 9 files changed, 79 insertions(+), 34 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 3fd98b8..43f5049 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -6,13 +6,11 @@ #include // placement new #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4127) // conditional expression is constant -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" +RAPIDJSON_DIAG_PUSH +RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant +#elif defined(__GNUC__) +RAPIDJSON_DIAG_PUSH +RAPIDJSON_DIAG_OFF(effc++) #endif #ifndef RAPIDJSON_NOMEMBERITERATORCLASS @@ -1168,12 +1166,8 @@ GenericValue::GenericValue(const GenericValue { } // namespace rapidjson #ifdef __GNUC__ -#pragma GCC diagnostic pop +RAPIDJSON_DIAG_POP #endif #endif // RAPIDJSON_ENCODINGS_H_ diff --git a/include/rapidjson/prettywriter.h b/include/rapidjson/prettywriter.h index 5d04433..031f5de 100644 --- a/include/rapidjson/prettywriter.h +++ b/include/rapidjson/prettywriter.h @@ -4,8 +4,8 @@ #include "writer.h" #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" +RAPIDJSON_DIAG_PUSH +RAPIDJSON_DIAG_OFF(effc++) #endif namespace rapidjson { @@ -184,7 +184,7 @@ private: } // namespace rapidjson #ifdef __GNUC__ -#pragma GCC diagnostic pop +RAPIDJSON_DIAG_POP #endif #endif // RAPIDJSON_RAPIDJSON_H_ diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index bd500bc..0177b8c 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -156,9 +156,56 @@ template struct StaticAssertTest {}; // Helpers //!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN + #define RAPIDJSON_MULTILINEMACRO_BEGIN do { #define RAPIDJSON_MULTILINEMACRO_END \ } while((void)0, 0) + +// adopted from Boost +#define RAPIDJSON_VERSION_CODE(x,y,z) \ + (((x)*100000) + ((y)*100) + (z)) + +// token stringification +#define RAPIDJSON_STRINGIFY(x) RAPIDJSON_DO_STRINGIFY(x) +#define RAPIDJSON_DO_STRINGIFY(x) #x + +/////////////////////////////////////////////////////////////////////////////// +// RAPIDJSON_DIAG_PUSH/POP, RAPIDJSON_DIAG_OFF + +#if defined(__clang__) || (defined(__GNUC__) && RAPIDJSON_VERSION_CODE(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) >= RAPIDJSON_VERSION_CODE(4,2,0)) + +#define RAPIDJSON_PRAGMA(x) _Pragma(RAPIDJSON_STRINGIFY(x)) +#define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(GCC diagnostic x) +#define RAPIDJSON_DIAG_OFF(x) \ + RAPIDJSON_DIAG_PRAGMA(ignored RAPIDJSON_STRINGIFY(RAPIDJSON_JOIN(-W,x))) + +// push/pop support in Clang and GCC>=4.6 +#if defined(__clang__) || (defined(__GNUC__) && RAPIDJSON_VERSION_CODE(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__) >= RAPIDJSON_VERSION_CODE(4,6,0)) +#define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) +#define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) +#else // GCC >= 4.2, < 4.6 +#define RAPIDJSON_DIAG_PUSH /* ignored */ +#define RAPIDJSON_DIAG_POP /* ignored */ +#endif + +#elif defined(_MSC_VER) + +// pragma (MSVC specific) +#define RAPIDJSON_PRAGMA(x) __pragma(x) +#define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(warning(x)) + +#define RAPIDJSON_DIAG_OFF(x) RAPIDJSON_DIAG_PRAGMA(disable: x) +#define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push) +#define RAPIDJSON_DIAG_POP RAPIDJSON_DIAG_PRAGMA(pop) + +#else + +#define RAPIDJSON_DIAG_OFF(x) /* ignored */ +#define RAPIDJSON_DIAG_PUSH /* ignored */ +#define RAPIDJSON_DIAG_POP /* ignored */ + +#endif // RAPIDJSON_DIAG_* + //!@endcond /////////////////////////////////////////////////////////////////////////////// diff --git a/test/perftest/perftest.h b/test/perftest/perftest.h index d142bee..86d53c6 100644 --- a/test/perftest/perftest.h +++ b/test/perftest/perftest.h @@ -29,14 +29,16 @@ # define __STDC_CONSTANT_MACROS 1 // required by C++ standard #endif -#ifdef __GNUC__ -#pragma GCC diagnostic push +#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) #pragma GCC diagnostic ignored "-Weffc++" +#if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#pragma GCC diagnostic push +#endif #endif #include "gtest/gtest.h" -#ifdef __GNUC__ +#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #pragma GCC diagnostic pop #endif diff --git a/test/perftest/rapidjsontest.cpp b/test/perftest/rapidjsontest.cpp index ea9d144..dd8bc30 100644 --- a/test/perftest/rapidjsontest.cpp +++ b/test/perftest/rapidjsontest.cpp @@ -172,8 +172,8 @@ TEST_F(RapidJson, DocumentTraverse) { } #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" +RAPIDJSON_DIAG_PUSH +RAPIDJSON_DIAG_OFF(effc++) #endif struct ValueCounter : public BaseReaderHandler<> { @@ -186,7 +186,7 @@ struct ValueCounter : public BaseReaderHandler<> { }; #ifdef __GNUC__ -#pragma GCC diagnostic pop +RAPIDJSON_DIAG_POP #endif TEST_F(RapidJson, DocumentAccept) { diff --git a/test/unittest/readertest.cpp b/test/unittest/readertest.cpp index 62a0b42..494a9f2 100644 --- a/test/unittest/readertest.cpp +++ b/test/unittest/readertest.cpp @@ -6,8 +6,8 @@ using namespace rapidjson; #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" +RAPIDJSON_DIAG_PUSH +RAPIDJSON_DIAG_OFF(effc++) #endif template @@ -707,5 +707,5 @@ TEST(Reader, Parse_IStreamWrapper_StringStream) { } #ifdef __GNUC__ -#pragma GCC diagnostic pop +RAPIDJSON_DIAG_POP #endif diff --git a/test/unittest/unittest.h b/test/unittest/unittest.h index 506203d..0fbe568 100644 --- a/test/unittest/unittest.h +++ b/test/unittest/unittest.h @@ -13,14 +13,16 @@ #pragma warning(disable : 4996) // 'function': was declared deprecated #endif -#ifdef __GNUC__ -#pragma GCC diagnostic push +#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) #pragma GCC diagnostic ignored "-Weffc++" +#if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#pragma GCC diagnostic push +#endif #endif #include "gtest/gtest.h" -#ifdef __GNUC__ +#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #pragma GCC diagnostic pop #endif From 6aa601cd5127a7d1e2e0ecc7ec89dd1d86d4571a Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 8 Jul 2014 15:12:02 +0200 Subject: [PATCH 50/76] perftest.h/unittest.h: fix pragma ordering --- test/perftest/perftest.h | 2 +- test/unittest/unittest.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/perftest/perftest.h b/test/perftest/perftest.h index 86d53c6..0f42a6c 100644 --- a/test/perftest/perftest.h +++ b/test/perftest/perftest.h @@ -30,10 +30,10 @@ #endif #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) -#pragma GCC diagnostic ignored "-Weffc++" #if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #pragma GCC diagnostic push #endif +#pragma GCC diagnostic ignored "-Weffc++" #endif #include "gtest/gtest.h" diff --git a/test/unittest/unittest.h b/test/unittest/unittest.h index 0fbe568..75d2bc4 100644 --- a/test/unittest/unittest.h +++ b/test/unittest/unittest.h @@ -14,10 +14,10 @@ #endif #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) -#pragma GCC diagnostic ignored "-Weffc++" #if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #pragma GCC diagnostic push #endif +#pragma GCC diagnostic ignored "-Weffc++" #endif #include "gtest/gtest.h" From 3bfffa3cf9afd167e03076c6946c5f580768efab Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 4 Jul 2014 15:08:10 +0200 Subject: [PATCH 51/76] meta.h: inherit from TrueType/FalseType where applicable To reduce repetition and to provide a proper type hierarchy, let type traits inherit from TrueType and FalseType. --- include/rapidjson/internal/meta.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rapidjson/internal/meta.h b/include/rapidjson/internal/meta.h index 0861a48..5b9a8c0 100644 --- a/include/rapidjson/internal/meta.h +++ b/include/rapidjson/internal/meta.h @@ -24,11 +24,11 @@ struct SelectIf : SelectIfCond {}; template struct MaybeAddConst : SelectIfCond {}; -template struct IsSame { enum { Value = false }; }; -template struct IsSame { enum { Value = true }; }; +template struct IsSame : FalseType {}; +template struct IsSame : TrueType {}; -template struct IsConst { enum { Value = false }; }; -template struct IsConst { enum { Value = true }; }; +template struct IsConst : FalseType {}; +template struct IsConst : TrueType {}; template struct IsMoreConst { From 4007301e1f7adebef70c92bca9be177e445beaed Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 4 Jul 2014 16:53:10 +0200 Subject: [PATCH 52/76] Add a wrapper for constant string references --- include/rapidjson/document.h | 128 ++++++++++++++++++++++-------- include/rapidjson/internal/meta.h | 6 ++ 2 files changed, 101 insertions(+), 33 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 43f5049..7f56086 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -174,6 +174,51 @@ struct GenericMemberIterator { #endif // RAPIDJSON_NOMEMBERITERATORCLASS +/////////////////////////////////////////////////////////////////////////////// +// GenericStringRef + +//! Reference to a constant string (not taking a copy) +template +struct GenericStringRef { + typedef CharType Ch; //!< character type of the string + + //! Create string reference from \c const character array + template + GenericStringRef(const CharType (&str)[N]) + : s(str), length(N-1) {} + + //! Explicitly create string reference from \c const character pointer + explicit GenericStringRef(const CharType* str) + : s(str), length(internal::StrLen(str)){} + + //! Create constant string reference from pointer and length + GenericStringRef(const CharType* str, SizeType len) + : s(str), length(len) { RAPIDJSON_ASSERT(s != NULL); } + + //! implicit conversion to plain CharType pointer + operator const Ch *() const { return s; } + + const Ch* s; //!< plain CharType pointer + const SizeType length; //!< length of the string (excluding the trailing NULL terminator) + +private: + //! Disallow construction from non-const array + template + GenericStringRef(CharType (&str)[N]) /* = delete */; +}; + +//! Mark a character pointer as constant string +template +inline GenericStringRef StringRef(const CharType* str) { + return GenericStringRef(str, internal::StrLen(str)); +} + +//! Mark a character pointer as constant string +template +inline GenericStringRef StringRef(const CharType* str, size_t length) { + return GenericStringRef(str, SizeType(length)); +} + /////////////////////////////////////////////////////////////////////////////// // GenericValue @@ -196,6 +241,7 @@ public: typedef Encoding EncodingType; //!< Encoding type from template parameter. typedef Allocator AllocatorType; //!< Allocator type from template parameter. typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding. + typedef GenericStringRef StringRefType; //!< Reference to a constant string typedef typename GenericMemberIterator::Iterator MemberIterator; //!< Member iterator for iterating in object. typedef typename GenericMemberIterator::Iterator ConstMemberIterator; //!< Constant member iterator for iterating in object. typedef GenericValue* ValueIterator; //!< Value iterator for iterating in array. @@ -207,9 +253,11 @@ public: //! Default constructor creates a null value. GenericValue() : data_(), flags_(kNullFlag) {} - //! Copy constructor is not permitted. private: + //! Copy constructor is not permitted. GenericValue(const GenericValue& rhs); + //! Disabled constructor for arbitrary pointers. + template explicit GenericValue(T*); public: @@ -283,16 +331,16 @@ public: explicit GenericValue(double d) : data_(), flags_(kNumberDoubleFlag) { data_.n.d = d; } //! Constructor for constant string (i.e. do not make a copy of string) - GenericValue(const Ch* s, SizeType length) : data_(), flags_() { SetStringRaw(s, length); } + GenericValue(const Ch* s, SizeType length) : data_(), flags_() { SetStringRaw(StringRef(s, length)); } //! Constructor for constant string (i.e. do not make a copy of string) - explicit GenericValue(const Ch* s) : data_(), flags_() { SetStringRaw(s, internal::StrLen(s)); } + explicit GenericValue(StringRefType s) : data_(), flags_() { SetStringRaw(s); } //! Constructor for copy-string (i.e. do make a copy of string) - GenericValue(const Ch* s, SizeType length, Allocator& allocator) : data_(), flags_() { SetStringRaw(s, length, allocator); } + GenericValue(const Ch* s, SizeType length, Allocator& allocator) : data_(), flags_() { SetStringRaw(StringRef(s, length), allocator); } //! Constructor for copy-string (i.e. do make a copy of string) - GenericValue(const Ch*s, Allocator& allocator) : data_(), flags_() { SetStringRaw(s, internal::StrLen(s), allocator); } + GenericValue(const Ch*s, Allocator& allocator) : data_(), flags_() { SetStringRaw(StringRef(s), allocator); } //! Destructor. /*! Need to destruct elements of array, members of object, or copy-string. @@ -339,12 +387,17 @@ public: return *this; } + //! Assignment of constant string reference (no copy) + GenericValue& operator=(StringRefType str) { + return (*this).template operator=(str); + } //! Assignment with primitive types. - /*! \tparam T Either Type, int, unsigned, int64_t, uint64_t, const Ch* + /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t \param value The value to be assigned. */ template - GenericValue& operator=(T value) { + RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer,GenericValue&) + operator=(T value) { this->~GenericValue(); new (this) GenericValue(value); return *this; @@ -428,7 +481,7 @@ public: A better approach is to use the now public FindMember(). */ GenericValue& operator[](const Ch* name) { - GenericValue n(name, internal::StrLen(name)); + GenericValue n(StringRef(name)); return (*this)[n]; } const GenericValue& operator[](const Ch* name) const { return const_cast(*this)[name]; } @@ -481,7 +534,7 @@ public: \c std::map, this has been changed to MemberEnd() now. */ MemberIterator FindMember(const Ch* name) { - GenericValue n(name, internal::StrLen(name)); + GenericValue n(StringRef(name)); return FindMember(n); } @@ -530,19 +583,23 @@ public: return *this; } - GenericValue& AddMember(const Ch* name, Allocator& nameAllocator, GenericValue& value, Allocator& allocator) { - GenericValue n(name, internal::StrLen(name), nameAllocator); + //! Add a member (name-value pair) to the object. + GenericValue& AddMember(StringRefType name, GenericValue& value, Allocator& allocator) { + GenericValue n(name); return AddMember(n, value, allocator); } - GenericValue& AddMember(const Ch* name, GenericValue& value, Allocator& allocator) { - GenericValue n(name, internal::StrLen(name)); - return AddMember(n, value, allocator); + //! Add a constant string value as member (name-value pair) to the object. + GenericValue& AddMember(StringRefType name, StringRefType value, Allocator& allocator) { + GenericValue v(value); + return AddMember(name, v, allocator); } + //! Add any primitive value as member (name-value pair) to the object. template - GenericValue& AddMember(const Ch* name, T value, Allocator& allocator) { - GenericValue n(name, internal::StrLen(name)); + RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer,GenericValue&) + AddMember(StringRefType name, T value, Allocator& allocator) { + GenericValue n(name); GenericValue v(value); return AddMember(n, v, allocator); } @@ -553,7 +610,7 @@ public: \note Removing member is implemented by moving the last member. So the ordering of members is changed. */ bool RemoveMember(const Ch* name) { - GenericValue n(name, internal::StrLen(name)); + GenericValue n(StringRef(name)); return RemoveMember(n); } @@ -657,7 +714,7 @@ int z = a[0u].GetInt(); // This works too. return *this; } - //! Append a value at the end of the array. + //! Append a GenericValue at the end of the array. /*! \param value The value to be appended. \param allocator The allocator for allocating memory. It must be the same one use previously. \return The value itself for fluent API. @@ -672,8 +729,15 @@ int z = a[0u].GetInt(); // This works too. return *this; } + //! Append a constant string reference at the end of the array. + GenericValue& PushBack(StringRefType value, Allocator& allocator) { + return (*this).template PushBack(value, allocator); + } + + //! Append a primitive value at the end of the array. template - GenericValue& PushBack(T value, Allocator& allocator) { + RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer,GenericValue&) + PushBack(T value, Allocator& allocator) { GenericValue v(value); return PushBack(v, allocator); } @@ -728,13 +792,13 @@ int z = a[0u].GetInt(); // This works too. \param length The length of source string, excluding the trailing null terminator. \return The value itself for fluent API. */ - GenericValue& SetString(const Ch* s, SizeType length) { this->~GenericValue(); SetStringRaw(s, length); return *this; } + GenericValue& SetString(const Ch* s, SizeType length) { return SetString(StringRef(s, length)); } //! Set this value as a string without copying source string. - /*! \param s source string pointer. + /*! \param s source string reference \return The value itself for fluent API. */ - GenericValue& SetString(const Ch* s) { return SetString(s, internal::StrLen(s)); } + GenericValue& SetString(StringRefType s) { this->~GenericValue(); SetStringRaw(s); return *this; } //! Set this value as a string by copying from source string. /*! This version has better performance with supplied length, and also support string containing null character. @@ -743,14 +807,14 @@ int z = a[0u].GetInt(); // This works too. \param allocator Allocator for allocating copied buffer. Commonly use document.GetAllocator(). \return The value itself for fluent API. */ - GenericValue& SetString(const Ch* s, SizeType length, Allocator& allocator) { this->~GenericValue(); SetStringRaw(s, length, allocator); return *this; } + GenericValue& SetString(const Ch* s, SizeType length, Allocator& allocator) { this->~GenericValue(); SetStringRaw(StringRef(s, length), allocator); return *this; } //! Set this value as a string by copying from source string. /*! \param s source string. \param allocator Allocator for allocating copied buffer. Commonly use document.GetAllocator(). \return The value itself for fluent API. */ - GenericValue& SetString(const Ch* s, Allocator& allocator) { SetString(s, internal::StrLen(s), allocator); return *this; } + GenericValue& SetString(const Ch* s, Allocator& allocator) { return SetString(s, internal::StrLen(s), allocator); } //@} @@ -906,21 +970,19 @@ private: } //! Initialize this value as constant string, without calling destructor. - void SetStringRaw(const Ch* s, SizeType length) { - RAPIDJSON_ASSERT(s != NULL); + void SetStringRaw(StringRefType s) { flags_ = kConstStringFlag; data_.s.str = s; - data_.s.length = length; + data_.s.length = s.length; } //! Initialize this value as copy string with initial data, without calling destructor. - void SetStringRaw(const Ch* s, SizeType length, Allocator& allocator) { - RAPIDJSON_ASSERT(s != NULL); + void SetStringRaw(StringRefType s, Allocator& allocator) { flags_ = kCopyStringFlag; - data_.s.str = (Ch *)allocator.Malloc((length + 1) * sizeof(Ch)); - data_.s.length = length; - memcpy(const_cast(data_.s.str), s, length * sizeof(Ch)); - const_cast(data_.s.str)[length] = '\0'; + data_.s.str = (Ch *)allocator.Malloc((s.length + 1) * sizeof(Ch)); + data_.s.length = s.length; + memcpy(const_cast(data_.s.str), s, s.length * sizeof(Ch)); + const_cast(data_.s.str)[s.length] = '\0'; } //! Assignment without calling destructor diff --git a/include/rapidjson/internal/meta.h b/include/rapidjson/internal/meta.h index 5b9a8c0..b8d3295 100644 --- a/include/rapidjson/internal/meta.h +++ b/include/rapidjson/internal/meta.h @@ -30,6 +30,9 @@ template struct IsSame : TrueType {}; template struct IsConst : FalseType {}; template struct IsConst : TrueType {}; +template struct IsPointer : FalseType {}; +template struct IsPointer : TrueType {}; + template struct IsMoreConst { enum { Value = @@ -64,6 +67,9 @@ template struct RemoveSfinaeFptr { typedef typename ::rapidjson::internal::EnableIf \ ::Type * = NULL +#define RAPIDJSON_DISABLEIF_RETURN(cond,returntype) \ + typename ::rapidjson::internal::DisableIf::Type + } // namespace internal } // namespace rapidjson //@endcond From 7c7eb1c5c04bbb9123b511bafb658defef25f6c1 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 8 Jul 2014 18:55:55 +0200 Subject: [PATCH 53/76] Travis CI: build/update Doxygen from separate script In this patch, a script 'build/travis-doxygen.sh' is added to build and push the Doxygen documentation to the GitHub pages at https://miloyip.githib.io/rapidjson. The script exits gracefully, if the build is requested for - a branch other than 'master' - a pull-request - a job (i.e. CI configuration) other than "1" In case the "secure variables" are not available, only the final upload is skipped, in order to allow testing of the script's basic functionality. Update .travis.yml to call the script. --- .travis.yml | 44 ++----------------- build/travis-doxygen.sh | 97 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 40 deletions(-) create mode 100755 build/travis-doxygen.sh diff --git a/.travis.yml b/.travis.yml index 55cf8ae..2093f94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,50 +19,14 @@ before_install: install: true before_script: - - cd build - - premake4 'gmake' - - cd "${TRAVIS_BUILD_DIR}" + - pushd build && premake4 'gmake' && popd script: - make -C build/gmake -f test.make - make -C build/gmake -f example.make - - cd bin + - pushd bin - ./unittest_${config_suffix} - valgrind --leak-check=full --error-exitcode=1 ./unittest_${config_suffix} - if [ "$config" = "release64" ]; then ./perftest_${config_suffix}; fi - -after_success: -# Build latest doxygen from source -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/doxygen/doxygen.git; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd doxygen; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make distclean; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git pull; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then ./configure; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then make; fi -# - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo make install; fi - -# Install doxygen binary distribution - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd /tmp; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then wget http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.7.linux.bin.tar.gz; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then tar -xvf doxygen-1.8.7.linux.bin.tar.gz; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then sudo install -m 755 doxygen-1.8.7/bin/doxygen /usr/bin; fi - -# Run doxygen - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd "${TRAVIS_BUILD_DIR}"; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then doxygen build/Doxyfile; fi - -# Push to Github Pages - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git config --global user.name "${GIT_NAME}"; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git config --global user.email ${GIT_EMAIL}; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then mkdir build/doc; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd build/doc; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git clone https://github.com/miloyip/rapidjson; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cd rapidjson; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git checkout gh-pages; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then cp -r ../../../doc/html/* .; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git add --all; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git commit -m "Automatic doxygen build"; fi - - if [ "$config" = "release64" -a "$CC" = "clang" ]; then git push https://${GH_TOKEN}@github.com/miloyip/rapidjson gh-pages; fi + - popd + - ./build/travis-doxygen.sh; diff --git a/build/travis-doxygen.sh b/build/travis-doxygen.sh new file mode 100755 index 0000000..a85d7ba --- /dev/null +++ b/build/travis-doxygen.sh @@ -0,0 +1,97 @@ +#!/bin/bash +# Update Doxygen documentation after push to 'master'. +# Author: @pah + +set -e + +SUDO=sudo +DOXYGEN_VER=doxygen-1.8.7 +DOXYGEN_TAR=${DOXYGEN_VER}.linux.bin.tar.gz +DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/${DOXYGEN_TAR}" +DOXYGEN_BIN="/usr/local/bin/doxygen" + +GHPAGES_REPO="miloyip/rapidjson" +GHPAGES_BASE="https://github.com/${GHPAGES_REPO}" +# NOTE: not expanded here to hide GH_TOKEN +GHPAGES_PUSH='https://${GH_TOKEN}@github.com/${GHPAGES_REPO}' + +skip() { + echo "$@" 1>&2 + echo "Exiting..." 1>&2 + exit 0 +} + +abort() { + echo "Error: $@" 1>&2 + echo "Exiting..." 1>&2 + exit 1 +} + +# TRAVIS_BUILD_DIR not set, exiting +[ -d "${TRAVIS_BUILD_DIR-/nonexistent}" ] || \ + abort '${TRAVIS_BUILD_DIR} not set or nonexistent.' + +# check for pull-requests +[ "${TRAVIS_PULL_REQUEST}" = "false" ] || \ + skip "Not running Doxygen for pull-requests." + +# check for branch name +[ "${TRAVIS_BRANCH}" = "master" ] || \ + skip "Running Doxygen only for updates on 'master' branch (current: ${TRAVIS_BRANCH})." + +# check for job number +[ "${TRAVIS_JOB_NUMBER}" = "${TRAVIS_BUILD_NUMBER}.1" ] || \ + skip "Running Doxygen only on first job of build ${TRAVIS_BUILD_NUMBER} (current: ${TRAVIS_JOB_NUMBER})." + +# install doxygen binary distribution +doxygen_install() +{ + wget -O - "${DOXYGEN_URL}" | \ + tar xz -C ${TMPDIR-/tmp} ${DOXYGEN_VER}/bin/doxygen + $SUDO install -m 755 ${TMPDIR-/tmp}/${DOXYGEN_VER}/bin/doxygen \ + ${DOXYGEN_BIN}; +} + +doxygen_run() +{ + cd "${TRAVIS_BUILD_DIR}"; + doxygen build/Doxyfile; +} + +gh_pages_prepare() +{ + cd "${TRAVIS_BUILD_DIR}/doc"; + [ ! -d "html" ] || \ + abort "Doxygen target directory already exists." + git clone --single-branch -b gh-pages ${GHPAGES_BASE} html + cd html + # clean working dir + rm -f .git/index + git clean -df +} + +gh_pages_commit() { + cd "${TRAVIS_BUILD_DIR}/doc/html"; + git add --all; + git commit -m "Automatic doxygen build"; +} + +gh_pages_push() { + # check for secure variables + [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] || \ + skip "Secure variables not available, not updating GitHub pages." + [ "${GH_TOKEN+set}" = set ] || \ + skip "GitHub access token not available, not updating GitHub pages." + + cd "${TRAVIS_BUILD_DIR}/doc/html"; + # push to GitHub without printing GH_TOKEN even in "set -x" mode + ( echo "git push ${GHPAGES_PUSH} gh-pages" ; set +x; \ + eval "git push ${GHPAGES_PUSH} gh-pages" ) +} + +doxygen_install +gh_pages_prepare +doxygen_run +gh_pages_commit +gh_pages_push + From 524362242b49c329e09c5b1331504565b7171b3c Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 4 Jul 2014 16:55:19 +0200 Subject: [PATCH 54/76] Add documentation to new string API --- include/rapidjson/document.h | 201 ++++++++++++++++++++++++++++++++--- 1 file changed, 188 insertions(+), 13 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 7f56086..44cf532 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -178,20 +178,92 @@ struct GenericMemberIterator { // GenericStringRef //! Reference to a constant string (not taking a copy) +/*! + \tparam CharType character type of the string + + This helper class is used to automatically infer constant string + references for string literals, especially from \c const \b (!) + character arrays. + + The main use is for creating JSON string values without copying the + source string via an \ref Allocator. This requires that the referenced + string pointers have a sufficient lifetime, which exceeds the lifetime + of the associated GenericValue. + + \b Example + \code + Value v("foo"); // ok, no need to copy & calculate length + const char foo[] = "foo"; + v.SetString(foo); // ok + + const char* bar = foo; + // Value x(bar); // not ok, can't rely on bar's lifetime + Value x(StringRef(bar)); // lifetime explicitly guaranteed by user + Value y(StringRef(bar, 3)); // ok, explicitly pass length + \endcode + + \see StringRef, GenericValue::SetString +*/ template struct GenericStringRef { typedef CharType Ch; //!< character type of the string //! Create string reference from \c const character array + /*! + This constructor implicitly creates a constant string reference from + a \c const character array. It has better performance than + \ref StringRef(const CharType*) by inferring the string \ref length + from the array length, and also supports strings containing null + characters. + + \tparam N length of the string, automatically inferred + + \param str Constant character array, lifetime assumed to be longer + than the use of the string in e.g. a GenericValue + + \post \ref s == str + + \note Constant complexity. + \note There is a hidden, private overload to disallow references to + non-const character arrays to be created via this constructor. + By this, e.g. function-scope arrays used to be filled via + \c snprintf are excluded from consideration. + In such cases, the referenced string should be \b copied to the + GenericValue instead. + */ template GenericStringRef(const CharType (&str)[N]) : s(str), length(N-1) {} //! Explicitly create string reference from \c const character pointer + /*! + This constructor can be used to \b explicitly create a reference to + a constant string pointer. + + \see StringRef(const CharType*) + + \param str Constant character pointer, lifetime assumed to be longer + than the use of the string in e.g. a GenericValue + + \post \ref s == str + + \note There is a hidden, private overload to disallow references to + non-const character arrays to be created via this constructor. + By this, e.g. function-scope arrays used to be filled via + \c snprintf are excluded from consideration. + In such cases, the referenced string should be \b copied to the + GenericValue instead. + */ explicit GenericStringRef(const CharType* str) : s(str), length(internal::StrLen(str)){} //! Create constant string reference from pointer and length + /*! \param str constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue + \param len length of the string, excluding the trailing NULL terminator + + \post \ref s == str && \ref length == len + \note Constant complexity. + */ GenericStringRef(const CharType* str, SizeType len) : s(str), length(len) { RAPIDJSON_ASSERT(s != NULL); } @@ -208,12 +280,37 @@ private: }; //! Mark a character pointer as constant string +/*! Mark a plain character pointer as a "string literal". This function + can be used to avoid copying a character string to be referenced as a + value in a JSON GenericValue object, if the string's lifetime is known + to be valid long enough. + \tparam CharType Character type of the string + \param str Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue + \return GenericStringRef string reference object + \relatesalso GenericStringRef + + \see GenericValue::GenericValue(StringRefType), GenericValue::operator=(StringRefType), GenericValue::SetString(StringRefType), GenericValue::PushBack(StringRefType, Allocator&), GenericValue::AddMember +*/ template inline GenericStringRef StringRef(const CharType* str) { return GenericStringRef(str, internal::StrLen(str)); } //! Mark a character pointer as constant string +/*! Mark a plain character pointer as a "string literal". This function + can be used to avoid copying a character string to be referenced as a + value in a JSON GenericValue object, if the string's lifetime is known + to be valid long enough. + + This version has better performance with supplied length, and also + supports string containing null characters. + + \tparam CharType character type of the string + \param str Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue + \param length The length of source string. + \return GenericStringRef string reference object + \relatesalso GenericStringRef +*/ template inline GenericStringRef StringRef(const CharType* str, size_t length) { return GenericStringRef(str, SizeType(length)); @@ -279,7 +376,7 @@ public: /*! Creates a copy of a Value by using the given Allocator \tparam SourceAllocator allocator of \c rhs \param rhs Value to copy from (read-only) - \param allocator Allocator to use for copying + \param allocator Allocator for allocating copied elements and buffers. Commonly use GenericDocument::GetAllocator(). \see CopyFrom() */ template< typename SourceAllocator > @@ -388,12 +485,25 @@ public: } //! Assignment of constant string reference (no copy) + /*! \param str Constant string reference to be assigned + \note This overload is needed to avoid clashes with the generic primitive type assignment overload below. + \see GenericStringRef, operator=(T) + */ GenericValue& operator=(StringRefType str) { return (*this).template operator=(str); } + //! Assignment with primitive types. /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t \param value The value to be assigned. + + \note The source type \c T explicitly disallows all pointer types, + especially (\c const) \ref Ch*. This helps avoiding implicitly + referencing character strings with insufficient lifetime, use + \ref SetString(const Ch*, Allocator&) (for copying) or + \ref StringRef() (to explicitly mark the pointer as constant) instead. + All other pointer types would implicitly convert to \c bool, + use \ref SetBool() instead. */ template RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer,GenericValue&) @@ -463,6 +573,8 @@ public: //@{ bool GetBool() const { RAPIDJSON_ASSERT(IsBool()); return flags_ == kTrueFlag; } + //!< Set boolean value + /*! \post IsBool() == true */ GenericValue& SetBool(bool b) { this->~GenericValue(); new (this) GenericValue(b); return *this; } //@} @@ -471,6 +583,7 @@ public: //@{ //! Set this value as an empty object. + /*! \post IsObject() == true */ GenericValue& SetObject() { this->~GenericValue(); new (this) GenericValue(kObjectType); return *this; } //! Get the value associated with the name. @@ -557,9 +670,11 @@ public: //! Add a member (name-value pair) to the object. /*! \param name A string value as name of member. \param value Value of any type. - \param allocator Allocator for reallocating memory. - \return The value itself for fluent API. - \note The ownership of name and value will be transfered to this object if success. + \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). + \return The value itself for fluent API. + \note The ownership of \c name and \c value will be transferred to this object on success. + \pre IsObject() && name.IsString() + \post name.IsNull() && value.IsNull() */ GenericValue& AddMember(GenericValue& name, GenericValue& value, Allocator& allocator) { RAPIDJSON_ASSERT(IsObject()); @@ -584,18 +699,48 @@ public: } //! Add a member (name-value pair) to the object. + /*! \param name A constant string reference as name of member. + \param value Value of any type. + \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). + \return The value itself for fluent API. + \note The ownership of \c value will be transferred to this object on success. + \pre IsObject() + \post value.IsNull() + */ GenericValue& AddMember(StringRefType name, GenericValue& value, Allocator& allocator) { GenericValue n(name); return AddMember(n, value, allocator); } //! Add a constant string value as member (name-value pair) to the object. + /*! \param name A constant string reference as name of member. + \param value constant string reference as value of member. + \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). + \return The value itself for fluent API. + \pre IsObject() + \note This overload is needed to avoid clashes with the generic primitive type AddMember(StringRefType,T,Allocator&) overload below. + */ GenericValue& AddMember(StringRefType name, StringRefType value, Allocator& allocator) { GenericValue v(value); return AddMember(name, v, allocator); } //! Add any primitive value as member (name-value pair) to the object. + /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t + \param name A constant string reference as name of member. + \param value Value of primitive type \c T as value of member + \param allocator Allocator for reallocating memory. Commonly use GenericDocument::GetAllocator(). + \return The value itself for fluent API. + \pre IsObject() + + \note The source type \c T explicitly disallows all pointer types, + especially (\c const) \ref Ch*. This helps avoiding implicitly + referencing character strings with insufficient lifetime, use + \ref AddMember(StringRefType, GenericValue&, Allocator&) or \ref + AddMember(StringRefType, StringRefType, Allocator&). + All other pointer types would implicitly convert to \c bool, + use an explicit cast instead, if needed. + */ template RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer,GenericValue&) AddMember(StringRefType name, T value, Allocator& allocator) { @@ -656,6 +801,7 @@ public: //@{ //! Set this value as an empty array. + /*! \post IsArray == true */ GenericValue& SetArray() { this->~GenericValue(); new (this) GenericValue(kArrayType); return *this; } //! Get the number of elements in array. @@ -702,7 +848,7 @@ int z = a[0u].GetInt(); // This works too. //! Request the array to have enough capacity to store elements. /*! \param newCapacity The capacity that the array at least need to have. - \param allocator The allocator for allocating memory. It must be the same one use previously. + \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). \return The value itself for fluent API. */ GenericValue& Reserve(SizeType newCapacity, Allocator &allocator) { @@ -715,11 +861,13 @@ int z = a[0u].GetInt(); // This works too. } //! Append a GenericValue at the end of the array. - /*! \param value The value to be appended. - \param allocator The allocator for allocating memory. It must be the same one use previously. - \return The value itself for fluent API. - \note The ownership of the value will be transfered to this object if success. - \note If the number of elements to be appended is known, calls Reserve() once first may be more efficient. + /*! \param value Value to be appended. + \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). + \pre IsArray() == true + \post value.IsNull() == true + \return The value itself for fluent API. + \note The ownership of \c value will be transferred to this array on success. + \note If the number of elements to be appended is known, calls Reserve() once first may be more efficient. */ GenericValue& PushBack(GenericValue& value, Allocator& allocator) { RAPIDJSON_ASSERT(IsArray()); @@ -730,11 +878,33 @@ int z = a[0u].GetInt(); // This works too. } //! Append a constant string reference at the end of the array. + /*! \param value Constant string reference to be appended. + \param allocator Allocator for reallocating memory. It must be the same one used previously. Commonly use GenericDocument::GetAllocator(). + \pre IsArray() == true + \return The value itself for fluent API. + \note If the number of elements to be appended is known, calls Reserve() once first may be more efficient. + \see GenericStringRef + */ GenericValue& PushBack(StringRefType value, Allocator& allocator) { return (*this).template PushBack(value, allocator); } - //! Append a primitive value at the end of the array. + //! Append a primitive value at the end of the array(.) + /*! \tparam T Either \ref Type, \c int, \c unsigned, \c int64_t, \c uint64_t + \param value Value of primitive type T to be appended. + \param allocator Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator(). + \pre IsArray() == true + \return The value itself for fluent API. + \note If the number of elements to be appended is known, calls Reserve() once first may be more efficient. + + \note The source type \c T explicitly disallows all pointer types, + especially (\c const) \ref Ch*. This helps avoiding implicitly + referencing character strings with insufficient lifetime, use + \ref PushBack(GenericValue&, Allocator&) or \ref + PushBack(StringRefType, Allocator&). + All other pointer types would implicitly convert to \c bool, + use an explicit cast instead, if needed. + */ template RAPIDJSON_DISABLEIF_RETURN(internal::IsPointer,GenericValue&) PushBack(T value, Allocator& allocator) { @@ -791,12 +961,15 @@ int z = a[0u].GetInt(); // This works too. \param s source string pointer. \param length The length of source string, excluding the trailing null terminator. \return The value itself for fluent API. + \post IsString() == true && GetString() == s && GetStringLength() == length + \see SetString(StringRefType) */ GenericValue& SetString(const Ch* s, SizeType length) { return SetString(StringRef(s, length)); } //! Set this value as a string without copying source string. /*! \param s source string reference \return The value itself for fluent API. + \post IsString() == true && GetString() == s && GetStringLength() == s.length */ GenericValue& SetString(StringRefType s) { this->~GenericValue(); SetStringRaw(s); return *this; } @@ -804,15 +977,17 @@ int z = a[0u].GetInt(); // This works too. /*! This version has better performance with supplied length, and also support string containing null character. \param s source string. \param length The length of source string, excluding the trailing null terminator. - \param allocator Allocator for allocating copied buffer. Commonly use document.GetAllocator(). + \param allocator Allocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator(). \return The value itself for fluent API. + \post IsString() == true && GetString() != s && strcmp(GetString(),s) == 0 && GetStringLength() == length */ GenericValue& SetString(const Ch* s, SizeType length, Allocator& allocator) { this->~GenericValue(); SetStringRaw(StringRef(s, length), allocator); return *this; } //! Set this value as a string by copying from source string. /*! \param s source string. - \param allocator Allocator for allocating copied buffer. Commonly use document.GetAllocator(). + \param allocator Allocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator(). \return The value itself for fluent API. + \post IsString() == true && GetString() != s && strcmp(GetString(),s) == 0 && GetStringLength() == length */ GenericValue& SetString(const Ch* s, Allocator& allocator) { return SetString(s, internal::StrLen(s), allocator); } From db8f45573f812a4d070c589c91fccf7e8e2211f2 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 4 Jul 2014 15:43:57 +0200 Subject: [PATCH 55/76] Doxyfile: expand internal RAPIDJSON_DISABLEIF_RETURN macro --- build/Doxyfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/Doxyfile b/build/Doxyfile index c74b79d..9d504b5 100644 --- a/build/Doxyfile +++ b/build/Doxyfile @@ -1990,7 +1990,8 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = +PREDEFINED = \ + RAPIDJSON_DISABLEIF_RETURN(cond,returntype)=returntype # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The From 8bbf41f7c7058c3f7231a14fb47f6677b20a694d Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Fri, 4 Jul 2014 16:34:10 +0200 Subject: [PATCH 56/76] update string API tests --- test/unittest/valuetest.cpp | 117 ++++++++++++++++++++++++++++++------ 1 file changed, 100 insertions(+), 17 deletions(-) diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 93d4eb0..39500d0 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -23,6 +23,25 @@ TEST(Value, assignment_operator) { y = x; EXPECT_TRUE(x.IsNull()); // move semantic EXPECT_EQ(1234, y.GetInt()); + + y = 5678; + EXPECT_TRUE(y.IsInt()); + EXPECT_EQ(5678, y.GetInt()); + + x = "Hello"; + EXPECT_TRUE(x.IsString()); + EXPECT_STREQ(x.GetString(),"Hello"); + + y = StringRef(x.GetString(),x.GetStringLength()); + EXPECT_TRUE(y.IsString()); + EXPECT_EQ(y.GetString(),x.GetString()); + EXPECT_EQ(y.GetStringLength(),x.GetStringLength()); + + static char mstr[] = "mutable"; + // y = mstr; // should not compile + y = StringRef(mstr); + EXPECT_TRUE(y.IsString()); + EXPECT_EQ(y.GetString(),mstr); } template @@ -350,8 +369,8 @@ TEST(Value, Double) { } TEST(Value, String) { - // Constructor with const string - Value x("Hello", 5); + // Construction with const string + Value x("Hello", 5); // literal EXPECT_EQ(kStringType, x.GetType()); EXPECT_TRUE(x.IsString()); EXPECT_STREQ("Hello", x.GetString()); @@ -365,9 +384,41 @@ TEST(Value, String) { EXPECT_FALSE(x.IsObject()); EXPECT_FALSE(x.IsArray()); + static const char cstr[] = "World"; // const array + Value(cstr).Swap(x); + EXPECT_TRUE(x.IsString()); + EXPECT_EQ(x.GetString(), cstr); + EXPECT_EQ(x.GetStringLength(), sizeof(cstr)-1); + + static char mstr[] = "Howdy"; // non-const array + // Value(mstr).Swap(x); // should not compile + Value(StringRef(mstr)).Swap(x); + EXPECT_TRUE(x.IsString()); + EXPECT_EQ(x.GetString(), mstr); + EXPECT_EQ(x.GetStringLength(), sizeof(mstr)-1); + strncpy(mstr,"Hello", sizeof(mstr)); + EXPECT_STREQ(x.GetString(), "Hello"); + + const char* pstr = cstr; + //Value(pstr).Swap(x); // should not compile + Value(StringRef(pstr)).Swap(x); + EXPECT_TRUE(x.IsString()); + EXPECT_EQ(x.GetString(), cstr); + EXPECT_EQ(x.GetStringLength(), sizeof(cstr)-1); + + char* mpstr = mstr; + Value(StringRef(mpstr,sizeof(mstr)-1)).Swap(x); + EXPECT_TRUE(x.IsString()); + EXPECT_EQ(x.GetString(), mstr); + EXPECT_EQ(x.GetStringLength(), 5u); + EXPECT_STREQ(x.GetString(), "Hello"); + // Constructor with copy string MemoryPoolAllocator<> allocator; Value c(x.GetString(), x.GetStringLength(), allocator); + EXPECT_NE(x.GetString(), c.GetString()); + EXPECT_EQ(x.GetStringLength(), c.GetStringLength()); + EXPECT_STREQ(x.GetString(), c.GetString()); //x.SetString("World"); x.SetString("World", 5); EXPECT_STREQ("Hello", c.GetString()); @@ -381,11 +432,31 @@ TEST(Value, String) { // SetConsttring() Value z; - //z.SetString("Hello"); + z.SetString("Hello"); + EXPECT_TRUE(x.IsString()); z.SetString("Hello", 5); EXPECT_STREQ("Hello", z.GetString()); + EXPECT_STREQ("Hello", z.GetString()); EXPECT_EQ(5u, z.GetStringLength()); + z.SetString("Hello"); + EXPECT_TRUE(z.IsString()); + EXPECT_STREQ("Hello", z.GetString()); + + //z.SetString(mstr); // should not compile + //z.SetString(pstr); // should not compile + z.SetString(StringRef(mstr)); + EXPECT_TRUE(z.IsString()); + EXPECT_STREQ(z.GetString(), mstr); + + z.SetString(cstr); + EXPECT_TRUE(z.IsString()); + EXPECT_EQ(cstr, z.GetString()); + + z = cstr; + EXPECT_TRUE(z.IsString()); + EXPECT_EQ(cstr, z.GetString()); + // SetString() char s[] = "World"; Value w; @@ -424,11 +495,13 @@ TEST(Value, Array) { x.PushBack(v, allocator); v.SetInt(123); x.PushBack(v, allocator); + //x.PushBack((const char*)"foo", allocator); // should not compile + x.PushBack("foo", allocator); EXPECT_FALSE(x.Empty()); - EXPECT_EQ(4u, x.Size()); + EXPECT_EQ(5u, x.Size()); EXPECT_FALSE(y.Empty()); - EXPECT_EQ(4u, y.Size()); + EXPECT_EQ(5u, y.Size()); EXPECT_TRUE(x[SizeType(0)].IsNull()); EXPECT_TRUE(x[1u].IsTrue()); EXPECT_TRUE(x[2u].IsFalse()); @@ -439,6 +512,8 @@ TEST(Value, Array) { EXPECT_TRUE(y[2u].IsFalse()); EXPECT_TRUE(y[3u].IsInt()); EXPECT_EQ(123, y[3u].GetInt()); + EXPECT_TRUE(y[4u].IsString()); + EXPECT_STREQ("foo", y[4u].GetString()); // iterator Value::ValueIterator itr = x.Begin(); @@ -454,6 +529,10 @@ TEST(Value, Array) { EXPECT_TRUE(itr != x.End()); EXPECT_TRUE(itr->IsInt()); EXPECT_EQ(123, itr->GetInt()); + ++itr; + EXPECT_TRUE(itr != x.End()); + EXPECT_TRUE(itr->IsString()); + EXPECT_STREQ("foo", itr->GetString()); // const iterator Value::ConstValueIterator citr = y.Begin(); @@ -469,13 +548,18 @@ TEST(Value, Array) { EXPECT_TRUE(citr != y.End()); EXPECT_TRUE(citr->IsInt()); EXPECT_EQ(123, citr->GetInt()); + ++citr; + EXPECT_TRUE(citr != y.End()); + EXPECT_TRUE(citr->IsString()); + EXPECT_STREQ("foo", citr->GetString()); // PopBack() x.PopBack(); - EXPECT_EQ(3u, x.Size()); + EXPECT_EQ(4u, x.Size()); EXPECT_TRUE(y[SizeType(0)].IsNull()); - EXPECT_TRUE(y[1].IsTrue()); - EXPECT_TRUE(y[2].IsFalse()); + EXPECT_TRUE(y[1u].IsTrue()); + EXPECT_TRUE(y[2u].IsFalse()); + EXPECT_TRUE(y[3u].IsInt()); // Clear() x.Clear(); @@ -502,16 +586,13 @@ TEST(Value, Object) { EXPECT_TRUE(y.IsObject()); // AddMember() - Value name("A", 1); - Value value("Apple", 5); - x.AddMember(name, value, allocator); - //name.SetString("B"); - name.SetString("B", 1); - //value.SetString("Banana"); - value.SetString("Banana", 6); - x.AddMember(name, value, allocator); + x.AddMember("A", "Apple", allocator); + + Value value("Banana", 6); + x.AddMember("B", "Banana", allocator); // Tests a member with null character + Value name; const Value C0D("C\0D", 3); name.SetString(C0D.GetString(), 3); value.SetString("CherryD", 7); @@ -523,7 +604,7 @@ TEST(Value, Object) { EXPECT_TRUE(y.HasMember("A")); EXPECT_TRUE(y.HasMember("B")); - name.SetString("C\0D", 3); + name.SetString("C\0D"); EXPECT_TRUE(x.HasMember(name)); EXPECT_TRUE(y.HasMember(name)); @@ -617,6 +698,7 @@ TEST(Value, BigNestedObject) { char name1[10]; sprintf(name1, "%d", i); + // Value name(name1); // should not compile Value name(name1, (SizeType)strlen(name1), allocator); Value object(kObjectType); @@ -629,6 +711,7 @@ TEST(Value, BigNestedObject) { object.AddMember(name, number, allocator); } + // x.AddMember(name1, object, allocator); // should not compile x.AddMember(name, object, allocator); } From ed9cdbc2f7f78d9936e5236632608c2589e84125 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Mon, 7 Jul 2014 11:26:19 +0200 Subject: [PATCH 57/76] GenericStringRef: disallow assignment, const string pointer --- include/rapidjson/document.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 44cf532..33c97f4 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -270,10 +270,12 @@ struct GenericStringRef { //! implicit conversion to plain CharType pointer operator const Ch *() const { return s; } - const Ch* s; //!< plain CharType pointer + const Ch* const s; //!< plain CharType pointer const SizeType length; //!< length of the string (excluding the trailing NULL terminator) private: + //! Disallow copy-assignment + GenericStringRef operator=(const GenericStringRef&); //! Disallow construction from non-const array template GenericStringRef(CharType (&str)[N]) /* = delete */; From 9b3969d0e1879d4661f163dba63922a78036fa71 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Tue, 8 Jul 2014 20:41:59 +0200 Subject: [PATCH 58/76] GenericValue: fixup bool constructor With the new string handling API, the constructor taking a `bool` parameter matches in some unwanted cases, as pointers can be casted to `bool` implicitly. Add a SFINAE helper to this constructor to avoid matching arbitrary pointers. To avoid confusion for the user, this mechanism is hidden from the Doxygen documentation. --- build/Doxyfile | 1 + include/rapidjson/document.h | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/build/Doxyfile b/build/Doxyfile index 9d504b5..d2a57d5 100644 --- a/build/Doxyfile +++ b/build/Doxyfile @@ -1991,6 +1991,7 @@ INCLUDE_FILE_PATTERNS = # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = \ + RAPIDJSON_DOXYGEN_RUNNING \ RAPIDJSON_DISABLEIF_RETURN(cond,returntype)=returntype # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 33c97f4..66df387 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -355,8 +355,6 @@ public: private: //! Copy constructor is not permitted. GenericValue(const GenericValue& rhs); - //! Disabled constructor for arbitrary pointers. - template explicit GenericValue(T*); public: @@ -385,7 +383,18 @@ public: GenericValue(const GenericValue& rhs, Allocator & allocator); //! Constructor for boolean value. - explicit GenericValue(bool b) : data_(), flags_(b ? kTrueFlag : kFalseFlag) {} + /*! \param b Boolean value + \note This constructor is limited to \em real boolean values and rejects + implicitly converted types like arbitrary pointers. Use an explicit cast + to \c bool, if you want to construct a boolean JSON value in such cases. + */ +#ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen + template + explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame))) +#else + explicit GenericValue(bool b) +#endif + : data_(), flags_(b ? kTrueFlag : kFalseFlag) {} //! Constructor for int value. explicit GenericValue(int i) : data_(), flags_(kNumberIntFlag) { From a5b39958eae17ac71eec2ca4faf24e47da592108 Mon Sep 17 00:00:00 2001 From: miloyip Date: Wed, 9 Jul 2014 13:21:07 +0800 Subject: [PATCH 59/76] Adding git config in travis doxygen --- build/travis-doxygen.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/travis-doxygen.sh b/build/travis-doxygen.sh index a85d7ba..8e64269 100755 --- a/build/travis-doxygen.sh +++ b/build/travis-doxygen.sh @@ -63,6 +63,8 @@ gh_pages_prepare() cd "${TRAVIS_BUILD_DIR}/doc"; [ ! -d "html" ] || \ abort "Doxygen target directory already exists." + git config --global user.name "${GIT_NAME}" + git config --global user.email "${GIT_EMAIL}" git clone --single-branch -b gh-pages ${GHPAGES_BASE} html cd html # clean working dir From b3665606a93bcc3ab97a6b2409d2cee8be8d5d19 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 9 Jul 2014 08:01:25 +0200 Subject: [PATCH 60/76] fixup travis doxygen build --- build/travis-doxygen.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build/travis-doxygen.sh b/build/travis-doxygen.sh index 8e64269..4d1d57b 100755 --- a/build/travis-doxygen.sh +++ b/build/travis-doxygen.sh @@ -63,10 +63,11 @@ gh_pages_prepare() cd "${TRAVIS_BUILD_DIR}/doc"; [ ! -d "html" ] || \ abort "Doxygen target directory already exists." - git config --global user.name "${GIT_NAME}" - git config --global user.email "${GIT_EMAIL}" git clone --single-branch -b gh-pages ${GHPAGES_BASE} html cd html + # setup git config (with defaults) + git config user.name "${GIT_NAME-travis}" + git config user.email "${GIT_EMAIL-"travis@localhost"}" # clean working dir rm -f .git/index git clean -df @@ -75,7 +76,7 @@ gh_pages_prepare() gh_pages_commit() { cd "${TRAVIS_BUILD_DIR}/doc/html"; git add --all; - git commit -m "Automatic doxygen build"; + git diff-index --quiet HEAD || git commit -m "Automatic doxygen build"; } gh_pages_push() { From 9a89eed11a1c559a73570c1ec423eca858a4415b Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 9 Jul 2014 09:24:34 +0200 Subject: [PATCH 61/76] adopt AddMember tests from #47 (726f986,b7bf73c) --- test/unittest/valuetest.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 39500d0..fcf36a3 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -591,6 +591,27 @@ TEST(Value, Object) { Value value("Banana", 6); x.AddMember("B", "Banana", allocator); + // AddMember(StringRefType, T, Allocator) + { + Value o(kObjectType); + o.AddMember("true", true, allocator); + o.AddMember("false", false, allocator); + o.AddMember("int", -1, allocator); + o.AddMember("uint", 1u, allocator); + o.AddMember("int64", INT64_C(-4294967296), allocator); + o.AddMember("uint64", UINT64_C(4294967296), allocator); + o.AddMember("double", 3.14, allocator); + o.AddMember("string", "Jelly", allocator); + + EXPECT_TRUE(o["true"].GetBool()); + EXPECT_FALSE(o["false"].GetBool()); + EXPECT_EQ(-1, o["int"].GetInt()); + EXPECT_EQ(1u, o["uint"].GetUint()); + EXPECT_EQ(INT64_C(-4294967296), o["int64"].GetInt64()); + EXPECT_EQ(UINT64_C(4294967296), o["uint64"].GetUint64()); + EXPECT_STREQ("Jelly",o["string"].GetString()); + } + // Tests a member with null character Value name; const Value C0D("C\0D", 3); From edf8a0aa1da966d6fc37dc79428b2863ce8538ad Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 9 Jul 2014 11:25:38 +0200 Subject: [PATCH 62/76] GenericValue: add Move() --- include/rapidjson/document.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 66df387..74e5c66 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -551,6 +551,9 @@ public: return *this; } + //! Prepare Value for move semantics + /*! \return *this */ + GenericValue& Move() { return *this; } //@} //!@name Type From 58b741ac4b2c60f3e96a0bf9d76939bef207747c Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 9 Jul 2014 11:25:55 +0200 Subject: [PATCH 63/76] tutorial.md: document GenericValue::Move() --- doc/tutorial.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/tutorial.md b/doc/tutorial.md index f35c4d3..cc858f8 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -313,6 +313,17 @@ Value o(kObjectType); This is called move assignment operator in C++11. As RapidJSON supports C++03, it adopts move semantics using assignment operator, and all other modifying function like `AddMember()`, `PushBack()`. +### Move semantics and temporary values {#TemporaryValues} + +Sometimes, it is convenient to construct a Value in place, before passing it to one of the "moving" functions, like `PushBack()` or `AddMember()`. As temporary objects can't be converted to proper Value references, the convenience function `Move()` is available: + +~~~~~~~~~~cpp +Value a(kArrayType); +// a.PushBack(Value(42)); // will not compile +a.PushBack(Value().SetInt(42)); // fluent API +a.PushBack(Value(42).Move()); // same as above +~~~~~~~~~~ + ## Create String {#CreateString} RapidJSON provide two strategies for storing string. From 12c5805c7edc8119b26badd3904cac5417c5f70d Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 9 Jul 2014 11:26:22 +0200 Subject: [PATCH 64/76] tutorial.md: update for new string API --- doc/tutorial.md | 55 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index cc858f8..ee5f873 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -350,15 +350,28 @@ In this example, we get the allocator from a `Document` instance. This is a comm Besides, the above `SetString()` requires length. This can handle null characters within a string. There is another `SetString()` overloaded function without the length parameter. And it assumes the input is null-terminated and calls a `strlen()`-like function to obtain the length. -Finally, for literal string or string with safe life-cycle can use const-string version of `SetString()`, which lacks allocator parameter: +Finally, for literal string or string with safe life-cycle can use const-string version of `SetString()`, which lacks allocator parameter. For string literals (or constant character arrays), simply passing the literal as parameter is safe and efficient: ~~~~~~~~~~cpp Value s; -s.SetString("rapidjson", 9); // faster, can contain null character -s.SetString("rapidjson"); // slower, assumes null-terminated +s.SetString("rapidjson"); // can contain null character, length derived at compile time s = "rapidjson"; // shortcut, same as above ~~~~~~~~~~ +For plain string pointers, the RapidJSON requires to mark a string as safe before using it without copying. This can be achieved by using the `StringRef` function: + +~~~~~~~~~cpp +const char * cstr = getenv("USER"); +size_t cstr_len = ...; // in case length is available +Value s; +// s.SetString(cstr); // will not compile +s.SetString(StringRef(cstr)); // ok, assume safe lifetime, null-terminated +s = StringRef(cstr); // shortcut, same as above +s.SetString(StringRef(cstr,cstr_len)); // faster, can contain null character +s = StringRef(cstr,cstr_len); // shortcut, same as above + +~~~~~~~~~ + ## Modify Array {#ModifyArray} Value with array type provides similar APIs as `std::vector`. @@ -368,7 +381,7 @@ Value with array type provides similar APIs as `std::vector`. * `template GenericValue& PushBack(T, Allocator&)` * `Value& PopBack()` -Note that, `Reserve(...)` and `PushBack(...)` may allocate memory, therefore requires an allocator. +Note that, `Reserve(...)` and `PushBack(...)` may allocate memory for the array elements, therefore require an allocator. Here is an example of `PushBack()`: @@ -383,14 +396,26 @@ for (int i = 5; i <= 10; i++) a.PushBack("Lua", allocator).PushBack("Mio", allocator); ~~~~~~~~~~ -Differs from STL, `PushBack()`/`PopBack()` returns the array reference itself. This is called fluent interface. +Differs from STL, `PushBack()`/`PopBack()` returns the array reference itself. This is called _fluent interface_. + +If you want to add a non-constant string or a string without sufficient lifetime (see [Create String](#CreateString)) to the array, you need to create a string Value by using the copy-string API. To avoid the need for an intermediate variable, you can use a [temporary value](#TemporaryValues) in place: + +~~~~~~~~~~cpp +// in-place Value parameter +contact.PushBack(Value("copy", document.GetAllocator()).Move(), // copy string + document.GetAllocator()); + +// explicit parameters +Value val("key", document.GetAllocator()); // copy string +contact.PushBack(val, document.GetAllocator()); +~~~~~~~~~~ ## Modify Object {#ModifyObject} Object is a collection of key-value pairs. Each key must be a string value. The way to manipulating object is to add/remove members: * `Value& AddMember(Value&, Value&, Allocator& allocator)` -* `Value& AddMember(const Ch*, Value&, Allocator&)` -* `template Value& AddMember(const Ch*, T value, Allocator&)` +* `Value& AddMember(StringRefType, Value&, Allocator&)` +* `template Value& AddMember(StringRefType, T value, Allocator&)` * `bool RemoveMember(const Ch*)` Here is an example. @@ -401,6 +426,22 @@ contact.AddMember("name", "Milo", document.GetAllocator()); contact.AddMember("married", true, document.GetAllocator()); ~~~~~~~~~~ +The `StringRefType` used as name parameter assumes the same interface as the `SetString` function for string values. These overloads are used to avoid the need for copying the `name` string, as constant key names are very common in JSON objects. + +If you need to create a name from a non-constant string or a string without sufficient lifetime (see [Create String](#CreateString)), you need to create a string Value by using the copy-string API. To avoid the need for an intermediate variable, you can use a [temporary value](#TemporaryValues) in place: + +~~~~~~~~~~cpp +// in-place Value parameter +contact.AddMember(Value("copy", document.GetAllocator()).Move(), // copy string + Value().Move(), // null value + document.GetAllocator()); + +// explicit parameters +Value key("key", document.GetAllocator()); // copy name string +Value val(42); // some value +contact.AddMember(key, val, document.GetAllocator()); +~~~~~~~~~~ + ## Deep Copy Value {#DeepCopyValue} If we really need to copy a DOM tree, we can use two APIs for deep copy: constructor with allocator, and `CopyFrom()`. From 72d0d42a1f3085fbf9a1ec81305d7601cdccf450 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 9 Jul 2014 18:24:13 +0200 Subject: [PATCH 65/76] travis-doxygen.sh: avoid leaking the GitHub token in build log --- build/travis-doxygen.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build/travis-doxygen.sh b/build/travis-doxygen.sh index 4d1d57b..c63d783 100755 --- a/build/travis-doxygen.sh +++ b/build/travis-doxygen.sh @@ -11,9 +11,7 @@ DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/${DOXYGEN_TAR}" DOXYGEN_BIN="/usr/local/bin/doxygen" GHPAGES_REPO="miloyip/rapidjson" -GHPAGES_BASE="https://github.com/${GHPAGES_REPO}" -# NOTE: not expanded here to hide GH_TOKEN -GHPAGES_PUSH='https://${GH_TOKEN}@github.com/${GHPAGES_REPO}' +GHPAGES_URL="https://github.com/${GHPAGES_REPO}" skip() { echo "$@" 1>&2 @@ -63,7 +61,7 @@ gh_pages_prepare() cd "${TRAVIS_BUILD_DIR}/doc"; [ ! -d "html" ] || \ abort "Doxygen target directory already exists." - git clone --single-branch -b gh-pages ${GHPAGES_BASE} html + git clone --single-branch -b gh-pages ${GHPAGES_URL} html cd html # setup git config (with defaults) git config user.name "${GIT_NAME-travis}" @@ -87,9 +85,11 @@ gh_pages_push() { skip "GitHub access token not available, not updating GitHub pages." cd "${TRAVIS_BUILD_DIR}/doc/html"; - # push to GitHub without printing GH_TOKEN even in "set -x" mode - ( echo "git push ${GHPAGES_PUSH} gh-pages" ; set +x; \ - eval "git push ${GHPAGES_PUSH} gh-pages" ) + # setup credentials (hide in "set -x" mode) + git config core.askpass /bin/true + ( set +x ; git config credential.${GHPAGES_URL}.username "${GH_TOKEN}" ) + # push to GitHub + git push origin gh-pages } doxygen_install From e1431e5836acc3ff9e0944bba19f422b4fefae27 Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Thu, 10 Jul 2014 01:55:45 +0800 Subject: [PATCH 66/76] Change travis token --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2093f94..530c56d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: - config=debug64 config_suffix=debug_x64_gmake - config=release64 config_suffix=release_x64_gmake global: - secure: HAEPpA7IxUd+X4X5VcUpSxWf3hDRDNgNpKQrRSX/X/nS0/h5PAwES7fmM6WJAsoEmczCp3OOArzyOON+KLbISvJLnHvnexd+rtyVjU2zOOVTEgzJRdAPHwocqVx5FOxtlKgbDISE6dl3H5aUCycf962jfquhKosi11rbxwcscmc= + secure: "PoHpnUX6AnuS0Rj2lytxG63cgU8r8dph4z2eSlc0q401nzakOgRRdhzuIqFyAv+qfihUoWi/xwCzAI8d67qamBFR6YUCsdQ5wpFZ3kHg4ZhlIlvAxOWcCcpWwwSqlQboGbv/JAWdnBaCXzyuA6soKyY32LSgMaUP2kOcwhbZvxo=" before_install: - sudo add-apt-repository -y ppa:codegear/release From 10596ee8823fccc92bf71316ec2d0a0d0e6ead6a Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Thu, 10 Jul 2014 02:19:27 +0800 Subject: [PATCH 67/76] Fixes travis token --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 530c56d..180530f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: - config=debug64 config_suffix=debug_x64_gmake - config=release64 config_suffix=release_x64_gmake global: - secure: "PoHpnUX6AnuS0Rj2lytxG63cgU8r8dph4z2eSlc0q401nzakOgRRdhzuIqFyAv+qfihUoWi/xwCzAI8d67qamBFR6YUCsdQ5wpFZ3kHg4ZhlIlvAxOWcCcpWwwSqlQboGbv/JAWdnBaCXzyuA6soKyY32LSgMaUP2kOcwhbZvxo=" + secure: "CR3yKliFhwQLX+Zs1PCRcGej6jr4DIZsCqs9x6J2NN+U9Aow0gd/uiPBho/utgm+/TmSBji5n8FO/J3ORo34q4gC6EebTEaN4gCHNXVlIBJFw9x+Gs/lML5i8F2AoweFJY334OVaOf9qC8ZVJ8Z1nEwxj77fq3gcSLzRU3pIaS8=" before_install: - sudo add-apt-repository -y ppa:codegear/release From 63d054349ab56d278060cd3373e76a6933cf194a Mon Sep 17 00:00:00 2001 From: Milo Yip Date: Thu, 10 Jul 2014 02:25:11 +0800 Subject: [PATCH 68/76] Fixes whitespaces in travis script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 180530f..2ae9443 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: - config=debug64 config_suffix=debug_x64_gmake - config=release64 config_suffix=release_x64_gmake global: - secure: "CR3yKliFhwQLX+Zs1PCRcGej6jr4DIZsCqs9x6J2NN+U9Aow0gd/uiPBho/utgm+/TmSBji5n8FO/J3ORo34q4gC6EebTEaN4gCHNXVlIBJFw9x+Gs/lML5i8F2AoweFJY334OVaOf9qC8ZVJ8Z1nEwxj77fq3gcSLzRU3pIaS8=" + secure: "CR3yKliFhwQLX+Zs1PCRcGej6jr4DIZsCqs9x6J2NN+U9Aow0gd/uiPBho/utgm+/TmSBji5n8FO/J3ORo34q4gC6EebTEaN4gCHNXVlIBJFw9x+Gs/lML5i8F2AoweFJY334OVaOf9qC8ZVJ8Z1nEwxj77fq3gcSLzRU3pIaS8=" before_install: - sudo add-apt-repository -y ppa:codegear/release From e63125f1a1c03abbaabb489a00d88fc9224fb095 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 13:09:15 +0200 Subject: [PATCH 69/76] MSVC: fix SSE/intrinsic support MSVC with enabled RAPIDJSON_SSE2/RAPIDJSON_SSE42 requires the explicit definition of the `_BitScanForward` intrinsic. This can be reliably ensured by including "intrin.h" and properly marking '_BitScanForward' as intrinsic. Confirmed on MSVC 2005, 2008. Should fix https://code.google.com/p/rapidjson/issues/detail?id=96 --- include/rapidjson/reader.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/rapidjson/reader.h b/include/rapidjson/reader.h index 59d03b6..bd141a1 100644 --- a/include/rapidjson/reader.h +++ b/include/rapidjson/reader.h @@ -9,6 +9,10 @@ #include "internal/pow10.h" #include "internal/stack.h" +#if defined(RAPIDJSON_SIMD) && defined(_MSC_VER) +#include +#pragma intrinsic(_BitScanForward) +#endif #ifdef RAPIDJSON_SSE42 #include #elif defined(RAPIDJSON_SSE2) @@ -16,8 +20,8 @@ #endif #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4127) // conditional expression is constant +RAPIDJSON_DIAG_PUSH +RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant #endif #ifndef RAPIDJSON_PARSE_ERROR_NORETURN @@ -769,7 +773,7 @@ typedef GenericReader, UTF8<> > Reader; } // namespace rapidjson #ifdef _MSC_VER -#pragma warning(pop) +RAPIDJSON_DIAG_POP #endif #endif // RAPIDJSON_READER_H_ From 04f9c5020f29592d6a9e45baf1c74071c6ab3b8a Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 18:12:46 +0200 Subject: [PATCH 70/76] encodings.h: hide narrowing conversion warnings on MSVC --- include/rapidjson/encodings.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/encodings.h b/include/rapidjson/encodings.h index 9e1623d..dcf21e4 100644 --- a/include/rapidjson/encodings.h +++ b/include/rapidjson/encodings.h @@ -3,7 +3,10 @@ #include "rapidjson.h" -#ifdef __GNUC__ +#ifdef _MSC_VER +RAPIDJSON_DIAG_PUSH +RAPIDJSON_DIAG_OFF(4244) // conversion from 'type1' to 'type2', possible loss of data +#elif defined(__GNUC__) RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(effc++) #endif @@ -529,7 +532,7 @@ struct Transcoder { } // namespace rapidjson -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(_MSV_VER) RAPIDJSON_DIAG_POP #endif From bde95eca04c7b683146460ffaca0e757dabca115 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 16:49:20 +0200 Subject: [PATCH 71/76] Writer::WriteUint: add cast to hide warning C4244 on MSVC --- include/rapidjson/writer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h index 979b781..4fd0427 100644 --- a/include/rapidjson/writer.h +++ b/include/rapidjson/writer.h @@ -185,7 +185,7 @@ protected: char buffer[10]; char *p = buffer; do { - *p++ = (u % 10) + '0'; + *p++ = char(u % 10) + '0'; u /= 10; } while (u > 0); From 3cdfb0dafe02f9edf041555f1ce2c428e7dfe1c5 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 19:38:57 +0200 Subject: [PATCH 72/76] rapidjsontest.cpp: silence a warning (C4244) on MSVC --- test/perftest/rapidjsontest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/perftest/rapidjsontest.cpp b/test/perftest/rapidjsontest.cpp index dd8bc30..7c58077 100644 --- a/test/perftest/rapidjsontest.cpp +++ b/test/perftest/rapidjsontest.cpp @@ -242,7 +242,7 @@ TEST_F(RapidJson, PrettyWriter_StringBuffer) { TEST_F(RapidJson, internal_Pow10) { double sum = 0; for (size_t i = 0; i < kTrialCount * kTrialCount; i++) - sum += internal::Pow10(i & 255); + sum += internal::Pow10(int(i & 255)); EXPECT_GT(sum, 0.0); } From 4f40ed64b6940b4d003d09f5fe0408a1ce641555 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 19:41:08 +0200 Subject: [PATCH 73/76] MSVC: fix compiler error in GenericDocument The `StringRefType` assignment operator overload leads to a compiler error on MSVC 2005 and later: ..\..\include\rapidjson/document.h(504) : error C2951: template declarations are only permitted at global, namespace, or class scope Drop the unneeded 'template' keyword here. --- include/rapidjson/document.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 74e5c66..8406598 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -501,7 +501,7 @@ public: \see GenericStringRef, operator=(T) */ GenericValue& operator=(StringRefType str) { - return (*this).template operator=(str); + return (*this).operator=(str); } //! Assignment with primitive types. From 7a2e6e79c64d322875f6ad565fc60024c9f40752 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 16:46:42 +0200 Subject: [PATCH 74/76] StrLen: align implementations There are two copies of `StrLen` in the RapidJSON code base * strfunc.h: rapidjson::internal::StrLen * unittest.h: Strlen To hide a warning on MSVC, align both implementations to use 'unsigned/SizeType' as return type and add an explicit cast. --- include/rapidjson/internal/strfunc.h | 3 +-- test/unittest/unittest.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/rapidjson/internal/strfunc.h b/include/rapidjson/internal/strfunc.h index 47b8ac0..0a20c56 100644 --- a/include/rapidjson/internal/strfunc.h +++ b/include/rapidjson/internal/strfunc.h @@ -13,8 +13,7 @@ namespace internal { template inline SizeType StrLen(const Ch* s) { const Ch* p = s; - while (*p != '\0') - ++p; + while (*p) ++p; return SizeType(p - s); } diff --git a/test/unittest/unittest.h b/test/unittest/unittest.h index 75d2bc4..0234319 100644 --- a/test/unittest/unittest.h +++ b/test/unittest/unittest.h @@ -27,10 +27,10 @@ #endif template -inline size_t StrLen(const Ch* s) { +inline unsigned StrLen(const Ch* s) { const Ch* p = s; while (*p) p++; - return p - s; + return unsigned(p - s); } template From ca36a2e66eb87a6caed5889f6adbc72e5568f820 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 19:49:52 +0200 Subject: [PATCH 75/76] writer.h: use warning macros for MSVC --- include/rapidjson/writer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h index 4fd0427..9652000 100644 --- a/include/rapidjson/writer.h +++ b/include/rapidjson/writer.h @@ -8,8 +8,8 @@ #include // placement new #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4127) // conditional expression is constant +RAPIDJSON_DIAG_PUSH +RAPIDJSON_DIAG_OFF(4127) // conditional expression is constant #endif namespace rapidjson { @@ -306,7 +306,7 @@ private: } // namespace rapidjson #ifdef _MSC_VER -#pragma warning(pop) +RAPIDJSON_DIAG_POP #endif #endif // RAPIDJSON_RAPIDJSON_H_ From 6d5583628a537a7ce96cf5037c6872dc6bcf8dd0 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 20:48:54 +0200 Subject: [PATCH 76/76] premake4.lua: only enable "-Wswitch-default" in unittest There's no need to enforce this flag during the build of the perftest or the GoogleTest library, as both include third-party code. --- build/premake4.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/premake4.lua b/build/premake4.lua index 1ef7ff5..0b5dbb1 100644 --- a/build/premake4.lua +++ b/build/premake4.lua @@ -64,7 +64,7 @@ solution "test" defines { "_CRT_SECURE_NO_WARNINGS" } configuration "gmake" - buildoptions "-msse4.2 -Werror -Wall -Wextra -Wswitch-default" + buildoptions "-msse4.2 -Werror -Wall -Wextra" project "gtest" kind "StaticLib" @@ -87,7 +87,7 @@ solution "test" kind "ConsoleApp" if _ACTION == "gmake" then - buildoptions "-Weffc++" + buildoptions "-Weffc++ -Wswitch-default" end files {