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
 
struct  StructuredError
 An error tagged with where in the JSON text it was encountered. More...
 
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...
 
std::vector< StructuredErrorgetStructuredErrors () const
 Returns a vector of structured erros encounted while parsing. More...
 
bool good () const
 Return whether there are any errors. 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...
 
bool pushError (const Value &value, const std::string &message)
 Add a semantic error message. More...
 
bool pushError (const Value &value, const std::string &message, const Value &extra)
 Add a semantic error message with extra context. 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 decodeDouble (Token &token, Value &decoded)
 
bool decodeNumber (Token &token)
 
bool decodeNumber (Token &token, Value &decoded)
 
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)
 
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.

Deprecated:
Use CharReader and CharReaderBuilder.

Definition at line 1230 of file json.h.

Member Typedef Documentation

typedef char Json::Reader::Char

Definition at line 1232 of file json.h.

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

Definition at line 1387 of file json.h.

typedef const Char* Json::Reader::Location

Definition at line 1233 of file json.h.

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

Definition at line 1428 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 1356 of file json.h.

Constructor & Destructor Documentation

Json::Reader::Reader ( )

Constructs a Reader allowing all features for parsing.

Definition at line 259 of file jsoncpp.cpp.

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

Constructs a Reader allowing the specified feature set for parsing.

Definition at line 264 of file jsoncpp.cpp.

Member Function Documentation

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

Definition at line 561 of file jsoncpp.cpp.

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

Definition at line 943 of file jsoncpp.cpp.

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

Definition at line 965 of file jsoncpp.cpp.

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

Definition at line 972 of file jsoncpp.cpp.

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

Definition at line 775 of file jsoncpp.cpp.

bool Json::Reader::decodeDouble ( Token token,
Value decoded 
)
private

Definition at line 785 of file jsoncpp.cpp.

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

Definition at line 725 of file jsoncpp.cpp.

bool Json::Reader::decodeNumber ( Token token,
Value decoded 
)
private

Definition at line 735 of file jsoncpp.cpp.

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

Definition at line 821 of file jsoncpp.cpp.

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

Definition at line 832 of file jsoncpp.cpp.

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

Definition at line 885 of file jsoncpp.cpp.

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

Definition at line 914 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 1020 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 1024 of file jsoncpp.cpp.

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

Definition at line 980 of file jsoncpp.cpp.

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

Definition at line 1003 of file jsoncpp.cpp.

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

Definition at line 974 of file jsoncpp.cpp.

std::vector< Reader::StructuredError > Json::Reader::getStructuredErrors ( ) const

Returns a vector of structured erros encounted while parsing.

Returns
A (possibly empty) vector of StructuredError objects. Currently only one error can be returned, but the caller should tolerate multiple errors. This can occur if the parser recovers from a non-fatal parse error and then encounters additional errors.

Definition at line 1040 of file jsoncpp.cpp.

bool Json::Reader::good ( ) const

Return whether there are any errors.

Returns
true if there are no errors to report false if errors have occurred.

Definition at line 1090 of file jsoncpp.cpp.

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

Definition at line 507 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 270 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 290 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 277 of file jsoncpp.cpp.

bool Json::Reader::pushError ( const Value value,
const std::string &  message 
)

Add a semantic error message.

Parameters
valueJSON Value location associated with the error
messageThe error message.
Returns
true if the error was successfully added, false if the Value offset exceeds the document size.

Definition at line 1055 of file jsoncpp.cpp.

bool Json::Reader::pushError ( const Value value,
const std::string &  message,
const Value extra 
)

Add a semantic error message with extra context.

Parameters
valueJSON Value location associated with the error
messageThe error message.
extraAdditional JSON Value location to contextualize the error
Returns
true if the error was successfully added, false if either Value offset exceeds the document size.

Definition at line 1072 of file jsoncpp.cpp.

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

Definition at line 687 of file jsoncpp.cpp.

bool Json::Reader::readComment ( )
private

Definition at line 518 of file jsoncpp.cpp.

bool Json::Reader::readCppStyleComment ( )
private

Definition at line 581 of file jsoncpp.cpp.

bool Json::Reader::readCStyleComment ( )
private

Definition at line 572 of file jsoncpp.cpp.

void Json::Reader::readNumber ( )
private

Definition at line 597 of file jsoncpp.cpp.

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

Definition at line 631 of file jsoncpp.cpp.

bool Json::Reader::readString ( )
private

Definition at line 619 of file jsoncpp.cpp.

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

Definition at line 426 of file jsoncpp.cpp.

bool Json::Reader::readValue ( )
private

Definition at line 332 of file jsoncpp.cpp.

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

Definition at line 952 of file jsoncpp.cpp.

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

Definition at line 416 of file jsoncpp.cpp.

void Json::Reader::skipSpaces ( )
private

Definition at line 497 of file jsoncpp.cpp.

void Json::Reader::skipUntilSpace ( )
private

Member Data Documentation

Location Json::Reader::begin_
private

Definition at line 1432 of file json.h.

bool Json::Reader::collectComments_
private

Definition at line 1439 of file json.h.

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

Definition at line 1437 of file json.h.

Location Json::Reader::current_
private

Definition at line 1434 of file json.h.

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

Definition at line 1431 of file json.h.

Location Json::Reader::end_
private

Definition at line 1433 of file json.h.

Errors Json::Reader::errors_
private

Definition at line 1430 of file json.h.

Features Json::Reader::features_
private

Definition at line 1438 of file json.h.

Value* Json::Reader::lastValue_
private

Definition at line 1436 of file json.h.

Location Json::Reader::lastValueEnd_
private

Definition at line 1435 of file json.h.

Nodes Json::Reader::nodes_
private

Definition at line 1429 of file json.h.


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


mission_planning
Author(s): ivan
autogenerated on Thu Nov 12 2015 19:08:20