6 #ifndef JSON_READER_H_INCLUDED 7 #define JSON_READER_H_INCLUDED 9 #if !defined(JSON_IS_AMALGAMATION) 10 #include "json_features.h" 12 #endif // if !defined(JSON_IS_AMALGAMATION) 21 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 23 #pragma warning(disable : 4251) 24 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 40 using Location =
const Char*;
48 ptrdiff_t offset_start;
49 ptrdiff_t offset_limit;
77 bool parse(
const std::string& document,
Value& root,
78 bool collectComments =
true);
96 bool parse(
const char* beginDoc,
const char* endDoc,
Value& root,
97 bool collectComments =
true);
101 bool parse(IStream& is,
Value& root,
bool collectComments =
true);
111 JSONCPP_DEPRECATED(
"Use getFormattedErrorMessages() instead.")
112 String getFormatedErrorMessages()
const;
121 String getFormattedErrorMessages()
const;
130 std::vector<StructuredError> getStructuredErrors()
const;
139 bool pushError(
const Value& value,
const String& message);
149 bool pushError(
const Value& value,
const String& message,
const Value& extra);
160 tokenEndOfStream = 0,
171 tokenMemberSeparator,
190 using Errors = std::deque<ErrorInfo>;
192 bool readToken(Token& token);
194 bool match(
const Char* pattern,
int patternLength);
196 bool readCStyleComment();
197 bool readCppStyleComment();
201 bool readObject(Token& token);
202 bool readArray(Token& token);
203 bool decodeNumber(Token& token);
204 bool decodeNumber(Token& token,
Value& decoded);
205 bool decodeString(Token& token);
206 bool decodeString(Token& token, String& decoded);
207 bool decodeDouble(Token& token);
208 bool decodeDouble(Token& token,
Value& decoded);
209 bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
210 unsigned int& unicode);
211 bool decodeUnicodeEscapeSequence(Token& token, Location& current,
212 Location end,
unsigned int& unicode);
213 bool addError(
const String& message, Token& token, Location extra =
nullptr);
214 bool recoverFromError(TokenType skipUntilToken);
215 bool addErrorAndRecover(
const String& message, Token& token,
216 TokenType skipUntilToken);
217 void skipUntilSpace();
218 Value& currentValue();
220 void getLocationLineAndColumn(Location location,
int& line,
222 String getLocationLineAndColumn(Location location)
const;
224 void skipCommentTokens(Token& token);
226 static bool containsNewLine(Location begin, Location end);
227 static String normalizeEOL(Location begin, Location end);
229 using Nodes = std::stack<Value*>;
236 Location lastValueEnd_{};
238 String commentsBefore_;
240 bool collectComments_{};
264 virtual bool parse(
char const* beginDoc,
char const* endDoc,
Value* root,
267 class JSON_API Factory {
269 virtual ~Factory() =
default;
273 virtual CharReader* newCharReader()
const = 0;
349 Value& operator[](
const String& key);
402 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 404 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) 406 #endif // JSON_READER_H_INCLUDED Json::Value settings_
Configuration of this builder.
Definition: reader.h:335
Represents a JSON value.
Definition: value.h:194
Configuration passed to reader and writer.
Definition: json_features.h:22
JSON_API IStream & operator>>(IStream &, Value &)
Read from 'sin' into 'root'.
An error tagged with where in the JSON text it was encountered.
Definition: reader.h:47
Build a CharReader implementation.
Definition: reader.h:289
JSON (JavaScript Object Notation).
Definition: allocator.h:15
CommentPlacement
Definition: value.h:119
bool JSON_API parseFromStream(CharReader::Factory const &, IStream &, Value *root, String *errs)
Consume entire stream and use its begin/end.
Unserialize a JSON document into a Value.
Definition: reader.h:37
Interface for reading JSON from a char array.
Definition: reader.h:245