}
doc_ = new Document(context_->myDoc);
- // This is to indicate to release_underlying that we took the
+ // This is to indicate to release_underlying() that we took the
// ownership on the doc.
context_->myDoc = nullptr;
- //Free the parse context, but keep the document alive so people can navigate the DOM tree:
- //TODO: Why not keep the context alive too?
+ // Free the parser context because it's not needed anymore,
+ // but keep the document alive so people can navigate the DOM tree:
Parser::release_underlying();
}
xmlResetLastError();
context_ = xmlCreatePushParserCtxt(
- 0, // Setting those two parameters to 0 force the parser
- 0, // to create a document while parsing.
- 0, // chunk
- 0, // size
- 0); // no filename for fetching external entities
+ nullptr, // Setting those two parameters to nullptr force the parser
+ nullptr, // to create a document while parsing.
+ nullptr, // chunk
+ 0, // size
+ nullptr); // no filename for fetching external entities
if(!context_)
{
initialize_context();
- //TODO: Shouldn't we use a Glib::ustring here, and some alternative to std::getline()?
+ // std::string or Glib::ustring?
+ // Output from the XML parser is UTF-8 encoded.
+ // But the istream "in" is input, i.e. an XML file. It can use any encoding.
+ // If it's not UTF-8, the file itself must contain information about which
+ // encoding it uses. See the XML specification. Thus use std::string.
int firstParseError = XML_ERR_OK;
std::string line;
while(std::getline(in, line))
firstParseError = parseError;
}
- const int parseError = xmlParseChunk(context_, 0, 0, 1 /* last chunk */);
+ const int parseError = xmlParseChunk(context_, nullptr, 0, 1 /* last chunk */);
if (parseError != XML_ERR_OK && firstParseError == XML_ERR_OK)
firstParseError = parseError;
}
doc_ = new Document(context_->myDoc);
- // This is to indicate to release_underlying that we took the
+ // This is to indicate to release_underlying() that we took the
// ownership on the doc.
context_->myDoc = nullptr;
-
- //Free the parse context, but keep the document alive so people can navigate the DOM tree:
- //TODO: Why not keep the context alive too?
+ // Free the parser context because it's not needed anymore,
+ // but keep the document alive so people can navigate the DOM tree:
Parser::release_underlying();
}