1 #ifndef CPPTL_JSON_READER_H_INCLUDED
2 # define CPPTL_JSON_READER_H_INCLUDED
42 bool parse(
const std::string &document,
44 bool collectComments =
true );
56 bool parse(
const char *beginDoc,
const char *endDoc,
58 bool collectComments =
true );
62 bool parse( std::istream &is,
64 bool collectComments =
true );
71 std::string getFormatedErrorMessages()
const;
104 std::string message_;
108 typedef std::deque<ErrorInfo> Errors;
110 bool expectToken( TokenType type, Token &token,
const char *message );
111 bool readToken( Token &token );
113 bool match( Location pattern,
116 bool readCStyleComment();
117 bool readCppStyleComment();
121 bool readObject( Token &token );
122 bool readArray( Token &token );
123 bool decodeNumber( Token &token );
124 bool decodeString( Token &token );
125 bool decodeString( Token &token, std::string &decoded );
126 bool decodeDouble( Token &token );
127 bool decodeUnicodeCodePoint( Token &token,
130 unsigned int &unicode );
131 bool decodeUnicodeEscapeSequence( Token &token,
134 unsigned int &unicode );
135 bool addError(
const std::string &message,
137 Location extra = 0 );
138 bool recoverFromError( TokenType skipUntilToken );
139 bool addErrorAndRecover(
const std::string &message,
141 TokenType skipUntilToken );
142 void skipUntilSpace();
143 Value ¤tValue();
145 void getLocationLineAndColumn( Location location,
148 std::string getLocationLineAndColumn( Location location )
const;
149 void addComment( Location begin,
152 void skipCommentTokens( Token &token );
154 typedef std::stack<Value *> Nodes;
157 std::string document_;
161 Location lastValueEnd_;
163 std::string commentsBefore_;
165 bool collectComments_;
192 std::istream&
operator>>( std::istream&, Value& );
196 #endif // CPPTL_JSON_READER_H_INCLUDED