All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rapidjson Namespace Reference

main RapidJSON namespace More...

Classes

class  CrtAllocator
 C-runtime library allocator. More...
 
class  MemoryPoolAllocator
 Default memory allocator used by the parser and DOM. More...
 
class  GenericValue
 Represents a JSON value. Use Value for UTF8 encoding and default allocator. More...
 
struct  GenericMember
 Name-value pair in a JSON object value. More...
 
class  GenericMemberIterator
 (Constant) member iterator for a JSON object value More...
 
struct  GenericStringRef
 Reference to a constant string (not taking a copy) More...
 
class  GenericDocument
 A document for parsing JSON text as DOM. More...
 
class  EncodedInputStream
 Input byte stream wrapper with a statically bound encoding. More...
 
class  EncodedOutputStream
 Output byte stream wrapper with statically bound encoding. More...
 
class  AutoUTFInputStream
 Input stream wrapper with dynamically bound encoding and automatic encoding detection. More...
 
class  AutoUTFOutputStream
 Output stream wrapper with dynamically bound encoding and automatic encoding detection. More...
 
struct  UTF8
 UTF-8 encoding. More...
 
struct  UTF16
 UTF-16 encoding. More...
 
struct  UTF16LE
 UTF-16 little endian encoding. More...
 
struct  UTF16BE
 UTF-16 big endian encoding. More...
 
struct  UTF32
 UTF-32 encoding. More...
 
struct  UTF32LE
 UTF-32 little endian enocoding. More...
 
struct  UTF32BE
 UTF-32 big endian encoding. More...
 
struct  ASCII
 ASCII encoding. More...
 
struct  AutoUTF
 Dynamically select encoding according to stream's runtime-specified UTF encoding type. More...
 
struct  Transcoder
 Encoding conversion. More...
 
struct  Transcoder< Encoding, Encoding >
 Specialization of Transcoder with same source and target encoding. More...
 
struct  ParseResult
 Result of parsing (wraps ParseErrorCode) More...
 
class  FileReadStream
 File byte stream for input using fread(). More...
 
class  FileStream
 (Depreciated) Wrapper of C file stream for input or output. More...
 
class  FileWriteStream
 Wrapper of C file stream for input using fread(). More...
 
class  GenericReadStream
 Wrapper of std::istream for input. More...
 
class  GenericWriteStream
 Wrapper of std::ostream for output. More...
 
struct  GenericMemoryBuffer
 Represents an in-memory output byte stream. More...
 
struct  MemoryStream
 Represents an in-memory input byte stream. More...
 
class  PrettyWriter
 Writer with indentation and spacing. More...
 
struct  StreamTraits
 Provides additional information for stream. More...
 
struct  GenericStringStream
 Read-only string stream. More...
 
struct  StreamTraits< GenericStringStream< Encoding > >
 
struct  GenericInsituStringStream
 A read-write string stream. More...
 
struct  StreamTraits< GenericInsituStringStream< Encoding > >
 
struct  BaseReaderHandler
 Default implementation of Handler. More...
 
class  GenericReader
 SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator. More...
 
struct  GenericStringBuffer
 Represents an in-memory output stream. More...
 
class  Writer
 JSON writer. More...
 
class  Allocator
 Concept for allocating, resizing and freeing memory block. More...
 
class  Encoding
 Concept for encoding of Unicode characters. More...
 
class  Stream
 Concept for reading and writing characters. More...
 
class  Handler
 Concept for receiving events from GenericReader upon parsing. The functions return true if no error occurs. If they return false, the event publisher should terminate the process. More...
 

Typedefs

typedef GenericValue< UTF8<> > Value
 GenericValue with UTF8 encoding.
 
typedef GenericDocument< UTF8<> > Document
 GenericDocument with UTF8 encoding.
 
typedef const
RAPIDJSON_ERROR_CHARTYPE *(* 
GetParseErrorFunc )(ParseErrorCode)
 Function pointer type of GetParseError(). More...
 
typedef GenericMemoryBuffer MemoryBuffer
 
typedef unsigned SizeType
 Use 32-bit array/string indices even for 64-bit platform, instead of using size_t. More...
 
typedef GenericStringStream
< UTF8<> > 
StringStream
 String stream with UTF8 encoding.
 
typedef
GenericInsituStringStream
< UTF8<> > 
InsituStringStream
 Insitu string stream with UTF8 encoding.
 
typedef GenericReader< UTF8
<>, UTF8<> > 
Reader
 Reader with UTF8 encoding and default allocator.
 
typedef GenericStringBuffer
< UTF8<> > 
StringBuffer
 String buffer with UTF8 encoding.
 

Enumerations

enum  UTFType {
  kUTF8 = 0, kUTF16LE = 1, kUTF16BE = 2, kUTF32LE = 3,
  kUTF32BE = 4
}
 Runtime-specified UTF encoding type of a stream. More...
 
enum  ParseErrorCode {
  kParseErrorNone = 0, kParseErrorDocumentEmpty, kParseErrorDocumentRootNotObjectOrArray, kParseErrorDocumentRootNotSingular,
  kParseErrorValueInvalid, kParseErrorObjectMissName, kParseErrorObjectMissColon, kParseErrorObjectMissCommaOrCurlyBracket,
  kParseErrorArrayMissCommaOrSquareBracket, kParseErrorStringUnicodeEscapeInvalidHex, kParseErrorStringUnicodeSurrogateInvalid, kParseErrorStringEscapeInvalid,
  kParseErrorStringMissQuotationMark, kParseErrorStringInvalidEncoding, kParseErrorNumberTooBig, kParseErrorNumberMissFraction,
  kParseErrorNumberMissExponent, kParseErrorTermination, kParseErrorUnspecificSyntaxError
}
 Error code of parsing. More...
 
enum  Type {
  kNullType = 0, kFalseType = 1, kTrueType = 2, kObjectType = 3,
  kArrayType = 4, kStringType = 5, kNumberType = 6
}
 Type of JSON value. More...
 
enum  ParseFlag {
  kParseDefaultFlags = 0, kParseInsituFlag = 1, kParseValidateEncodingFlag = 2, kParseIterativeFlag = 4,
  kParseStopWhenDoneFlag = 8
}
 Combination of parseFlags. More...
 

Functions

template<typename CharType >
GenericStringRef< CharType > StringRef (const CharType *str)
 Mark a character pointer as constant string. More...
 
template<typename CharType >
GenericStringRef< CharType > StringRef (const CharType *str, size_t length)
 Mark a character pointer as constant string. More...
 
const RAPIDJSON_ERROR_CHARTYPE * GetParseError_En (ParseErrorCode parseErrorCode)
 Maps error code of parsing into error message. More...
 
template<>
void PutN (FileWriteStream &stream, char c, size_t n)
 Implement specialized version of PutN() with memset() for better performance.
 
template<>
void PutN (GenericWriteStream &stream, char c, size_t n)
 
template<>
void PutN (MemoryBuffer &memoryBuffer, char c, size_t n)
 Implement specialized version of PutN() with memset() for better performance.
 
template<typename Stream , typename Ch >
void PutN (Stream &stream, Ch c, size_t n)
 Put N copies of a character to a stream.
 
template<typename InputStream >
void SkipWhitespace (InputStream &is)
 Skip the JSON white spaces in a stream. More...
 
template<>
void PutN (GenericStringBuffer< UTF8<> > &stream, char c, size_t n)
 Implement specialized version of PutN() with memset() for better performance.
 

Detailed Description

main RapidJSON namespace

Typedef Documentation

typedef const RAPIDJSON_ERROR_CHARTYPE*(* rapidjson::GetParseErrorFunc)(ParseErrorCode)

Function pointer type of GetParseError().

This is the prototype for GetParseError_X(), where X is a locale. User can dynamically change locale in runtime, e.g.:

GetParseErrorFunc GetParseError = GetParseError_En; // or whatever
const RAPIDJSON_ERROR_CHARTYPE* s = GetParseError(document.GetParseErrorCode());
typedef unsigned rapidjson::SizeType

Use 32-bit array/string indices even for 64-bit platform, instead of using size_t.

User may override the SizeType by defining RAPIDJSON_NO_SIZETYPEDEFINE.

Enumeration Type Documentation

Error code of parsing.

See Also
GenericReader::Parse, GenericReader::GetParseErrorCode
Enumerator
kParseErrorNone 

No error.

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.

kParseErrorValueInvalid 

Invalid value.

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.

kParseErrorArrayMissCommaOrSquareBracket 

Missing a comma or ']' after an array element.

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.

kParseErrorNumberTooBig 

Number too big to be stored in double.

kParseErrorNumberMissFraction 

Miss fraction part in number.

kParseErrorNumberMissExponent 

Miss exponent in number.

kParseErrorTermination 

Parsing was terminated.

kParseErrorUnspecificSyntaxError 

Unspecific syntax error.

Combination of parseFlags.

See Also
Reader::Parse, Document::Parse, Document::ParseInsitu, Document::ParseStream
Enumerator
kParseDefaultFlags 

Default parse flags. Non-destructive parsing. Text strings are decoded into allocated buffer.

kParseInsituFlag 

In-situ(destructive) parsing.

kParseValidateEncodingFlag 

Validate encoding of JSON strings.

kParseIterativeFlag 

Iterative(constant complexity in terms of function call stack size) parsing.

kParseStopWhenDoneFlag 

After parsing a complete JSON root from stream, stop further processing the rest of stream. When this flag is used, parser will not generate kParseErrorDocumentRootNotSingular error.

Type of JSON value.

Enumerator
kNullType 

null

kFalseType 

false

kTrueType 

true

kObjectType 

object

kArrayType 

array

kStringType 

string

kNumberType 

number

Runtime-specified UTF encoding type of a stream.

Enumerator
kUTF8 

UTF-8.

kUTF16LE 

UTF-16 little endian.

kUTF16BE 

UTF-16 big endian.

kUTF32LE 

UTF-32 little endian.

kUTF32BE 

UTF-32 big endian.

Function Documentation

const RAPIDJSON_ERROR_CHARTYPE* rapidjson::GetParseError_En ( ParseErrorCode  parseErrorCode)
inline

Maps error code of parsing into error message.

Parameters
parseErrorCodeError code obtained in parsing.
Returns
the error message.
Note
User can make a copy of this function for localization. Using switch-case is safer for future modification of error codes.
template<typename InputStream >
void rapidjson::SkipWhitespace ( InputStream &  is)

Skip the JSON white spaces in a stream.

Parameters
isA input stream for skipping white spaces.
Note
This function has SSE2/SSE4.2 specialization.
template<typename CharType >
GenericStringRef< CharType > StringRef ( const CharType *  str)
inline

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.

Template Parameters
CharTypeCharacter type of the string
Parameters
strConstant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue
Returns
GenericStringRef string reference object
See Also
GenericValue::GenericValue(StringRefType), GenericValue::operator=(StringRefType), GenericValue::SetString(StringRefType), GenericValue::PushBack(StringRefType, Allocator&), GenericValue::AddMember
template<typename CharType >
GenericStringRef< CharType > StringRef ( const CharType *  str,
size_t  length 
)
inline

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.

Template Parameters
CharTypecharacter type of the string
Parameters
strConstant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue
lengthThe length of source string.
Returns
GenericStringRef string reference object