summaryrefslogtreecommitdiff
path: root/src/configparser.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-09-11 20:22:47 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2013-09-11 20:22:47 +0200
commit2d44ba23037e6d37dfdf2fa40cde2d3efb6eb8c2 (patch)
tree3ebf2eb3491f23f0b42907d3d89a7f2a2b400453 /src/configparser.cc
parent4fb69a0c62540c8a9f2613e55731e30dc05d619f (diff)
Move class specification to header file.
Diffstat (limited to 'src/configparser.cc')
-rw-r--r--src/configparser.cc71
1 files changed, 34 insertions, 37 deletions
diff --git a/src/configparser.cc b/src/configparser.cc
index b04f6fc..b0a0e9b 100644
--- a/src/configparser.cc
+++ b/src/configparser.cc
@@ -26,48 +26,45 @@
*/
#include "configparser.h"
+#include <hugin.hpp>
+
#include "saxparser.h"
-class ConfigParser : public SAXParser {
-public:
- ConfigParser()
- {
- str = NULL;
- }
+ConfigParser::ConfigParser()
+{
+ str = NULL;
+}
- void characterData(std::string &data)
- {
- if(str) str->append(data);
- }
+void ConfigParser::characterData(std::string &data)
+{
+ if(str) str->append(data);
+}
- void startTag(std::string name, attr_t attr)
- {
- if(name == "value" && attr.find("name") != attr.end()) {
- values[attr["name"]] = "";
- str = &values[attr["name"]];
- }
+void ConfigParser::startTag(std::string name, attr_t attr)
+{
+ if(name == "value" && attr.find("name") != attr.end()) {
+ values[attr["name"]] = "";
+ str = &values[attr["name"]];
}
+}
- void endTag(std::string name)
- {
- if(name == "value") str = NULL;
- }
+void ConfigParser::endTag(std::string name)
+{
+ if(name == "value") str = NULL;
+}
- std::string value(std::string name, std::string def = "")
- {
- if(values.find(name) == values.end()) return def;
- return values[name];
- }
-
- void 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, len, buffer.c_str());
- }
+std::string ConfigParser::value(std::string name, std::string def)
+{
+ if(values.find(name) == values.end()) return def;
+ return values[name];
+}
- std::map<std::string, std::string> values;
- std::string *str;
-};
+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, len, buffer.c_str());
+}