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);
100 bool parse(
IStream& is,
Value& root,
bool collectComments =
true);
111 String getFormatedErrorMessages() const;
120 String getFormattedErrorMessages() const;
138 bool pushError(const
Value& value, const
String& message);
148 bool pushError(const
Value& value, const
String& message, const
Value& extra);
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_{};
virtual bool parse(char const *beginDoc, char const *endDoc, Value *root, String *errs)=0
Read a Value from a JSON document.
bool parseFromStream(CharReader::Factory const &, IStream &, Value *root, String *errs)
Consume entire stream and use its begin/end.