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

◆ Char

typedef char Json::Reader::Char

Definition at line 1458 of file json.h.

◆ Errors

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

Definition at line 1558 of file json.h.

◆ Location

typedef const Char* Json::Reader::Location

Definition at line 1459 of file json.h.

◆ Nodes

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

Definition at line 1604 of file json.h.

Member Enumeration Documentation

◆ TokenType

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

◆ Reader() [1/2]

Json::Reader::Reader ( )

Constructs a Reader allowing all features for parsing.

Definition at line 270 of file jsoncpp.cpp.

◆ Reader() [2/2]

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

◆ addComment()

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

Definition at line 567 of file jsoncpp.cpp.

◆ addError()

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

Definition at line 936 of file jsoncpp.cpp.

◆ addErrorAndRecover()

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

Definition at line 967 of file jsoncpp.cpp.

◆ currentValue()

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

Definition at line 977 of file jsoncpp.cpp.

◆ decodeDouble()

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

Definition at line 796 of file jsoncpp.cpp.

◆ decodeNumber()

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

Definition at line 743 of file jsoncpp.cpp.

◆ decodeString() [1/2]

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

Definition at line 823 of file jsoncpp.cpp.

◆ decodeString() [2/2]

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

Definition at line 834 of file jsoncpp.cpp.

◆ decodeUnicodeCodePoint()

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

Definition at line 880 of file jsoncpp.cpp.

◆ decodeUnicodeEscapeSequence()

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

Definition at line 910 of file jsoncpp.cpp.

◆ expectToken()

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

Definition at line 425 of file jsoncpp.cpp.

◆ getFormatedErrorMessages()

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.

◆ getFormattedErrorMessages()

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.

◆ getLocationLineAndColumn() [1/2]

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

Definition at line 993 of file jsoncpp.cpp.

◆ getLocationLineAndColumn() [2/2]

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

Definition at line 1023 of file jsoncpp.cpp.

◆ getNextChar()

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

Definition at line 984 of file jsoncpp.cpp.

◆ match()

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

Definition at line 524 of file jsoncpp.cpp.

◆ parse() [1/3]

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.

◆ parse() [2/3]

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.

◆ parse() [3/3]

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.

◆ readArray()

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

Definition at line 700 of file jsoncpp.cpp.

◆ readComment()

bool Json::Reader::readComment ( )
private

Definition at line 539 of file jsoncpp.cpp.

◆ readCppStyleComment()

bool Json::Reader::readCppStyleComment ( )
private

Definition at line 600 of file jsoncpp.cpp.

◆ readCStyleComment()

bool Json::Reader::readCStyleComment ( )
private

Definition at line 587 of file jsoncpp.cpp.

◆ readNumber()

void Json::Reader::readNumber ( )
private

Definition at line 613 of file jsoncpp.cpp.

◆ readObject()

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

Definition at line 641 of file jsoncpp.cpp.

◆ readString()

bool Json::Reader::readString ( )
private

Definition at line 625 of file jsoncpp.cpp.

◆ readToken()

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

Definition at line 435 of file jsoncpp.cpp.

◆ readValue()

bool Json::Reader::readValue ( )
private

Definition at line 356 of file jsoncpp.cpp.

◆ recoverFromError()

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

Definition at line 950 of file jsoncpp.cpp.

◆ skipCommentTokens()

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

Definition at line 407 of file jsoncpp.cpp.

◆ skipSpaces()

void Json::Reader::skipSpaces ( )
private

Definition at line 510 of file jsoncpp.cpp.

◆ skipUntilSpace()

void Json::Reader::skipUntilSpace ( )
private

Member Data Documentation

◆ begin_

Location Json::Reader::begin_
private

Definition at line 1608 of file json.h.

◆ collectComments_

bool Json::Reader::collectComments_
private

Definition at line 1615 of file json.h.

◆ commentsBefore_

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

Definition at line 1613 of file json.h.

◆ current_

Location Json::Reader::current_
private

Definition at line 1610 of file json.h.

◆ document_

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

Definition at line 1607 of file json.h.

◆ end_

Location Json::Reader::end_
private

Definition at line 1609 of file json.h.

◆ errors_

Errors Json::Reader::errors_
private

Definition at line 1606 of file json.h.

◆ features_

Features Json::Reader::features_
private

Definition at line 1614 of file json.h.

◆ lastValue_

Value* Json::Reader::lastValue_
private

Definition at line 1612 of file json.h.

◆ lastValueEnd_

Location Json::Reader::lastValueEnd_
private

Definition at line 1611 of file json.h.

◆ nodes_

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 Dec 12 2022 03:20:10