Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GenericReader< SourceEncoding, TargetEncoding, StackAllocator > Class Template Reference

SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator. More...

#include <fwd.h>

Classes

struct  ClearStackOnExit
 
class  NumberStream
 
class  NumberStream< InputStream, false, false >
 
class  NumberStream< InputStream, true, false >
 
class  NumberStream< InputStream, true, true >
 
class  StackStream
 

Public Types

typedef SourceEncoding::Ch Ch
 SourceEncoding character type. More...
 

Public Member Functions

 GenericReader (StackAllocator *stackAllocator=0, size_t stackCapacity=kDefaultStackCapacity)
 Constructor. More...
 
template<unsigned parseFlags, typename InputStream , typename Handler >
ParseResult Parse (InputStream &is, Handler &handler)
 Parse JSON text. More...
 
template<typename InputStream , typename Handler >
ParseResult Parse (InputStream &is, Handler &handler)
 Parse JSON text (with kParseDefaultFlags) More...
 
void IterativeParseInit ()
 Initialize JSON text token-by-token parsing. More...
 
template<unsigned parseFlags, typename InputStream , typename Handler >
bool IterativeParseNext (InputStream &is, Handler &handler)
 Parse one token from JSON text. More...
 
RAPIDJSON_FORCEINLINE bool IterativeParseComplete () const
 Check if token-by-token parsing JSON text is complete. More...
 
bool HasParseError () const
 Whether a parse error has occurred in the last parsing. More...
 
ParseErrorCode GetParseErrorCode () const
 Get the ParseErrorCode of last parsing. More...
 
size_t GetErrorOffset () const
 Get the position of last parsing error in input, 0 otherwise. More...
 

Protected Member Functions

void SetParseError (ParseErrorCode code, size_t offset)
 

Private Types

enum  IterativeParsingState {
  IterativeParsingFinishState = 0, IterativeParsingErrorState, IterativeParsingStartState, IterativeParsingObjectInitialState,
  IterativeParsingMemberKeyState, IterativeParsingMemberValueState, IterativeParsingObjectFinishState, IterativeParsingArrayInitialState,
  IterativeParsingElementState, IterativeParsingArrayFinishState, IterativeParsingValueState, IterativeParsingElementDelimiterState,
  IterativeParsingMemberDelimiterState, IterativeParsingKeyValueDelimiterState, cIterativeParsingStateCount
}
 
enum  Token {
  LeftBracketToken = 0, RightBracketToken, LeftCurlyBracketToken, RightCurlyBracketToken,
  CommaToken, ColonToken, StringToken, FalseToken,
  TrueToken, NullToken, NumberToken, kTokenCount
}
 

Private Member Functions

 GenericReader (const GenericReader &)
 
GenericReaderoperator= (const GenericReader &)
 
void ClearStack ()
 
template<unsigned parseFlags, typename InputStream >
void SkipWhitespaceAndComments (InputStream &is)
 
template<unsigned parseFlags, typename InputStream , typename Handler >
void ParseObject (InputStream &is, Handler &handler)
 
template<unsigned parseFlags, typename InputStream , typename Handler >
void ParseArray (InputStream &is, Handler &handler)
 
template<unsigned parseFlags, typename InputStream , typename Handler >
void ParseNull (InputStream &is, Handler &handler)
 
template<unsigned parseFlags, typename InputStream , typename Handler >
void ParseTrue (InputStream &is, Handler &handler)
 
template<unsigned parseFlags, typename InputStream , typename Handler >
void ParseFalse (InputStream &is, Handler &handler)
 
template<typename InputStream >
unsigned ParseHex4 (InputStream &is, size_t escapeOffset)
 
template<unsigned parseFlags, typename InputStream , typename Handler >
void ParseString (InputStream &is, Handler &handler, bool isKey=false)
 
template<unsigned parseFlags, typename SEncoding , typename TEncoding , typename InputStream , typename OutputStream >
RAPIDJSON_FORCEINLINE void ParseStringToStream (InputStream &is, OutputStream &os)
 
template<unsigned parseFlags, typename InputStream , typename Handler >
void ParseNumber (InputStream &is, Handler &handler)
 
template<unsigned parseFlags, typename InputStream , typename Handler >
void ParseValue (InputStream &is, Handler &handler)
 
RAPIDJSON_FORCEINLINE Token Tokenize (Ch c) const
 
RAPIDJSON_FORCEINLINE IterativeParsingState Predict (IterativeParsingState state, Token token) const
 
template<unsigned parseFlags, typename InputStream , typename Handler >
RAPIDJSON_FORCEINLINE IterativeParsingState Transit (IterativeParsingState src, Token token, IterativeParsingState dst, InputStream &is, Handler &handler)
 
template<typename InputStream >
void HandleError (IterativeParsingState src, InputStream &is)
 
RAPIDJSON_FORCEINLINE bool IsIterativeParsingDelimiterState (IterativeParsingState s) const
 
RAPIDJSON_FORCEINLINE bool IsIterativeParsingCompleteState (IterativeParsingState s) const
 
template<unsigned parseFlags, typename InputStream , typename Handler >
ParseResult IterativeParse (InputStream &is, Handler &handler)
 

Static Private Member Functions

template<typename InputStream >
static RAPIDJSON_FORCEINLINE bool Consume (InputStream &is, typename InputStream::Ch expect)
 
template<typename InputStream , typename OutputStream >
static RAPIDJSON_FORCEINLINE void ScanCopyUnescapedString (InputStream &, OutputStream &)
 

Private Attributes

internal::Stack< StackAllocator > stack_
 A stack for storing decoded string temporarily during non-destructive parsing. More...
 
ParseResult parseResult_
 
IterativeParsingState state_
 

Static Private Attributes

static const size_t kDefaultStackCapacity = 256
 Default stack capacity in bytes for storing a single decoded string. More...
 

Detailed Description

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
class GenericReader< SourceEncoding, TargetEncoding, StackAllocator >

SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.

GenericReader parses JSON text from a stream, and send events synchronously to an object implementing Handler concept.

It needs to allocate a stack for storing a single decoded string during non-destructive parsing.

For in-situ parsing, the decoded string is directly written to the source text string, no temporary buffer is required.

A GenericReader object can be reused for parsing multiple JSON text.

Template Parameters
SourceEncodingEncoding of the input stream.
TargetEncodingEncoding of the parse output.
StackAllocatorAllocator type for stack.

Definition at line 88 of file fwd.h.

Member Typedef Documentation

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
typedef SourceEncoding::Ch GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Ch

SourceEncoding character type.

Definition at line 539 of file reader.h.

Member Enumeration Documentation

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
enum GenericReader::IterativeParsingState
private
Enumerator
IterativeParsingFinishState 
IterativeParsingErrorState 
IterativeParsingStartState 
IterativeParsingObjectInitialState 
IterativeParsingMemberKeyState 
IterativeParsingMemberValueState 
IterativeParsingObjectFinishState 
IterativeParsingArrayInitialState 
IterativeParsingElementState 
IterativeParsingArrayFinishState 
IterativeParsingValueState 
IterativeParsingElementDelimiterState 
IterativeParsingMemberDelimiterState 
IterativeParsingKeyValueDelimiterState 
cIterativeParsingStateCount 

Definition at line 1754 of file reader.h.

1754  {
1755  IterativeParsingFinishState = 0, // sink states at top
1756  IterativeParsingErrorState, // sink states at top
1758 
1759  // Object states
1764 
1765  // Array states
1769 
1770  // Single value state
1772 
1773  // Delimiter states (at bottom)
1777 
1779  };
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
enum GenericReader::Token
private
Enumerator
LeftBracketToken 
RightBracketToken 
LeftCurlyBracketToken 
RightCurlyBracketToken 
CommaToken 
ColonToken 
StringToken 
FalseToken 
TrueToken 
NullToken 
NumberToken 
kTokenCount 

Definition at line 1782 of file reader.h.

Constructor & Destructor Documentation

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::GenericReader ( StackAllocator *  stackAllocator = 0,
size_t  stackCapacity = kDefaultStackCapacity 
)
inline

Constructor.

Parameters
stackAllocatorOptional allocator for allocating stack memory. (Only use for non-destructive parsing)
stackCapacitystack capacity in bytes for storing a single decoded string. (Only use for non-destructive parsing)

Definition at line 545 of file reader.h.

545  :
546  stack_(stackAllocator, stackCapacity), parseResult_(), state_(IterativeParsingStartState) {}
ParseResult parseResult_
Definition: reader.h:2212
IterativeParsingState state_
Definition: reader.h:2213
internal::Stack< StackAllocator > stack_
A stack for storing decoded string temporarily during non-destructive parsing.
Definition: reader.h:2211
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::GenericReader ( const GenericReader< SourceEncoding, TargetEncoding, StackAllocator > &  )
private

Member Function Documentation

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ClearStack ( )
inlineprivate

Definition at line 696 of file reader.h.

696 { stack_.Clear(); }
void Clear()
Definition: stack.h:98
internal::Stack< StackAllocator > stack_
A stack for storing decoded string temporarily during non-destructive parsing.
Definition: reader.h:2211
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<typename InputStream >
static RAPIDJSON_FORCEINLINE bool GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Consume ( InputStream &  is,
typename InputStream::Ch  expect 
)
inlinestaticprivate

Definition at line 893 of file reader.h.

893  {
894  if (RAPIDJSON_LIKELY(is.Peek() == expect)) {
895  is.Take();
896  return true;
897  }
898  else
899  return false;
900  }
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
size_t GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::GetErrorOffset ( ) const
inline

Get the position of last parsing error in input, 0 otherwise.

Definition at line 686 of file reader.h.

686 { return parseResult_.Offset(); }
size_t Offset() const
Get the error offset, if IsError(), 0 otherwise.
Definition: error.h:118
ParseResult parseResult_
Definition: reader.h:2212
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
ParseErrorCode GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::GetParseErrorCode ( ) const
inline

Get the ParseErrorCode of last parsing.

Definition at line 683 of file reader.h.

683 { return parseResult_.Code(); }
ParseResult parseResult_
Definition: reader.h:2212
ParseErrorCode Code() const
Get the error code.
Definition: error.h:116
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<typename InputStream >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::HandleError ( IterativeParsingState  src,
InputStream &  is 
)
inlineprivate

Definition at line 2147 of file reader.h.

2147  {
2148  if (HasParseError()) {
2149  // Error flag has been set.
2150  return;
2151  }
2152 
2153  switch (src) {
2164  }
2165  }
Invalid value.
Definition: error.h:70
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Missing a comma or &#39;}&#39; after an object member.
Definition: error.h:74
The document is empty.
Definition: error.h:67
Missing a comma or &#39;]&#39; after an array element.
Definition: error.h:76
Missing a name for object member.
Definition: error.h:72
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
Definition: reader.h:680
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
Missing a colon after a name of object member.
Definition: error.h:73
The document root must not follow by other values.
Definition: error.h:68
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
bool GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::HasParseError ( ) const
inline

Whether a parse error has occurred in the last parsing.

Definition at line 680 of file reader.h.

680 { return parseResult_.IsError(); }
ParseResult parseResult_
Definition: reader.h:2212
bool IsError() const
Whether the result is an error.
Definition: error.h:123
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
RAPIDJSON_FORCEINLINE bool GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IsIterativeParsingCompleteState ( IterativeParsingState  s) const
inlineprivate

Definition at line 2171 of file reader.h.

2171  {
2172  return s <= IterativeParsingErrorState;
2173  }
static QCString * s
Definition: config.cpp:1042
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
RAPIDJSON_FORCEINLINE bool GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IsIterativeParsingDelimiterState ( IterativeParsingState  s) const
inlineprivate

Definition at line 2167 of file reader.h.

2167  {
2169  }
static QCString * s
Definition: config.cpp:1042
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
ParseResult GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IterativeParse ( InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 2176 of file reader.h.

2176  {
2177  parseResult_.Clear();
2178  ClearStackOnExit scope(*this);
2180 
2181  SkipWhitespaceAndComments<parseFlags>(is);
2182  RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
2183  while (is.Peek() != '\0') {
2184  Token t = Tokenize(is.Peek());
2185  IterativeParsingState n = Predict(state, t);
2186  IterativeParsingState d = Transit<parseFlags>(state, t, n, is, handler);
2187 
2188  if (d == IterativeParsingErrorState) {
2189  HandleError(state, is);
2190  break;
2191  }
2192 
2193  state = d;
2194 
2195  // Do not further consume streams if a root JSON has been parsed.
2196  if ((parseFlags & kParseStopWhenDoneFlag) && state == IterativeParsingFinishState)
2197  break;
2198 
2199  SkipWhitespaceAndComments<parseFlags>(is);
2200  RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
2201  }
2202 
2203  // Handle the end of file.
2204  if (state != IterativeParsingFinishState)
2205  HandleError(state, is);
2206 
2207  return parseResult_;
2208  }
void HandleError(IterativeParsingState src, InputStream &is)
Definition: reader.h:2147
static QCString scope
Definition: declinfo.cpp:668
ParseResult parseResult_
Definition: reader.h:2212
After parsing a complete JSON root from stream, stop further processing the rest of stream...
Definition: reader.h:150
std::void_t< T > n
IterativeParsingState
Definition: reader.h:1754
void Clear()
Reset error code.
Definition: error.h:134
static msg_handler handler
Definition: qglobal.cpp:234
RAPIDJSON_FORCEINLINE Token Tokenize(Ch c) const
Definition: reader.h:1801
RAPIDJSON_FORCEINLINE IterativeParsingState Predict(IterativeParsingState state, Token token) const
Definition: reader.h:1828
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
RAPIDJSON_FORCEINLINE bool GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IterativeParseComplete ( ) const
inline

Check if token-by-token parsing JSON text is complete.

Returns
Whether the JSON has been fully decoded.

Definition at line 675 of file reader.h.

675  {
677  }
IterativeParsingState state_
Definition: reader.h:2213
RAPIDJSON_FORCEINLINE bool IsIterativeParsingCompleteState(IterativeParsingState s) const
Definition: reader.h:2171
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IterativeParseInit ( )
inline

Initialize JSON text token-by-token parsing.

Definition at line 605 of file reader.h.

605  {
608  }
ParseResult parseResult_
Definition: reader.h:2212
IterativeParsingState state_
Definition: reader.h:2213
void Clear()
Reset error code.
Definition: error.h:134
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
bool GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IterativeParseNext ( InputStream &  is,
Handler &  handler 
)
inline

Parse one token from JSON text.

Template Parameters
InputStreamType of input stream, implementing Stream concept
HandlerType of handler, implementing Handler concept.
Parameters
isInput stream to be parsed.
handlerThe handler to receive events.
Returns
Whether the parsing is successful.

Definition at line 618 of file reader.h.

618  {
619  while (RAPIDJSON_LIKELY(is.Peek() != '\0')) {
620  SkipWhitespaceAndComments<parseFlags>(is);
621 
622  Token t = Tokenize(is.Peek());
624  IterativeParsingState d = Transit<parseFlags>(state_, t, n, is, handler);
625 
626  // If we've finished or hit an error...
628  // Report errors.
629  if (d == IterativeParsingErrorState) {
630  HandleError(state_, is);
631  return false;
632  }
633 
634  // Transition to the finish state.
636  state_ = d;
637 
638  // If StopWhenDone is not set...
639  if (!(parseFlags & kParseStopWhenDoneFlag)) {
640  // ... and extra non-whitespace data is found...
641  SkipWhitespaceAndComments<parseFlags>(is);
642  if (is.Peek() != '\0') {
643  // ... this is considered an error.
644  HandleError(state_, is);
645  return false;
646  }
647  }
648 
649  // Success! We are done!
650  return true;
651  }
652 
653  // Transition to the new state.
654  state_ = d;
655 
656  // If we parsed anything other than a delimiter, we invoked the handler, so we can return true now.
658  return true;
659  }
660 
661  // We reached the end of file.
662  stack_.Clear();
663 
664  if (state_ != IterativeParsingFinishState) {
665  HandleError(state_, is);
666  return false;
667  }
668 
669  return true;
670  }
void HandleError(IterativeParsingState src, InputStream &is)
Definition: reader.h:2147
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
RAPIDJSON_FORCEINLINE bool IsIterativeParsingDelimiterState(IterativeParsingState s) const
Definition: reader.h:2167
void Clear()
Definition: stack.h:98
After parsing a complete JSON root from stream, stop further processing the rest of stream...
Definition: reader.h:150
std::void_t< T > n
IterativeParsingState
Definition: reader.h:1754
IterativeParsingState state_
Definition: reader.h:2213
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
RAPIDJSON_FORCEINLINE bool IsIterativeParsingCompleteState(IterativeParsingState s) const
Definition: reader.h:2171
internal::Stack< StackAllocator > stack_
A stack for storing decoded string temporarily during non-destructive parsing.
Definition: reader.h:2211
static msg_handler handler
Definition: qglobal.cpp:234
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
RAPIDJSON_FORCEINLINE Token Tokenize(Ch c) const
Definition: reader.h:1801
RAPIDJSON_FORCEINLINE IterativeParsingState Predict(IterativeParsingState state, Token token) const
Definition: reader.h:1828
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
GenericReader& GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::operator= ( const GenericReader< SourceEncoding, TargetEncoding, StackAllocator > &  )
private
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
ParseResult GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Parse ( InputStream &  is,
Handler &  handler 
)
inline

Parse JSON text.

Template Parameters
parseFlagsCombination of ParseFlag.
InputStreamType of input stream, implementing Stream concept.
HandlerType of handler, implementing Handler concept.
Parameters
isInput stream to be parsed.
handlerThe handler to receive events.
Returns
Whether the parsing is successful.

Definition at line 557 of file reader.h.

557  {
558  if (parseFlags & kParseIterativeFlag)
559  return IterativeParse<parseFlags>(is, handler);
560 
562 
563  ClearStackOnExit scope(*this);
564 
565  SkipWhitespaceAndComments<parseFlags>(is);
566  RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
567 
568  if (RAPIDJSON_UNLIKELY(is.Peek() == '\0')) {
570  RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
571  }
572  else {
573  ParseValue<parseFlags>(is, handler);
574  RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
575 
576  if (!(parseFlags & kParseStopWhenDoneFlag)) {
577  SkipWhitespaceAndComments<parseFlags>(is);
578  RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
579 
580  if (RAPIDJSON_UNLIKELY(is.Peek() != '\0')) {
582  RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);
583  }
584  }
585  }
586 
587  return parseResult_;
588  }
static QCString scope
Definition: declinfo.cpp:668
Iterative(constant complexity in terms of function call stack size) parsing.
Definition: reader.h:149
ParseResult parseResult_
Definition: reader.h:2212
The document is empty.
Definition: error.h:67
#define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset)
Macro to indicate a parse error.
Definition: reader.h:99
After parsing a complete JSON root from stream, stop further processing the rest of stream...
Definition: reader.h:150
void Clear()
Reset error code.
Definition: error.h:134
static msg_handler handler
Definition: qglobal.cpp:234
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
The document root must not follow by other values.
Definition: error.h:68
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<typename InputStream , typename Handler >
ParseResult GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Parse ( InputStream &  is,
Handler &  handler 
)
inline

Parse JSON text (with kParseDefaultFlags)

Template Parameters
InputStreamType of input stream, implementing Stream concept
HandlerType of handler, implementing Handler concept.
Parameters
isInput stream to be parsed.
handlerThe handler to receive events.
Returns
Whether the parsing is successful.

Definition at line 598 of file reader.h.

598  {
599  return Parse<kParseDefaultFlags>(is, handler);
600  }
static msg_handler handler
Definition: qglobal.cpp:234
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseArray ( InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 806 of file reader.h.

806  {
807  RAPIDJSON_ASSERT(is.Peek() == '[');
808  is.Take(); // Skip '['
809 
810  if (RAPIDJSON_UNLIKELY(!handler.StartArray()))
812 
813  SkipWhitespaceAndComments<parseFlags>(is);
814  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
815 
816  if (Consume(is, ']')) {
817  if (RAPIDJSON_UNLIKELY(!handler.EndArray(0))) // empty array
819  return;
820  }
821 
822  for (SizeType elementCount = 0;;) {
823  ParseValue<parseFlags>(is, handler);
824  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
825 
826  ++elementCount;
827  SkipWhitespaceAndComments<parseFlags>(is);
828  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
829 
830  if (Consume(is, ',')) {
831  SkipWhitespaceAndComments<parseFlags>(is);
832  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
833  }
834  else if (Consume(is, ']')) {
835  if (RAPIDJSON_UNLIKELY(!handler.EndArray(elementCount)))
837  return;
838  }
839  else
841 
842  if (parseFlags & kParseTrailingCommasFlag) {
843  if (is.Peek() == ']') {
844  if (RAPIDJSON_UNLIKELY(!handler.EndArray(elementCount)))
846  is.Take();
847  return;
848  }
849  }
850  }
851  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Parsing was terminated.
Definition: error.h:88
Missing a comma or &#39;]&#39; after an array element.
Definition: error.h:76
Allow trailing commas at the end of objects and arrays.
Definition: reader.h:154
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
static RAPIDJSON_FORCEINLINE bool Consume(InputStream &is, typename InputStream::Ch expect)
Definition: reader.h:893
static msg_handler handler
Definition: qglobal.cpp:234
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseFalse ( InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 880 of file reader.h.

880  {
881  RAPIDJSON_ASSERT(is.Peek() == 'f');
882  is.Take();
883 
884  if (RAPIDJSON_LIKELY(Consume(is, 'a') && Consume(is, 'l') && Consume(is, 's') && Consume(is, 'e'))) {
885  if (RAPIDJSON_UNLIKELY(!handler.Bool(false)))
887  }
888  else
890  }
Invalid value.
Definition: error.h:70
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Parsing was terminated.
Definition: error.h:88
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
static RAPIDJSON_FORCEINLINE bool Consume(InputStream &is, typename InputStream::Ch expect)
Definition: reader.h:893
static msg_handler handler
Definition: qglobal.cpp:234
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<typename InputStream >
unsigned GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseHex4 ( InputStream &  is,
size_t  escapeOffset 
)
inlineprivate

Definition at line 904 of file reader.h.

904  {
905  unsigned codepoint = 0;
906  for (int i = 0; i < 4; i++) {
907  Ch c = is.Peek();
908  codepoint <<= 4;
909  codepoint += static_cast<unsigned>(c);
910  if (c >= '0' && c <= '9')
911  codepoint -= '0';
912  else if (c >= 'A' && c <= 'F')
913  codepoint -= 'A' - 10;
914  else if (c >= 'a' && c <= 'f')
915  codepoint -= 'a' - 10;
916  else {
918  RAPIDJSON_PARSE_ERROR_EARLY_RETURN(0);
919  }
920  is.Take();
921  }
922  return codepoint;
923  }
#define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset)
Macro to indicate a parse error.
Definition: reader.h:99
SourceEncoding::Ch Ch
SourceEncoding character type.
Definition: reader.h:539
Incorrect hex digit after \u escape in string.
Definition: error.h:78
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseNull ( InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 854 of file reader.h.

854  {
855  RAPIDJSON_ASSERT(is.Peek() == 'n');
856  is.Take();
857 
858  if (RAPIDJSON_LIKELY(Consume(is, 'u') && Consume(is, 'l') && Consume(is, 'l'))) {
859  if (RAPIDJSON_UNLIKELY(!handler.Null()))
861  }
862  else
864  }
Invalid value.
Definition: error.h:70
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Parsing was terminated.
Definition: error.h:88
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
static RAPIDJSON_FORCEINLINE bool Consume(InputStream &is, typename InputStream::Ch expect)
Definition: reader.h:893
static msg_handler handler
Definition: qglobal.cpp:234
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseNumber ( InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 1454 of file reader.h.

1454  {
1456  NumberStream<InputStream,
1457  ((parseFlags & kParseNumbersAsStringsFlag) != 0) ?
1458  ((parseFlags & kParseInsituFlag) == 0) :
1459  ((parseFlags & kParseFullPrecisionFlag) != 0),
1460  (parseFlags & kParseNumbersAsStringsFlag) != 0 &&
1461  (parseFlags & kParseInsituFlag) == 0> s(*this, copy.s);
1462 
1463  size_t startOffset = s.Tell();
1464  double d = 0.0;
1465  bool useNanOrInf = false;
1466 
1467  // Parse minus
1468  bool minus = Consume(s, '-');
1469 
1470  // Parse int: zero / ( digit1-9 *DIGIT )
1471  unsigned i = 0;
1472  uint64_t i64 = 0;
1473  bool use64bit = false;
1474  int significandDigit = 0;
1475  if (RAPIDJSON_UNLIKELY(s.Peek() == '0')) {
1476  i = 0;
1477  s.TakePush();
1478  }
1479  else if (RAPIDJSON_LIKELY(s.Peek() >= '1' && s.Peek() <= '9')) {
1480  i = static_cast<unsigned>(s.TakePush() - '0');
1481 
1482  if (minus)
1483  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1484  if (RAPIDJSON_UNLIKELY(i >= 214748364)) { // 2^31 = 2147483648
1485  if (RAPIDJSON_LIKELY(i != 214748364 || s.Peek() > '8')) {
1486  i64 = i;
1487  use64bit = true;
1488  break;
1489  }
1490  }
1491  i = i * 10 + static_cast<unsigned>(s.TakePush() - '0');
1492  significandDigit++;
1493  }
1494  else
1495  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1496  if (RAPIDJSON_UNLIKELY(i >= 429496729)) { // 2^32 - 1 = 4294967295
1497  if (RAPIDJSON_LIKELY(i != 429496729 || s.Peek() > '5')) {
1498  i64 = i;
1499  use64bit = true;
1500  break;
1501  }
1502  }
1503  i = i * 10 + static_cast<unsigned>(s.TakePush() - '0');
1504  significandDigit++;
1505  }
1506  }
1507  // Parse NaN or Infinity here
1508  else if ((parseFlags & kParseNanAndInfFlag) && RAPIDJSON_LIKELY((s.Peek() == 'I' || s.Peek() == 'N'))) {
1509  if (Consume(s, 'N')) {
1510  if (Consume(s, 'a') && Consume(s, 'N')) {
1511  d = std::numeric_limits<double>::quiet_NaN();
1512  useNanOrInf = true;
1513  }
1514  }
1515  else if (RAPIDJSON_LIKELY(Consume(s, 'I'))) {
1516  if (Consume(s, 'n') && Consume(s, 'f')) {
1517  d = (minus ? -std::numeric_limits<double>::infinity() : std::numeric_limits<double>::infinity());
1518  useNanOrInf = true;
1519 
1520  if (RAPIDJSON_UNLIKELY(s.Peek() == 'i' && !(Consume(s, 'i') && Consume(s, 'n')
1521  && Consume(s, 'i') && Consume(s, 't') && Consume(s, 'y')))) {
1523  }
1524  }
1525  }
1526 
1527  if (RAPIDJSON_UNLIKELY(!useNanOrInf)) {
1529  }
1530  }
1531  else
1533 
1534  // Parse 64bit int
1535  bool useDouble = false;
1536  if (use64bit) {
1537  if (minus)
1538  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1539  if (RAPIDJSON_UNLIKELY(i64 >= RAPIDJSON_UINT64_C2(0x0CCCCCCC, 0xCCCCCCCC))) // 2^63 = 9223372036854775808
1540  if (RAPIDJSON_LIKELY(i64 != RAPIDJSON_UINT64_C2(0x0CCCCCCC, 0xCCCCCCCC) || s.Peek() > '8')) {
1541  d = static_cast<double>(i64);
1542  useDouble = true;
1543  break;
1544  }
1545  i64 = i64 * 10 + static_cast<unsigned>(s.TakePush() - '0');
1546  significandDigit++;
1547  }
1548  else
1549  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1550  if (RAPIDJSON_UNLIKELY(i64 >= RAPIDJSON_UINT64_C2(0x19999999, 0x99999999))) // 2^64 - 1 = 18446744073709551615
1551  if (RAPIDJSON_LIKELY(i64 != RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) || s.Peek() > '5')) {
1552  d = static_cast<double>(i64);
1553  useDouble = true;
1554  break;
1555  }
1556  i64 = i64 * 10 + static_cast<unsigned>(s.TakePush() - '0');
1557  significandDigit++;
1558  }
1559  }
1560 
1561  // Force double for big integer
1562  if (useDouble) {
1563  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1564  d = d * 10 + (s.TakePush() - '0');
1565  }
1566  }
1567 
1568  // Parse frac = decimal-point 1*DIGIT
1569  int expFrac = 0;
1570  size_t decimalPosition;
1571  if (Consume(s, '.')) {
1572  decimalPosition = s.Length();
1573 
1574  if (RAPIDJSON_UNLIKELY(!(s.Peek() >= '0' && s.Peek() <= '9')))
1576 
1577  if (!useDouble) {
1578 #if RAPIDJSON_64BIT
1579  // Use i64 to store significand in 64-bit architecture
1580  if (!use64bit)
1581  i64 = i;
1582 
1583  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1584  if (i64 > RAPIDJSON_UINT64_C2(0x1FFFFF, 0xFFFFFFFF)) // 2^53 - 1 for fast path
1585  break;
1586  else {
1587  i64 = i64 * 10 + static_cast<unsigned>(s.TakePush() - '0');
1588  --expFrac;
1589  if (i64 != 0)
1590  significandDigit++;
1591  }
1592  }
1593 
1594  d = static_cast<double>(i64);
1595 #else
1596  // Use double to store significand in 32-bit architecture
1597  d = static_cast<double>(use64bit ? i64 : i);
1598 #endif
1599  useDouble = true;
1600  }
1601 
1602  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1603  if (significandDigit < 17) {
1604  d = d * 10.0 + (s.TakePush() - '0');
1605  --expFrac;
1606  if (RAPIDJSON_LIKELY(d > 0.0))
1607  significandDigit++;
1608  }
1609  else
1610  s.TakePush();
1611  }
1612  }
1613  else
1614  decimalPosition = s.Length(); // decimal position at the end of integer.
1615 
1616  // Parse exp = e [ minus / plus ] 1*DIGIT
1617  int exp = 0;
1618  if (Consume(s, 'e') || Consume(s, 'E')) {
1619  if (!useDouble) {
1620  d = static_cast<double>(use64bit ? i64 : i);
1621  useDouble = true;
1622  }
1623 
1624  bool expMinus = false;
1625  if (Consume(s, '+'))
1626  ;
1627  else if (Consume(s, '-'))
1628  expMinus = true;
1629 
1630  if (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1631  exp = static_cast<int>(s.Take() - '0');
1632  if (expMinus) {
1633  // (exp + expFrac) must not underflow int => we're detecting when -exp gets
1634  // dangerously close to INT_MIN (a pessimistic next digit 9 would push it into
1635  // underflow territory):
1636  //
1637  // -(exp * 10 + 9) + expFrac >= INT_MIN
1638  // <=> exp <= (expFrac - INT_MIN - 9) / 10
1639  RAPIDJSON_ASSERT(expFrac <= 0);
1640  int maxExp = (expFrac + 2147483639) / 10;
1641 
1642  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1643  exp = exp * 10 + static_cast<int>(s.Take() - '0');
1644  if (RAPIDJSON_UNLIKELY(exp > maxExp)) {
1645  while (RAPIDJSON_UNLIKELY(s.Peek() >= '0' && s.Peek() <= '9')) // Consume the rest of exponent
1646  s.Take();
1647  }
1648  }
1649  }
1650  else { // positive exp
1651  int maxExp = 308 - expFrac;
1652  while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {
1653  exp = exp * 10 + static_cast<int>(s.Take() - '0');
1654  if (RAPIDJSON_UNLIKELY(exp > maxExp))
1656  }
1657  }
1658  }
1659  else
1661 
1662  if (expMinus)
1663  exp = -exp;
1664  }
1665 
1666  // Finish parsing, call event according to the type of number.
1667  bool cont = true;
1668 
1669  if (parseFlags & kParseNumbersAsStringsFlag) {
1670  if (parseFlags & kParseInsituFlag) {
1671  s.Pop(); // Pop stack no matter if it will be used or not.
1672  typename InputStream::Ch* head = is.PutBegin();
1673  const size_t length = s.Tell() - startOffset;
1674  RAPIDJSON_ASSERT(length <= 0xFFFFFFFF);
1675  // unable to insert the \0 character here, it will erase the comma after this number
1676  const typename TargetEncoding::Ch* const str = reinterpret_cast<typename TargetEncoding::Ch*>(head);
1677  cont = handler.RawNumber(str, SizeType(length), false);
1678  }
1679  else {
1680  SizeType numCharsToCopy = static_cast<SizeType>(s.Length());
1681  StringStream srcStream(s.Pop());
1682  StackStream<typename TargetEncoding::Ch> dstStream(stack_);
1683  while (numCharsToCopy--) {
1684  Transcoder<UTF8<>, TargetEncoding>::Transcode(srcStream, dstStream);
1685  }
1686  dstStream.Put('\0');
1687  const typename TargetEncoding::Ch* str = dstStream.Pop();
1688  const SizeType length = static_cast<SizeType>(dstStream.Length()) - 1;
1689  cont = handler.RawNumber(str, SizeType(length), true);
1690  }
1691  }
1692  else {
1693  size_t length = s.Length();
1694  const char* decimal = s.Pop(); // Pop stack no matter if it will be used or not.
1695 
1696  if (useDouble) {
1697  int p = exp + expFrac;
1698  if (parseFlags & kParseFullPrecisionFlag)
1699  d = internal::StrtodFullPrecision(d, p, decimal, length, decimalPosition, exp);
1700  else
1702 
1703  // Use > max, instead of == inf, to fix bogus warning -Wfloat-equal
1704  if (d > (std::numeric_limits<double>::max)()) {
1705  // Overflow
1706  // TODO: internal::StrtodX should report overflow (or underflow)
1708  }
1709 
1710  cont = handler.Double(minus ? -d : d);
1711  }
1712  else if (useNanOrInf) {
1713  cont = handler.Double(d);
1714  }
1715  else {
1716  if (use64bit) {
1717  if (minus)
1718  cont = handler.Int64(static_cast<int64_t>(~i64 + 1));
1719  else
1720  cont = handler.Uint64(i64);
1721  }
1722  else {
1723  if (minus)
1724  cont = handler.Int(static_cast<int32_t>(~i + 1));
1725  else
1726  cont = handler.Uint(i);
1727  }
1728  }
1729  }
1730  if (RAPIDJSON_UNLIKELY(!cont))
1732  }
Encoding conversion.
Definition: encodings.h:658
Invalid value.
Definition: error.h:70
double StrtodFullPrecision(double d, int p, const char *decimals, size_t length, size_t decimalPosition, int exp)
Definition: strtod.h:226
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Parsing was terminated.
Definition: error.h:88
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:289
Read-only string stream.
Definition: fwd.h:47
STL namespace.
Allow parsing NaN, Inf, Infinity, -Inf and -Infinity as doubles.
Definition: reader.h:155
Number too big to be stored in double.
Definition: error.h:84
Parse all numbers (ints/doubles) as strings.
Definition: reader.h:153
Parse number in full precision (but slower).
Definition: reader.h:151
double StrtodNormalPrecision(double d, int p)
Definition: strtod.h:37
unsigned __int64 uint64_t
Definition: stdint.h:136
Miss exponent in number.
Definition: error.h:86
static int max(int a, int b)
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
p
Definition: test.py:223
Miss fraction part in number.
Definition: error.h:85
internal::Stack< StackAllocator > stack_
A stack for storing decoded string temporarily during non-destructive parsing.
Definition: reader.h:2211
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
T copy(T const &v)
static RAPIDJSON_FORCEINLINE bool Consume(InputStream &is, typename InputStream::Ch expect)
Definition: reader.h:893
static msg_handler handler
Definition: qglobal.cpp:234
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
static QCString * s
Definition: config.cpp:1042
static QCString str
In-situ(destructive) parsing.
Definition: reader.h:147
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseObject ( InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 738 of file reader.h.

738  {
739  RAPIDJSON_ASSERT(is.Peek() == '{');
740  is.Take(); // Skip '{'
741 
742  if (RAPIDJSON_UNLIKELY(!handler.StartObject()))
744 
745  SkipWhitespaceAndComments<parseFlags>(is);
746  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
747 
748  if (Consume(is, '}')) {
749  if (RAPIDJSON_UNLIKELY(!handler.EndObject(0))) // empty object
751  return;
752  }
753 
754  for (SizeType memberCount = 0;;) {
755  if (RAPIDJSON_UNLIKELY(is.Peek() != '"'))
757 
758  ParseString<parseFlags>(is, handler, true);
759  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
760 
761  SkipWhitespaceAndComments<parseFlags>(is);
762  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
763 
764  if (RAPIDJSON_UNLIKELY(!Consume(is, ':')))
766 
767  SkipWhitespaceAndComments<parseFlags>(is);
768  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
769 
770  ParseValue<parseFlags>(is, handler);
771  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
772 
773  SkipWhitespaceAndComments<parseFlags>(is);
774  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
775 
776  ++memberCount;
777 
778  switch (is.Peek()) {
779  case ',':
780  is.Take();
781  SkipWhitespaceAndComments<parseFlags>(is);
782  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
783  break;
784  case '}':
785  is.Take();
786  if (RAPIDJSON_UNLIKELY(!handler.EndObject(memberCount)))
788  return;
789  default:
790  RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); break; // This useless break is only for making warning and coverage happy
791  }
792 
793  if (parseFlags & kParseTrailingCommasFlag) {
794  if (is.Peek() == '}') {
795  if (RAPIDJSON_UNLIKELY(!handler.EndObject(memberCount)))
797  is.Take();
798  return;
799  }
800  }
801  }
802  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Parsing was terminated.
Definition: error.h:88
Missing a comma or &#39;}&#39; after an object member.
Definition: error.h:74
Missing a name for object member.
Definition: error.h:72
Allow trailing commas at the end of objects and arrays.
Definition: reader.h:154
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
static RAPIDJSON_FORCEINLINE bool Consume(InputStream &is, typename InputStream::Ch expect)
Definition: reader.h:893
static msg_handler handler
Definition: qglobal.cpp:234
Missing a colon after a name of object member.
Definition: error.h:73
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseString ( InputStream &  is,
Handler &  handler,
bool  isKey = false 
)
inlineprivate

Definition at line 957 of file reader.h.

957  {
959  InputStream& s(copy.s);
960 
961  RAPIDJSON_ASSERT(s.Peek() == '\"');
962  s.Take(); // Skip '\"'
963 
964  bool success = false;
965  if (parseFlags & kParseInsituFlag) {
966  typename InputStream::Ch *head = s.PutBegin();
967  ParseStringToStream<parseFlags, SourceEncoding, SourceEncoding>(s, s);
968  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
969  size_t length = s.PutEnd(head) - 1;
970  RAPIDJSON_ASSERT(length <= 0xFFFFFFFF);
971  const typename TargetEncoding::Ch* const str = reinterpret_cast<typename TargetEncoding::Ch*>(head);
972  success = (isKey ? handler.Key(str, SizeType(length), false) : handler.String(str, SizeType(length), false));
973  }
974  else {
975  StackStream<typename TargetEncoding::Ch> stackStream(stack_);
976  ParseStringToStream<parseFlags, SourceEncoding, TargetEncoding>(s, stackStream);
977  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
978  SizeType length = static_cast<SizeType>(stackStream.Length()) - 1;
979  const typename TargetEncoding::Ch* const str = stackStream.Pop();
980  success = (isKey ? handler.Key(str, length, true) : handler.String(str, length, true));
981  }
982  if (RAPIDJSON_UNLIKELY(!success))
984  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Parsing was terminated.
Definition: error.h:88
internal::Stack< StackAllocator > stack_
A stack for storing decoded string temporarily during non-destructive parsing.
Definition: reader.h:2211
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
T copy(T const &v)
static msg_handler handler
Definition: qglobal.cpp:234
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
static QCString * s
Definition: config.cpp:1042
static QCString str
In-situ(destructive) parsing.
Definition: reader.h:147
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename SEncoding , typename TEncoding , typename InputStream , typename OutputStream >
RAPIDJSON_FORCEINLINE void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseStringToStream ( InputStream &  is,
OutputStream &  os 
)
inlineprivate

Definition at line 989 of file reader.h.

989  {
990 //!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
991 #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
992  static const char escape[256] = {
993  Z16, Z16, 0, 0,'\"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'/',
994  Z16, Z16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\', 0, 0, 0,
995  0, 0,'\b', 0, 0, 0,'\f', 0, 0, 0, 0, 0, 0, 0,'\n', 0,
996  0, 0,'\r', 0,'\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
997  Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16
998  };
999 #undef Z16
1000 //!@endcond
1001 
1002  for (;;) {
1003  // Scan and copy string before "\\\"" or < 0x20. This is an optional optimzation.
1004  if (!(parseFlags & kParseValidateEncodingFlag))
1005  ScanCopyUnescapedString(is, os);
1006 
1007  Ch c = is.Peek();
1008  if (RAPIDJSON_UNLIKELY(c == '\\')) { // Escape
1009  size_t escapeOffset = is.Tell(); // For invalid escaping, report the initial '\\' as error offset
1010  is.Take();
1011  Ch e = is.Peek();
1012  if ((sizeof(Ch) == 1 || unsigned(e) < 256) && RAPIDJSON_LIKELY(escape[static_cast<unsigned char>(e)])) {
1013  is.Take();
1014  os.Put(static_cast<typename TEncoding::Ch>(escape[static_cast<unsigned char>(e)]));
1015  }
1016  else if (RAPIDJSON_LIKELY(e == 'u')) { // Unicode
1017  is.Take();
1018  unsigned codepoint = ParseHex4(is, escapeOffset);
1019  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
1020  if (RAPIDJSON_UNLIKELY(codepoint >= 0xD800 && codepoint <= 0xDBFF)) {
1021  // Handle UTF-16 surrogate pair
1022  if (RAPIDJSON_UNLIKELY(!Consume(is, '\\') || !Consume(is, 'u')))
1024  unsigned codepoint2 = ParseHex4(is, escapeOffset);
1025  RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;
1026  if (RAPIDJSON_UNLIKELY(codepoint2 < 0xDC00 || codepoint2 > 0xDFFF))
1028  codepoint = (((codepoint - 0xD800) << 10) | (codepoint2 - 0xDC00)) + 0x10000;
1029  }
1030  TEncoding::Encode(os, codepoint);
1031  }
1032  else
1034  }
1035  else if (RAPIDJSON_UNLIKELY(c == '"')) { // Closing double quote
1036  is.Take();
1037  os.Put('\0'); // null-terminate the string
1038  return;
1039  }
1040  else if (RAPIDJSON_UNLIKELY(static_cast<unsigned>(c) < 0x20)) { // RFC 4627: unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
1041  if (c == '\0')
1043  else
1045  }
1046  else {
1047  size_t offset = is.Tell();
1048  if (RAPIDJSON_UNLIKELY((parseFlags & kParseValidateEncodingFlag ?
1052  }
1053  }
1054  }
Encoding conversion.
Definition: encodings.h:658
SourceEncoding::Ch Ch
SourceEncoding character type.
Definition: reader.h:539
unsigned ParseHex4(InputStream &is, size_t escapeOffset)
Definition: reader.h:904
const double e
Invalid escape character in string.
Definition: error.h:80
Invalid encoding in string.
Definition: error.h:82
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
#define Z16
Validate encoding of JSON strings.
Definition: reader.h:148
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
static RAPIDJSON_FORCEINLINE bool Consume(InputStream &is, typename InputStream::Ch expect)
Definition: reader.h:893
The surrogate pair in string is invalid.
Definition: error.h:79
std::string escape(std::string const &str)
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
Missing a closing quotation mark in string.
Definition: error.h:81
static RAPIDJSON_FORCEINLINE void ScanCopyUnescapedString(InputStream &, OutputStream &)
Definition: reader.h:1057
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseTrue ( InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 867 of file reader.h.

867  {
868  RAPIDJSON_ASSERT(is.Peek() == 't');
869  is.Take();
870 
871  if (RAPIDJSON_LIKELY(Consume(is, 'r') && Consume(is, 'u') && Consume(is, 'e'))) {
872  if (RAPIDJSON_UNLIKELY(!handler.Bool(true)))
874  }
875  else
877  }
Invalid value.
Definition: error.h:70
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Parsing was terminated.
Definition: error.h:88
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
static RAPIDJSON_FORCEINLINE bool Consume(InputStream &is, typename InputStream::Ch expect)
Definition: reader.h:893
static msg_handler handler
Definition: qglobal.cpp:234
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ParseValue ( InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 1736 of file reader.h.

1736  {
1737  switch (is.Peek()) {
1738  case 'n': ParseNull <parseFlags>(is, handler); break;
1739  case 't': ParseTrue <parseFlags>(is, handler); break;
1740  case 'f': ParseFalse <parseFlags>(is, handler); break;
1741  case '"': ParseString<parseFlags>(is, handler); break;
1742  case '{': ParseObject<parseFlags>(is, handler); break;
1743  case '[': ParseArray <parseFlags>(is, handler); break;
1744  default :
1745  ParseNumber<parseFlags>(is, handler);
1746  break;
1747 
1748  }
1749  }
static msg_handler handler
Definition: qglobal.cpp:234
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
RAPIDJSON_FORCEINLINE IterativeParsingState GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Predict ( IterativeParsingState  state,
Token  token 
) const
inlineprivate

Definition at line 1828 of file reader.h.

1828  {
1829  // current state x one lookahead token -> new state
1830  static const char G[cIterativeParsingStateCount][kTokenCount] = {
1831  // Finish(sink state)
1832  {
1835  IterativeParsingErrorState
1836  },
1837  // Error(sink state)
1838  {
1841  IterativeParsingErrorState
1842  },
1843  // Start
1844  {
1845  IterativeParsingArrayInitialState, // Left bracket
1846  IterativeParsingErrorState, // Right bracket
1847  IterativeParsingObjectInitialState, // Left curly bracket
1848  IterativeParsingErrorState, // Right curly bracket
1849  IterativeParsingErrorState, // Comma
1850  IterativeParsingErrorState, // Colon
1851  IterativeParsingValueState, // String
1852  IterativeParsingValueState, // False
1855  IterativeParsingValueState // Number
1856  },
1857  // ObjectInitial
1858  {
1859  IterativeParsingErrorState, // Left bracket
1860  IterativeParsingErrorState, // Right bracket
1861  IterativeParsingErrorState, // Left curly bracket
1862  IterativeParsingObjectFinishState, // Right curly bracket
1863  IterativeParsingErrorState, // Comma
1864  IterativeParsingErrorState, // Colon
1866  IterativeParsingErrorState, // False
1869  IterativeParsingErrorState // Number
1870  },
1871  // MemberKey
1872  {
1873  IterativeParsingErrorState, // Left bracket
1874  IterativeParsingErrorState, // Right bracket
1875  IterativeParsingErrorState, // Left curly bracket
1876  IterativeParsingErrorState, // Right curly bracket
1877  IterativeParsingErrorState, // Comma
1879  IterativeParsingErrorState, // String
1880  IterativeParsingErrorState, // False
1883  IterativeParsingErrorState // Number
1884  },
1885  // MemberValue
1886  {
1887  IterativeParsingErrorState, // Left bracket
1888  IterativeParsingErrorState, // Right bracket
1889  IterativeParsingErrorState, // Left curly bracket
1890  IterativeParsingObjectFinishState, // Right curly bracket
1892  IterativeParsingErrorState, // Colon
1893  IterativeParsingErrorState, // String
1894  IterativeParsingErrorState, // False
1897  IterativeParsingErrorState // Number
1898  },
1899  // ObjectFinish(sink state)
1900  {
1903  IterativeParsingErrorState
1904  },
1905  // ArrayInitial
1906  {
1907  IterativeParsingArrayInitialState, // Left bracket(push Element state)
1908  IterativeParsingArrayFinishState, // Right bracket
1909  IterativeParsingObjectInitialState, // Left curly bracket(push Element state)
1910  IterativeParsingErrorState, // Right curly bracket
1911  IterativeParsingErrorState, // Comma
1912  IterativeParsingErrorState, // Colon
1913  IterativeParsingElementState, // String
1917  IterativeParsingElementState // Number
1918  },
1919  // Element
1920  {
1921  IterativeParsingErrorState, // Left bracket
1922  IterativeParsingArrayFinishState, // Right bracket
1923  IterativeParsingErrorState, // Left curly bracket
1924  IterativeParsingErrorState, // Right curly bracket
1926  IterativeParsingErrorState, // Colon
1927  IterativeParsingErrorState, // String
1928  IterativeParsingErrorState, // False
1931  IterativeParsingErrorState // Number
1932  },
1933  // ArrayFinish(sink state)
1934  {
1937  IterativeParsingErrorState
1938  },
1939  // Single Value (sink state)
1940  {
1943  IterativeParsingErrorState
1944  },
1945  // ElementDelimiter
1946  {
1947  IterativeParsingArrayInitialState, // Left bracket(push Element state)
1948  IterativeParsingArrayFinishState, // Right bracket
1949  IterativeParsingObjectInitialState, // Left curly bracket(push Element state)
1950  IterativeParsingErrorState, // Right curly bracket
1951  IterativeParsingErrorState, // Comma
1952  IterativeParsingErrorState, // Colon
1953  IterativeParsingElementState, // String
1957  IterativeParsingElementState // Number
1958  },
1959  // MemberDelimiter
1960  {
1961  IterativeParsingErrorState, // Left bracket
1962  IterativeParsingErrorState, // Right bracket
1963  IterativeParsingErrorState, // Left curly bracket
1964  IterativeParsingObjectFinishState, // Right curly bracket
1965  IterativeParsingErrorState, // Comma
1966  IterativeParsingErrorState, // Colon
1968  IterativeParsingErrorState, // False
1971  IterativeParsingErrorState // Number
1972  },
1973  // KeyValueDelimiter
1974  {
1975  IterativeParsingArrayInitialState, // Left bracket(push MemberValue state)
1976  IterativeParsingErrorState, // Right bracket
1977  IterativeParsingObjectInitialState, // Left curly bracket(push MemberValue state)
1978  IterativeParsingErrorState, // Right curly bracket
1979  IterativeParsingErrorState, // Comma
1980  IterativeParsingErrorState, // Colon
1985  IterativeParsingMemberValueState // Number
1986  },
1987  }; // End of G
1988 
1989  return static_cast<IterativeParsingState>(G[state][token]);
1990  }
IterativeParsingState
Definition: reader.h:1754
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<typename InputStream , typename OutputStream >
static RAPIDJSON_FORCEINLINE void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::ScanCopyUnescapedString ( InputStream &  ,
OutputStream &   
)
inlinestaticprivate

Definition at line 1057 of file reader.h.

1057  {
1058  // Do nothing for generic version
1059  }
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::SetParseError ( ParseErrorCode  code,
size_t  offset 
)
inlineprotected

Definition at line 689 of file reader.h.

689 { parseResult_.Set(code, offset); }
ParseResult parseResult_
Definition: reader.h:2212
void Set(ParseErrorCode code, size_t offset=0)
Update error code and offset.
Definition: error.h:136
CodeOutputInterface * code
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream >
void GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::SkipWhitespaceAndComments ( InputStream &  is)
inlineprivate

Definition at line 709 of file reader.h.

709  {
710  SkipWhitespace(is);
711 
712  if (parseFlags & kParseCommentsFlag) {
713  while (RAPIDJSON_UNLIKELY(Consume(is, '/'))) {
714  if (Consume(is, '*')) {
715  while (true) {
716  if (RAPIDJSON_UNLIKELY(is.Peek() == '\0'))
718  else if (Consume(is, '*')) {
719  if (Consume(is, '/'))
720  break;
721  }
722  else
723  is.Take();
724  }
725  }
726  else if (RAPIDJSON_LIKELY(Consume(is, '/')))
727  while (is.Peek() != '\0' && is.Take() != '\n') {}
728  else
730 
731  SkipWhitespace(is);
732  }
733  }
734  }
#define RAPIDJSON_LIKELY(x)
Compiler branching hint for expression with high probability to be true.
Definition: rapidjson.h:463
void SkipWhitespace(InputStream &is)
Skip the JSON white spaces in a stream.
Definition: reader.h:264
#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset)
(Internal) macro to indicate and handle a parse error.
Definition: reader.h:118
static RAPIDJSON_FORCEINLINE bool Consume(InputStream &is, typename InputStream::Ch expect)
Definition: reader.h:893
Unspecific syntax error.
Definition: error.h:89
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
Definition: rapidjson.h:476
Allow one-line (//) and multi-line (/**/) comments.
Definition: reader.h:152
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
RAPIDJSON_FORCEINLINE Token GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Tokenize ( Ch  c) const
inlineprivate

Definition at line 1801 of file reader.h.

1801  {
1802 
1803 //!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN
1804 #define N NumberToken
1805 #define N16 N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N
1806  // Maps from ASCII to Token
1807  static const unsigned char tokenMap[256] = {
1808  N16, // 00~0F
1809  N16, // 10~1F
1810  N, N, StringToken, N, N, N, N, N, N, N, N, N, CommaToken, N, N, N, // 20~2F
1811  N, N, N, N, N, N, N, N, N, N, ColonToken, N, N, N, N, N, // 30~3F
1812  N16, // 40~4F
1813  N, N, N, N, N, N, N, N, N, N, N, LeftBracketToken, N, RightBracketToken, N, N, // 50~5F
1814  N, N, N, N, N, N, FalseToken, N, N, N, N, N, N, N, NullToken, N, // 60~6F
1815  N, N, N, N, TrueToken, N, N, N, N, N, N, LeftCurlyBracketToken, N, RightCurlyBracketToken, N, N, // 70~7F
1816  N16, N16, N16, N16, N16, N16, N16, N16 // 80~FF
1817  };
1818 #undef N
1819 #undef N16
1820 //!@endcond
1821 
1822  if (sizeof(Ch) == 1 || static_cast<unsigned>(c) < 256)
1823  return static_cast<Token>(tokenMap[static_cast<unsigned char>(c)]);
1824  else
1825  return NumberToken;
1826  }
SourceEncoding::Ch Ch
SourceEncoding character type.
Definition: reader.h:539
template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >
RAPIDJSON_FORCEINLINE IterativeParsingState GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Transit ( IterativeParsingState  src,
Token  token,
IterativeParsingState  dst,
InputStream &  is,
Handler &  handler 
)
inlineprivate

Definition at line 1995 of file reader.h.

1995  {
1996  (void)token;
1997 
1998  switch (dst) {
2000  return dst;
2001 
2004  {
2005  // Push the state(Element or MemeberValue) if we are nested in another array or value of member.
2006  // In this way we can get the correct state on ObjectFinish or ArrayFinish by frame pop.
2007  IterativeParsingState n = src;
2012  // Push current state.
2013  *stack_.template Push<SizeType>(1) = n;
2014  // Initialize and push the member/element count.
2015  *stack_.template Push<SizeType>(1) = 0;
2016  // Call handler
2017  bool hr = (dst == IterativeParsingObjectInitialState) ? handler.StartObject() : handler.StartArray();
2018  // On handler short circuits the parsing.
2019  if (!hr) {
2022  }
2023  else {
2024  is.Take();
2025  return dst;
2026  }
2027  }
2028 
2030  ParseString<parseFlags>(is, handler, true);
2031  if (HasParseError())
2033  else
2034  return dst;
2035 
2037  RAPIDJSON_ASSERT(token == ColonToken);
2038  is.Take();
2039  return dst;
2040 
2042  // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.
2043  ParseValue<parseFlags>(is, handler);
2044  if (HasParseError()) {
2046  }
2047  return dst;
2048 
2050  // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.
2051  ParseValue<parseFlags>(is, handler);
2052  if (HasParseError()) {
2054  }
2055  return dst;
2056 
2059  is.Take();
2060  // Update member/element count.
2061  *stack_.template Top<SizeType>() = *stack_.template Top<SizeType>() + 1;
2062  return dst;
2063 
2065  {
2066  // Transit from delimiter is only allowed when trailing commas are enabled
2067  if (!(parseFlags & kParseTrailingCommasFlag) && src == IterativeParsingMemberDelimiterState) {
2070  }
2071  // Get member count.
2072  SizeType c = *stack_.template Pop<SizeType>(1);
2073  // If the object is not empty, count the last member.
2075  ++c;
2076  // Restore the state.
2077  IterativeParsingState n = static_cast<IterativeParsingState>(*stack_.template Pop<SizeType>(1));
2078  // Transit to Finish state if this is the topmost scope.
2079  if (n == IterativeParsingStartState)
2081  // Call handler
2082  bool hr = handler.EndObject(c);
2083  // On handler short circuits the parsing.
2084  if (!hr) {
2087  }
2088  else {
2089  is.Take();
2090  return n;
2091  }
2092  }
2093 
2095  {
2096  // Transit from delimiter is only allowed when trailing commas are enabled
2097  if (!(parseFlags & kParseTrailingCommasFlag) && src == IterativeParsingElementDelimiterState) {
2100  }
2101  // Get element count.
2102  SizeType c = *stack_.template Pop<SizeType>(1);
2103  // If the array is not empty, count the last element.
2104  if (src == IterativeParsingElementState)
2105  ++c;
2106  // Restore the state.
2107  IterativeParsingState n = static_cast<IterativeParsingState>(*stack_.template Pop<SizeType>(1));
2108  // Transit to Finish state if this is the topmost scope.
2109  if (n == IterativeParsingStartState)
2111  // Call handler
2112  bool hr = handler.EndArray(c);
2113  // On handler short circuits the parsing.
2114  if (!hr) {
2117  }
2118  else {
2119  is.Take();
2120  return n;
2121  }
2122  }
2123 
2124  default:
2125  // This branch is for IterativeParsingValueState actually.
2126  // Use `default:` rather than
2127  // `case IterativeParsingValueState:` is for code coverage.
2128 
2129  // The IterativeParsingStartState is not enumerated in this switch-case.
2130  // It is impossible for that case. And it can be caught by following assertion.
2131 
2132  // The IterativeParsingFinishState is not enumerated in this switch-case either.
2133  // It is a "derivative" state which cannot triggered from Predict() directly.
2134  // Therefore it cannot happen here. And it can be caught by following assertion.
2136 
2137  // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.
2138  ParseValue<parseFlags>(is, handler);
2139  if (HasParseError()) {
2141  }
2143  }
2144  }
Invalid value.
Definition: error.h:70
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
Parsing was terminated.
Definition: error.h:88
Missing a name for object member.
Definition: error.h:72
Allow trailing commas at the end of objects and arrays.
Definition: reader.h:154
#define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset)
Macro to indicate a parse error.
Definition: reader.h:99
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
Definition: reader.h:680
std::void_t< T > n
IterativeParsingState
Definition: reader.h:1754
internal::Stack< StackAllocator > stack_
A stack for storing decoded string temporarily during non-destructive parsing.
Definition: reader.h:2211
static msg_handler handler
Definition: qglobal.cpp:234

Member Data Documentation

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
const size_t GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::kDefaultStackCapacity = 256
staticprivate

Default stack capacity in bytes for storing a single decoded string.

Definition at line 2210 of file reader.h.

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
ParseResult GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::parseResult_
private

Definition at line 2212 of file reader.h.

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
internal::Stack<StackAllocator> GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::stack_
private

A stack for storing decoded string temporarily during non-destructive parsing.

Definition at line 2211 of file reader.h.

template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
IterativeParsingState GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::state_
private

Definition at line 2213 of file reader.h.


The documentation for this class was generated from the following files: