From 2d44ba23037e6d37dfdf2fa40cde2d3efb6eb8c2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 11 Sep 2013 20:22:47 +0200 Subject: Move class specification to header file. --- src/configparser.cc | 71 +++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) (limited to 'src/configparser.cc') 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 + #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 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()); +} -- cgit v1.2.3