De-templatize stage2::structural_parser

This commit is contained in:
John Keiser
2020-08-03 16:59:52 -07:00
parent ee6647ce40
commit ec28acba3d
6 changed files with 121 additions and 175 deletions
+6 -10
View File
@@ -114,19 +114,15 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
}
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
if (auto error = stage2::structural_parser<stage2::tape_builder>::parse<false>(*this, _doc)) { return error; }
// If we didn't make it to the end, it's an error
if ( next_structural_index != n_structural_indexes ) {
logger::log_string("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
return TAPE_ERROR;
}
return SUCCESS;
doc = &_doc;
stage2::tape_builder builder(*doc);
return stage2::structural_parser::parse<false>(*this, builder);
}
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
return stage2::structural_parser<stage2::tape_builder>::parse<true>(*this, _doc);
doc = &_doc;
stage2::tape_builder builder(_doc);
return stage2::structural_parser::parse<true>(*this, builder);
}
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {