mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-14 05:07:05 +01:00
pugixml 1.9 update
This commit is contained in:
@ -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 <>
|
||||
|
@ -47,9 +47,10 @@ namespace Grid
|
||||
class XmlWriter: public Writer<XmlWriter>
|
||||
{
|
||||
public:
|
||||
XmlWriter(const std::string &fileName,std::string toplev = std::string("grid") );
|
||||
XmlWriter(const std::string &fileName, std::string toplev = std::string("grid") );
|
||||
virtual ~XmlWriter(void);
|
||||
void push(const std::string &s);
|
||||
void pushXmlString(const std::string &s);
|
||||
void pop(void);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const U &x);
|
||||
@ -65,8 +66,8 @@ namespace Grid
|
||||
class XmlReader: public Reader<XmlReader>
|
||||
{
|
||||
public:
|
||||
XmlReader(const char *xmlstring,std::string toplev = std::string("grid") );
|
||||
XmlReader(const std::string &fileName,std::string toplev = std::string("grid") );
|
||||
XmlReader(const char *xmlstring, std::string toplev = std::string("grid") );
|
||||
XmlReader(const std::string &fileName, std::string toplev = std::string("grid") );
|
||||
virtual ~XmlReader(void) = default;
|
||||
bool push(const std::string &s);
|
||||
void pop(void);
|
||||
@ -75,6 +76,8 @@ namespace Grid
|
||||
void readDefault(const std::string &s, U &output);
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, std::vector<U> &output);
|
||||
private:
|
||||
void initDoc(const std::string &toplev);
|
||||
private:
|
||||
pugi::xml_document doc_;
|
||||
pugi::xml_node node_;
|
||||
|
Reference in New Issue
Block a user