Integrating the new 3-stage approach.

This commit is contained in:
Daniel Lemire
2018-09-25 17:26:58 -04:00
parent cb26dc9c7b
commit dee1bbe54e
3 changed files with 25 additions and 2 deletions
+21 -2
View File
@@ -44,8 +44,9 @@ void deallocate_ParsedJson(ParsedJson *pj_ptr) {
delete pj_ptr;
}
// parse a document found in buf, need to preallocate ParsedJson.
bool json_parse(const u8 *buf, size_t len, ParsedJson &pj) {
// parse a document found in buf, need to preallocate ParsedJson.
// this can probably be considered a legacy function at this point.
bool json_parse_4stages(const u8 *buf, size_t len, ParsedJson &pj) {
if (pj.bytecapacity < len) {
std::cerr << "Your ParsedJson cannot support documents that big: " << len
<< std::endl;
@@ -63,3 +64,21 @@ bool json_parse(const u8 *buf, size_t len, ParsedJson &pj) {
}
return isok;
}
// parse a document found in buf, need to preallocate ParsedJson.
bool json_parse(const u8 *buf, size_t len, ParsedJson &pj) {
if (pj.bytecapacity < len) {
std::cerr << "Your ParsedJson cannot support documents that big: " << len
<< std::endl;
return false;
}
bool isok = find_structural_bits(buf, len, pj);
if (isok) {
isok = flatten_indexes(len, pj);
}
if (isok) {
isok = unified_machine(buf, len, pj);
}
return isok;
}