Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Json::Reader Class Reference

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

#include <json.h>

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

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 1455 of file json.h.

Member Typedef Documentation

typedef char Json::Reader::Char

Definition at line 1458 of file json.h.

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

Definition at line 1558 of file json.h.

typedef const Char* Json::Reader::Location

Definition at line 1459 of file json.h.

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

Definition at line 1604 of file json.h.

Member Enumeration Documentation

Enumerator
tokenEndOfStream 
tokenObjectBegin 
tokenObjectEnd 
tokenArrayBegin 
tokenArrayEnd 
tokenString 
tokenNumber 
tokenTrue 
tokenFalse 
tokenNull 
tokenArraySeparator 
tokenMemberSeparator 
tokenComment 
tokenError 

Definition at line 1524 of file json.h.

Constructor & Destructor Documentation

Json::Reader::Reader ( )

Constructs a Reader allowing all features for parsing.

Definition at line 270 of file jsoncpp.cpp.

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

Constructs a Reader allowing the specified feature set for parsing.

Definition at line 276 of file jsoncpp.cpp.

Member Function Documentation

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

Definition at line 567 of file jsoncpp.cpp.

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

Definition at line 936 of file jsoncpp.cpp.

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

Definition at line 967 of file jsoncpp.cpp.

Value & Json::Reader::currentValue ( )
private

Definition at line 977 of file jsoncpp.cpp.

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

Definition at line 796 of file jsoncpp.cpp.

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

Definition at line 743 of file jsoncpp.cpp.

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

Definition at line 823 of file jsoncpp.cpp.

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

Definition at line 834 of file jsoncpp.cpp.

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

Definition at line 880 of file jsoncpp.cpp.

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

Definition at line 910 of file jsoncpp.cpp.

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

Definition at line 425 of file jsoncpp.cpp.

std::string Json::Reader::getFormatedErrorMessages ( ) const

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.
Deprecated:
Use getFormattedErrorMessages() instead (typo fix).

Definition at line 1035 of file jsoncpp.cpp.

std::string Json::Reader::getFormattedErrorMessages ( ) const

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 1042 of file jsoncpp.cpp.

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

Definition at line 993 of file jsoncpp.cpp.

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

Definition at line 1023 of file jsoncpp.cpp.

Reader::Char Json::Reader::getNextChar ( )
private

Definition at line 984 of file jsoncpp.cpp.

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

Definition at line 524 of file jsoncpp.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 283 of file jsoncpp.cpp.

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

Read a Value from a JSON document.

Parameters
beginDocPointer on the beginning of the UTF-8 encoded string of the document to read.
endDocPointer on the end of the UTF-8 encoded string of the document to read. \ Must be >= beginDoc.
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 312 of file jsoncpp.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 295 of file jsoncpp.cpp.

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

Definition at line 700 of file jsoncpp.cpp.

bool Json::Reader::readComment ( )
private

Definition at line 539 of file jsoncpp.cpp.

bool Json::Reader::readCppStyleComment ( )
private

Definition at line 600 of file jsoncpp.cpp.

bool Json::Reader::readCStyleComment ( )
private

Definition at line 587 of file jsoncpp.cpp.

void Json::Reader::readNumber ( )
private

Definition at line 613 of file jsoncpp.cpp.

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

Definition at line 641 of file jsoncpp.cpp.

bool Json::Reader::readString ( )
private

Definition at line 625 of file jsoncpp.cpp.

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

Definition at line 435 of file jsoncpp.cpp.

bool Json::Reader::readValue ( )
private

Definition at line 356 of file jsoncpp.cpp.

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

Definition at line 950 of file jsoncpp.cpp.

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

Definition at line 407 of file jsoncpp.cpp.

void Json::Reader::skipSpaces ( )
private

Definition at line 510 of file jsoncpp.cpp.

void Json::Reader::skipUntilSpace ( )
private

Member Data Documentation

Location Json::Reader::begin_
private

Definition at line 1608 of file json.h.

bool Json::Reader::collectComments_
private

Definition at line 1615 of file json.h.

std::string Json::Reader::commentsBefore_
private

Definition at line 1613 of file json.h.

Location Json::Reader::current_
private

Definition at line 1610 of file json.h.

std::string Json::Reader::document_
private

Definition at line 1607 of file json.h.

Location Json::Reader::end_
private

Definition at line 1609 of file json.h.

Errors Json::Reader::errors_
private

Definition at line 1606 of file json.h.

Features Json::Reader::features_
private

Definition at line 1614 of file json.h.

Value* Json::Reader::lastValue_
private

Definition at line 1612 of file json.h.

Location Json::Reader::lastValueEnd_
private

Definition at line 1611 of file json.h.

Nodes Json::Reader::nodes_
private

Definition at line 1605 of file json.h.


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


find_object_2d
Author(s): Mathieu Labbe
autogenerated on Mon Jun 10 2019 13:21:32