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

IO: code cleaning and string binary IO fix

This commit is contained in:
2015-12-08 13:53:33 +00:00
parent ab45f029f4
commit d68a72e28b
6 changed files with 71 additions and 49 deletions

View File

@@ -1,8 +1,10 @@
#include <Grid.h>
namespace Grid {
using namespace Grid;
using namespace std;
// Writer implementation ///////////////////////////////////////////////////////
XmlWriter::XmlWriter(const std::string &fileName)
XmlWriter::XmlWriter(const string &fileName)
: fileName_(fileName)
{
node_ = doc_.append_child();
@@ -14,7 +16,7 @@ XmlWriter::~XmlWriter(void)
doc_.save_file(fileName_.c_str(), " ");
}
void XmlWriter::push(const std::string &s)
void XmlWriter::push(const string &s)
{
node_ = node_.append_child(s.c_str());
}
@@ -25,22 +27,22 @@ void XmlWriter::pop(void)
}
// Reader implementation ///////////////////////////////////////////////////////
XmlReader::XmlReader(const std::string &fileName)
XmlReader::XmlReader(const string &fileName)
: fileName_(fileName)
{
pugi::xml_parse_result result = doc_.load_file(fileName_.c_str());
if ( !result )
{
std::cerr << "XML error description: " << result.description() << "\n";
std::cerr << "XML error offset : " << result.offset << "\n";
std::abort();
cerr << "XML error description: " << result.description() << "\n";
cerr << "XML error offset : " << result.offset << "\n";
abort();
}
node_ = doc_.child("grid");
}
void XmlReader::push(const std::string &s)
void XmlReader::push(const string &s)
{
node_ = node_.child(s.c_str());
}
@@ -51,8 +53,7 @@ void XmlReader::pop(void)
}
template <>
void XmlReader::readDefault(const std::string &s, std::string &output)
void XmlReader::readDefault(const string &s, string &output)
{
output = node_.child(s.c_str()).first_child().value();
}
}