6#ifndef NIM_CPP_WRAPPER_UTIL_JSON_READER_H_INCLUDED
7#define NIM_CPP_WRAPPER_UTIL_JSON_READER_H_INCLUDED
9#if !defined(JSON_IS_AMALGAMATION)
10#include "json_features.h"
21#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
23#pragma warning(disable : 4251)
40 using Location =
const Char*;
48 ptrdiff_t offset_start;
49 ptrdiff_t offset_limit;
75 bool parse(
const std::string& document,
Value& root,
bool collectComments =
true);
93 bool parse(
const char* beginDoc,
const char* endDoc,
Value& root,
bool collectComments =
true);
97 bool parse(IStream& is,
Value& root,
bool collectComments =
true);
107 String getFormatedErrorMessages()
const;
116 String getFormattedErrorMessages()
const;
125 std::vector<StructuredError> getStructuredErrors()
const;
134 bool pushError(
const Value& value,
const String& message);
144 bool pushError(
const Value& value,
const String& message,
const Value& extra);
155 tokenEndOfStream = 0,
166 tokenMemberSeparator,
185 using Errors = std::deque<ErrorInfo>;
187 bool readToken(Token& token);
189 bool match(
const Char* pattern,
int patternLength);
191 bool readCStyleComment();
192 bool readCppStyleComment();
196 bool readObject(Token& token);
197 bool readArray(Token& token);
198 bool decodeNumber(Token& token);
199 bool decodeNumber(Token& token, Value& decoded);
200 bool decodeString(Token& token);
201 bool decodeString(Token& token, String& decoded);
202 bool decodeDouble(Token& token);
203 bool decodeDouble(Token& token, Value& decoded);
204 bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
unsigned int& unicode);
205 bool decodeUnicodeEscapeSequence(Token& token, Location& current, Location end,
unsigned int& unicode);
206 bool addError(
const String& message, Token& token, Location extra =
nullptr);
207 bool recoverFromError(TokenType skipUntilToken);
208 bool addErrorAndRecover(
const String& message, Token& token, TokenType skipUntilToken);
209 void skipUntilSpace();
210 Value& currentValue();
212 void getLocationLineAndColumn(Location location,
int& line,
int& column)
const;
213 String getLocationLineAndColumn(Location location)
const;
214 void addComment(Location begin, Location end, CommentPlacement placement);
215 void skipCommentTokens(Token& token);
217 static bool containsNewLine(Location begin, Location end);
218 static String normalizeEOL(Location begin, Location end);
220 using Nodes = std::stack<Value*>;
227 Location lastValueEnd_{};
229 String commentsBefore_;
231 bool collectComments_{};
255 virtual bool parse(
char const* beginDoc,
char const* endDoc,
Value* root, String* errs) = 0;
336 Value& operator[](
const String& key);
382JSON_API IStream& operator>>(IStream&,
Value&);
389#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
virtual CharReader * newCharReader() const =0
Allocate a CharReader via operator new().
Build a CharReader implementation.
Definition: reader.h:279
nim_cpp_wrapper_util::Json::Value settings_
Definition: reader.h:322
virtual bool parse(char const *beginDoc, char const *endDoc, Value *root, String *errs)=0
Read a Value from a JSON document. The document must be a UTF-8 encoded string containing the documen...
Configuration passed to reader and writer. This configuration object can be used to force the Reader ...
Definition: json_features.h:22
Unserialize a JSON document into a Value.
Definition: reader.h:37
Represents a JSON value.
Definition: value.h:196
JSON (JavaScript Object Notation).
Definition: allocator.h:14
An error tagged with where in the JSON text it was encountered.
Definition: reader.h:47