summaryrefslogtreecommitdiff
path: root/src/configparser.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2016-03-22 00:40:15 +0100
committerAndré Nusser <andre.nusser@googlemail.com>2016-03-29 22:19:49 +0200
commit0930fdc014bf36fb9e2715b3d14bff5fedf354a9 (patch)
tree9136c06ba9311f164e03156312ed449367acf20a /src/configparser.cc
parent866b09992668f97af063dcd77dc5dd0e3a512b94 (diff)
Parser refactoring.
* Use new style * Update to C++11 * Use more std::string than char*
Diffstat (limited to 'src/configparser.cc')
-rw-r--r--src/configparser.cc45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/configparser.cc b/src/configparser.cc
index ac8b876..1ada879 100644
--- a/src/configparser.cc
+++ b/src/configparser.cc
@@ -32,39 +32,40 @@
ConfigParser::ConfigParser()
{
- str = NULL;
+ str = nullptr;
}
-void ConfigParser::characterData(std::string &data)
+void ConfigParser::characterData(const std::string& data)
{
- if(str) str->append(data);
+ if(str)
+ {
+ str->append(data);
+ }
}
-void ConfigParser::startTag(std::string name, attr_t attr)
+void ConfigParser::startTag(const std::string& name, attr_t& attr)
{
- if(name == "value" && attr.find("name") != attr.end()) {
- values[attr["name"]] = "";
- str = &values[attr["name"]];
- }
+ if(name == "value" && attr.find("name") != attr.end())
+ {
+ values[attr["name"]] = "";
+ str = &values[attr["name"]];
+ }
}
-void ConfigParser::endTag(std::string name)
+void ConfigParser::endTag(const std::string& name)
{
- if(name == "value") str = NULL;
+ if(name == "value")
+ {
+ str = nullptr;
+ }
}
-std::string ConfigParser::value(std::string name, std::string def)
+std::string ConfigParser::value(const std::string& name, const std::string& def)
{
- if(values.find(name) == values.end()) return def;
- return values[name];
-}
+ if(values.find(name) == values.end())
+ {
+ return def;
+ }
-void ConfigParser::parseError(char *buf, size_t len, std::string error,
- int lineno)
-{
- std::string buffer;
- buffer.append(buf, len);
- ERR(configparser, "sax parser error '%s' at line %d. "
- "Buffer: [%d bytes]<%s>\n",
- error.c_str(), lineno, (int)len, buffer.c_str());
+ return values[name];
}