6 #ifndef CPPTL_JSON_READER_H_INCLUDED
7 #define CPPTL_JSON_READER_H_INCLUDED
9 #if !defined(JSON_IS_AMALGAMATION)
21 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
23 #pragma warning(disable : 4251)
38 typedef const Char* Location;
46 struct StructuredError {
47 ptrdiff_t offset_start;
48 ptrdiff_t offset_limit;
49 JSONCPP_STRING message;
77 parse(
const std::string& document,
Value& root,
bool collectComments =
true);
97 bool parse(
const char* beginDoc,
100 bool collectComments =
true);
104 bool parse(JSONCPP_ISTREAM& is,
Value& root,
bool collectComments =
true);
116 JSONCPP_STRING getFormatedErrorMessages()
const;
126 JSONCPP_STRING getFormattedErrorMessages()
const;
135 std::vector<StructuredError> getStructuredErrors()
const;
143 bool pushError(
const Value& value,
const JSONCPP_STRING& message);
152 bool pushError(
const Value& value,
const JSONCPP_STRING& message,
const Value& extra);
162 tokenEndOfStream = 0,
173 tokenMemberSeparator,
188 JSONCPP_STRING message_;
192 typedef std::deque<ErrorInfo> Errors;
194 bool readToken(Token& token);
196 bool match(Location pattern,
int patternLength);
198 bool readCStyleComment();
199 bool readCppStyleComment();
203 bool readObject(Token& token);
204 bool readArray(Token& token);
205 bool decodeNumber(Token& token);
206 bool decodeNumber(Token& token,
Value& decoded);
207 bool decodeString(Token& token);
208 bool decodeString(Token& token, JSONCPP_STRING& decoded);
209 bool decodeDouble(Token& token);
210 bool decodeDouble(Token& token,
Value& decoded);
211 bool decodeUnicodeCodePoint(Token& token,
214 unsigned int& unicode);
215 bool decodeUnicodeEscapeSequence(Token& token,
218 unsigned int& unicode);
219 bool addError(
const JSONCPP_STRING& message, Token& token, Location extra = 0);
220 bool recoverFromError(TokenType skipUntilToken);
221 bool addErrorAndRecover(
const JSONCPP_STRING& message,
223 TokenType skipUntilToken);
224 void skipUntilSpace();
225 Value& currentValue();
228 getLocationLineAndColumn(Location location,
int& line,
int& column)
const;
229 JSONCPP_STRING getLocationLineAndColumn(Location location)
const;
231 void skipCommentTokens(Token& token);
233 static bool containsNewLine(Location begin, Location end);
234 static JSONCPP_STRING normalizeEOL(Location begin, Location end);
236 typedef std::stack<Value*> Nodes;
239 JSONCPP_STRING document_;
243 Location lastValueEnd_;
245 JSONCPP_STRING commentsBefore_;
247 bool collectComments_;
273 char const* beginDoc,
char const* endDoc,
274 Value* root, JSONCPP_STRING* errs) = 0;
352 Value& operator[](JSONCPP_STRING key);
375 Value* root, std::
string* errs);
401 JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&,
Value&);
407 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
virtual CharReader * newCharReader() const =0
Allocate a CharReader via operator new().
Build a CharReader implementation.
Json::Value settings_
Configuration of this builder.
Interface for reading JSON from a char array.
virtual bool parse(char const *beginDoc, char const *endDoc, Value *root, JSONCPP_STRING *errs)=0
Read a Value from a JSON document.
Configuration passed to reader and writer.
JSON (JavaScript Object Notation).
class JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") JSON_API Reader
Unserialize a JSON document into a Value.
bool JSON_API parseFromStream(CharReader::Factory const &, JSONCPP_ISTREAM &, Value *root, std::string *errs)
Consume entire stream and use its begin/end.