6#ifndef JSON_READER_H_INCLUDED
7#define JSON_READER_H_INCLUDED
9#if !defined(JSON_IS_AMALGAMATION)
21#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
23#pragma warning(disable : 4251)
76 bool parse(
const std::string& document,
Value& root,
77 bool collectComments =
true);
95 bool parse(
const char* beginDoc,
const char* endDoc,
Value& root,
96 bool collectComments =
true);
111 String getFormatedErrorMessages() const;
159 tokenEndOfStream = 0,
170 tokenMemberSeparator,
189 using Errors = std::deque<ErrorInfo>;
191 bool readToken(Token& token);
193 bool match(
const Char* pattern,
int patternLength);
195 bool readCStyleComment();
196 bool readCppStyleComment();
200 bool readObject(Token& token);
201 bool readArray(Token& token);
202 bool decodeNumber(Token& token);
203 bool decodeNumber(Token& token, Value& decoded);
204 bool decodeString(Token& token);
205 bool decodeString(Token& token, String& decoded);
206 bool decodeDouble(Token& token);
207 bool decodeDouble(Token& token, Value& decoded);
208 bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
209 unsigned int& unicode);
210 bool decodeUnicodeEscapeSequence(Token& token, Location& current,
211 Location end,
unsigned int& unicode);
212 bool addError(
const String& message, Token& token, Location extra =
nullptr);
213 bool recoverFromError(TokenType skipUntilToken);
214 bool addErrorAndRecover(
const String& message, Token& token,
215 TokenType skipUntilToken);
216 void skipUntilSpace();
217 Value& currentValue();
219 void getLocationLineAndColumn(Location location,
int& line,
221 String getLocationLineAndColumn(Location location)
const;
222 void addComment(Location begin, Location end, CommentPlacement placement);
223 void skipCommentTokens(Token& token);
225 static bool containsNewLine(Location begin, Location end);
226 static String normalizeEOL(Location begin, Location end);
228 using Nodes = std::stack<Value*>;
235 Location lastValueEnd_{};
239 bool collectComments_{};
263 virtual bool parse(
char const* beginDoc,
char const* endDoc,
Value* root,
401#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
virtual ~Factory()=default
virtual CharReader * newCharReader() const =0
Allocate a CharReader via operator new().
static void setDefaults(Json::Value *settings)
Called by ctor, but you can use this to reset settings_.
Value & operator[](const String &key)
A simple way to update a specific setting.
CharReader * newCharReader() const override
Allocate a CharReader via operator new().
static void strictMode(Json::Value *settings)
Same as old Features::strictMode().
Json::Value settings_
Configuration of this builder.
~CharReaderBuilder() override
bool validate(Json::Value *invalid) const
Interface for reading JSON from a char array.
virtual ~CharReader()=default
virtual bool parse(char const *beginDoc, char const *endDoc, Value *root, String *errs)=0
Read a Value from a JSON document.
Configuration passed to reader and writer.
Reader()
Constructs a Reader allowing all features for parsing.
bool pushError(const Value &value, const String &message)
Add a semantic error message.
bool good() const
Return whether there are any errors.
std::vector< StructuredError > getStructuredErrors() const
Returns a vector of structured errors encountered while parsing.
bool parse(const std::string &document, Value &root, bool collectComments=true)
Read a Value from a JSON document.
String getFormattedErrorMessages() const
Returns a user friendly string that list errors in the parsed document.
#define JSON_API
If defined, indicates that the source file is amalgamated to prevent private header inclusion.
#define JSONCPP_DEPRECATED(message)
JSON (JavaScript Object Notation).
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
IStream & operator>>(IStream &, Value &)
Read from 'sin' into 'root'.
bool parseFromStream(CharReader::Factory const &, IStream &, Value *root, String *errs)
Consume entire stream and use its begin/end.
An error tagged with where in the JSON text it was encountered.