MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / parse

Method parse

Sources/Dependencies/jsoncpp/reader.cpp:183–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181 : features_(features) {}
182
183 bool OurReader::parse(const char* beginDoc, const char* endDoc, Value& root, bool collectComments) {
184 if (!features_.allowComments_) {
185 collectComments = false;
186 }
187
188 begin_ = beginDoc;
189 end_ = endDoc;
190 collectComments_ = collectComments;
191 current_ = begin_;
192 lastValueEnd_ = nullptr;
193 lastValue_ = nullptr;
194 commentsBefore_.clear();
195 errors_.clear();
196 while (!nodes_.empty())
197 nodes_.pop();
198 nodes_.push(&root);
199
200 // skip byte order mark if it exists at the beginning of the UTF-8 text.
201 skipBom(features_.skipBom_);
202 bool successful = readValue();
203 nodes_.pop();
204 Token token;
205 readTokenSkippingComments(token);
206 if (features_.failIfExtra_ && (token.type_ != tokenEndOfStream)) {
207 addError("Extra non-whitespace after JSON value.", token);
208 return false;
209 }
210 if (collectComments_ && !commentsBefore_.empty())
211 root.setComment(commentsBefore_, commentAfter);
212 if (features_.strictRoot_) {
213 if (!root.isArray() && !root.isObject()) {
214 // Set error location to start of doc, ideally should be first token found
215 // in doc
216 token.type_ = tokenError;
217 token.start_ = beginDoc;
218 token.end_ = endDoc;
219 addError("A valid JSON document must be either an array or an object value.", token);
220 return false;
221 }
222 }
223 return successful;
224 }
225
226 bool OurReader::readValue() {
227 // To preserve the old behaviour we cast size_t to int.

Callers 10

parseMethod · 0.45
RequestMetadataMethod · 0.45
RequestGraphicsMethod · 0.45
MigrateGraphicsMethod · 0.45
OnFetchSuccessMethod · 0.45
ProcessInboundFrameMethod · 0.45

Calls 7

popMethod · 0.80
pushMethod · 0.80
setCommentMethod · 0.80
isArrayMethod · 0.80
isObjectMethod · 0.80
clearMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected