Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
Json::Reader Class Reference

Unserialize a JSON document into a Value. More...

#include <reader.h>

List of all members.

Classes

class  ErrorInfo
class  Token

Public Types

typedef char Char
typedef const CharLocation

Public Member Functions

std::string getFormatedErrorMessages () const
 Returns a user friendly string that list errors in the parsed document.
bool parse (const std::string &document, Value &root, bool collectComments=true)
 Read a Value from a JSON document.
bool parse (const char *beginDoc, const char *endDoc, Value &root, bool collectComments=true)
 Read a Value from a JSON document.
bool parse (std::istream &is, Value &root, bool collectComments=true)
 Parse from input stream.
 Reader ()
 Constructs a Reader allowing all features for parsing.
 Reader (const Features &features)
 Constructs a Reader allowing the specified feature set for parsing.

Private Types

typedef std::deque< ErrorInfoErrors
typedef std::stack< Value * > Nodes
enum  TokenType {
  tokenEndOfStream = 0, tokenObjectBegin, tokenObjectEnd, tokenArrayBegin,
  tokenArrayEnd, tokenString, tokenNumber, tokenTrue,
  tokenFalse, tokenNull, tokenArraySeparator, tokenMemberSeparator,
  tokenComment, tokenError
}

Private Member Functions

void addComment (Location begin, Location end, CommentPlacement placement)
bool addError (const std::string &message, Token &token, Location extra=0)
bool addErrorAndRecover (const std::string &message, Token &token, TokenType skipUntilToken)
ValuecurrentValue ()
bool decodeDouble (Token &token)
bool decodeNumber (Token &token)
bool decodeString (Token &token)
bool decodeString (Token &token, std::string &decoded)
bool decodeUnicodeCodePoint (Token &token, Location &current, Location end, unsigned int &unicode)
bool decodeUnicodeEscapeSequence (Token &token, Location &current, Location end, unsigned int &unicode)
bool expectToken (TokenType type, Token &token, const char *message)
void getLocationLineAndColumn (Location location, int &line, int &column) const
std::string getLocationLineAndColumn (Location location) const
Char getNextChar ()
bool match (Location pattern, int patternLength)
bool readArray (Token &token)
bool readComment ()
bool readCppStyleComment ()
bool readCStyleComment ()
void readNumber ()
bool readObject (Token &token)
bool readString ()
bool readToken (Token &token)
bool readValue ()
bool recoverFromError (TokenType skipUntilToken)
void skipCommentTokens (Token &token)
void skipSpaces ()
void skipUntilSpace ()

Private Attributes

Location begin_
bool collectComments_
std::string commentsBefore_
Location current_
std::string document_
Location end_
Errors errors_
Features features_
ValuelastValue_
Location lastValueEnd_
Nodes nodes_

Detailed Description

Unserialize a JSON document into a Value.

Definition at line 16 of file reader.h.


Member Typedef Documentation

typedef char Json::Reader::Char

Definition at line 19 of file reader.h.

typedef std::deque<ErrorInfo> Json::Reader::Errors [private]

Definition at line 108 of file reader.h.

typedef const Char* Json::Reader::Location

Definition at line 20 of file reader.h.

typedef std::stack<Value *> Json::Reader::Nodes [private]

Definition at line 154 of file reader.h.


Member Enumeration Documentation

enum Json::Reader::TokenType [private]
Enumerator:
tokenEndOfStream 
tokenObjectBegin 
tokenObjectEnd 
tokenArrayBegin 
tokenArrayEnd 
tokenString 
tokenNumber 
tokenTrue 
tokenFalse 
tokenNull 
tokenArraySeparator 
tokenMemberSeparator 
tokenComment 
tokenError 

Definition at line 74 of file reader.h.


Constructor & Destructor Documentation

Constructs a Reader allowing all features for parsing.

Definition at line 109 of file json_reader.cpp.

Json::Reader::Reader ( const Features features)

Constructs a Reader allowing the specified feature set for parsing.

Definition at line 115 of file json_reader.cpp.


Member Function Documentation

void Json::Reader::addComment ( Location  begin,
Location  end,
CommentPlacement  placement 
) [private]

Definition at line 406 of file json_reader.cpp.

bool Json::Reader::addError ( const std::string &  message,
Token token,
Location  extra = 0 
) [private]

Definition at line 760 of file json_reader.cpp.

bool Json::Reader::addErrorAndRecover ( const std::string &  message,
Token token,
TokenType  skipUntilToken 
) [private]

Definition at line 791 of file json_reader.cpp.

Definition at line 801 of file json_reader.cpp.

bool Json::Reader::decodeDouble ( Token token) [private]

Definition at line 620 of file json_reader.cpp.

bool Json::Reader::decodeNumber ( Token token) [private]

Definition at line 582 of file json_reader.cpp.

bool Json::Reader::decodeString ( Token token) [private]

Definition at line 647 of file json_reader.cpp.

bool Json::Reader::decodeString ( Token token,
std::string &  decoded 
) [private]

Definition at line 658 of file json_reader.cpp.

bool Json::Reader::decodeUnicodeCodePoint ( Token token,
Location current,
Location  end,
unsigned int &  unicode 
) [private]

Definition at line 704 of file json_reader.cpp.

bool Json::Reader::decodeUnicodeEscapeSequence ( Token token,
Location current,
Location  end,
unsigned int &  unicode 
) [private]

Definition at line 734 of file json_reader.cpp.

bool Json::Reader::expectToken ( TokenType  type,
Token token,
const char *  message 
) [private]

Definition at line 264 of file json_reader.cpp.

Returns a user friendly string that list errors in the parsed document.

Returns:
Formatted error message with the list of errors with their location in the parsed document. An empty string is returned if no error occurred during parsing.

Definition at line 858 of file json_reader.cpp.

void Json::Reader::getLocationLineAndColumn ( Location  location,
int &  line,
int &  column 
) const [private]

Definition at line 817 of file json_reader.cpp.

std::string Json::Reader::getLocationLineAndColumn ( Location  location) const [private]

Definition at line 847 of file json_reader.cpp.

Definition at line 808 of file json_reader.cpp.

bool Json::Reader::match ( Location  pattern,
int  patternLength 
) [private]

Definition at line 363 of file json_reader.cpp.

bool Json::Reader::parse ( const std::string &  document,
Value root,
bool  collectComments = true 
)

Read a Value from a JSON document.

Parameters:
documentUTF-8 encoded string containing the document to read.
root[out] Contains the root value of the document if it was successfully parsed.
collectCommentstrue to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false.
Returns:
true if the document was successfully parsed, false if an error occurred.

Definition at line 122 of file json_reader.cpp.

bool Json::Reader::parse ( const char *  beginDoc,
const char *  endDoc,
Value root,
bool  collectComments = true 
)

Read a Value from a JSON document.

Parameters:
documentUTF-8 encoded string containing the document to read.
root[out] Contains the root value of the document if it was successfully parsed.
collectCommentstrue to collect comment and allow writing them back during serialization, false to discard comments. This parameter is ignored if Features::allowComments_ is false.
Returns:
true if the document was successfully parsed, false if an error occurred.

Definition at line 151 of file json_reader.cpp.

bool Json::Reader::parse ( std::istream &  is,
Value root,
bool  collectComments = true 
)

Parse from input stream.

See also:
Json::operator>>(std::istream&, Json::Value&).

Definition at line 134 of file json_reader.cpp.

bool Json::Reader::readArray ( Token token) [private]

Definition at line 539 of file json_reader.cpp.

bool Json::Reader::readComment ( ) [private]

Definition at line 378 of file json_reader.cpp.

Definition at line 439 of file json_reader.cpp.

bool Json::Reader::readCStyleComment ( ) [private]

Definition at line 426 of file json_reader.cpp.

void Json::Reader::readNumber ( ) [private]

Definition at line 452 of file json_reader.cpp.

bool Json::Reader::readObject ( Token token) [private]

Definition at line 480 of file json_reader.cpp.

bool Json::Reader::readString ( ) [private]

Definition at line 464 of file json_reader.cpp.

bool Json::Reader::readToken ( Token token) [private]

Definition at line 274 of file json_reader.cpp.

bool Json::Reader::readValue ( ) [private]

Definition at line 195 of file json_reader.cpp.

bool Json::Reader::recoverFromError ( TokenType  skipUntilToken) [private]

Definition at line 774 of file json_reader.cpp.

void Json::Reader::skipCommentTokens ( Token token) [private]

Definition at line 246 of file json_reader.cpp.

void Json::Reader::skipSpaces ( ) [private]

Definition at line 349 of file json_reader.cpp.

void Json::Reader::skipUntilSpace ( ) [private]

Member Data Documentation

Definition at line 158 of file reader.h.

Definition at line 165 of file reader.h.

std::string Json::Reader::commentsBefore_ [private]

Definition at line 163 of file reader.h.

Definition at line 160 of file reader.h.

std::string Json::Reader::document_ [private]

Definition at line 157 of file reader.h.

Definition at line 159 of file reader.h.

Definition at line 156 of file reader.h.

Definition at line 164 of file reader.h.

Definition at line 162 of file reader.h.

Definition at line 161 of file reader.h.

Definition at line 155 of file reader.h.


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


bwi_tools
Author(s): Piyush Khandelwal
autogenerated on Thu Jun 6 2019 17:57:27