[xml_parser] Allow element handlers to stop parsing
This commit is contained in:
parent
ced9929ca6
commit
d28e64aff0
@ -19,13 +19,16 @@ xml_parser::parse(std::string const &backup_file, bool quiet)
|
|||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
size_t input_length = get_file_length(backup_file);
|
size_t input_length = get_file_length(backup_file);
|
||||||
|
|
||||||
while (!in.eof()) {
|
XML_Error error_code = XML_ERROR_NONE;
|
||||||
|
while (!in.eof() && error_code == XML_ERROR_NONE) {
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
in.read(buffer, sizeof(buffer));
|
in.read(buffer, sizeof(buffer));
|
||||||
size_t len = in.gcount();
|
size_t len = in.gcount();
|
||||||
int done = in.eof();
|
int done = in.eof();
|
||||||
|
|
||||||
if (!XML_Parse(parser_, buffer, len, done)) {
|
// Do not throw while normally aborted by element handlers
|
||||||
|
if (!XML_Parse(parser_, buffer, len, done) &&
|
||||||
|
(error_code = XML_GetErrorCode(parser_)) != XML_ERROR_ABORTED) {
|
||||||
ostringstream out;
|
ostringstream out;
|
||||||
out << "Parse error at line "
|
out << "Parse error at line "
|
||||||
<< XML_GetCurrentLineNumber(parser_)
|
<< XML_GetCurrentLineNumber(parser_)
|
||||||
|
Loading…
Reference in New Issue
Block a user