1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-07-31 11:47:06 +01:00

pugixml 1.9 update

This commit is contained in:
2018-04-06 16:17:22 +01:00
parent f089bf5629
commit eddf023b8a
7 changed files with 1935 additions and 1590 deletions

View File

@@ -54,6 +54,11 @@ void XmlWriter::push(const string &s)
node_ = node_.append_child(s.c_str());
}
void XmlWriter::pushXmlString(const std::string &s)
{
}
void XmlWriter::pop(void)
{
node_ = node_.parent();
@@ -65,40 +70,47 @@ std::string XmlWriter::XmlString(void)
return oss.str();
}
XmlReader::XmlReader(const char *xmlstring,string toplev) : fileName_("")
{
pugi::xml_parse_result result;
result = doc_.load_string(xmlstring);
if ( !result ) {
cerr << "XML error description (from char *): " << result.description() << "\nXML\n"<< xmlstring << "\n";
cerr << "XML error offset (from char *) " << result.offset << "\nXML\n"<< xmlstring <<"\n";
abort();
}
if ( toplev == std::string("") ) {
node_ = doc_;
} else {
node_ = doc_.child(toplev.c_str());
}
}
// Reader implementation ///////////////////////////////////////////////////////
XmlReader::XmlReader(const string &fileName,string toplev) : fileName_(fileName)
void XmlReader::initDoc(const std::string &toplev)
{
pugi::xml_parse_result result;
result = doc_.load_file(fileName_.c_str());
if ( !result ) {
cerr << "XML error description: " << result.description() <<" "<< fileName_ <<"\n";
cerr << "XML error offset : " << result.offset <<" "<< fileName_ <<"\n";
abort();
}
if ( toplev == std::string("") ) {
node_ = doc_;
node_ = doc_;
} else {
node_ = doc_.child(toplev.c_str());
}
}
bool XmlReader::push(const string &s)
XmlReader::XmlReader(const char *xmlstring, const std::string toplev)
: fileName_("")
{
auto result = doc_.load_string(xmlstring);
if ( !result ) {
std::cerr << "XML error description (from char *): "
<< result.description() << "\nXML\n"<< xmlstring << "\n";
std::cerr << "XML error offset (from char *) "
<< result.offset << "\nXML\n"<< xmlstring << std::endl;
abort();
}
initDoc(toplev);
}
XmlReader::XmlReader(const std::string &fileName, std::string toplev)
: fileName_(fileName)
{
auto result = doc_.load_file(fileName_.c_str());
if ( !result ) {
std::cerr << "XML error description: "
<< result.description() <<" "<< fileName_ <<"\n";
std::cerr << "XML error offset : "
<< result.offset <<" "<< fileName_ << std::endl;
abort();
}
initDoc(toplev);
}
bool XmlReader::push(const std::string &s)
{
if (node_.child(s.c_str()))
{
@@ -129,7 +141,6 @@ bool XmlReader::nextElement(const std::string &s)
{
return false;
}
}
template <>