diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-06-29 22:04:47 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-06-29 22:04:47 +0200 |
commit | 77cd7380d951b136c7c505ef9ca580643fcfc9e1 (patch) | |
tree | 636542262bf877c57676a33cd1d40ac15941c484 /src/drumgizmo.cc | |
parent | a3c8cfd881371b5675b1e714f9953685299e8879 (diff) |
Move ConfigParser to its own file.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r-- | src/drumgizmo.cc | 46 |
1 files changed, 1 insertions, 45 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index cd0196c..4732c27 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -39,6 +39,7 @@ #include "drumkitparser.h" #include "audioinputenginemidi.h" #include "configuration.h" +#include "configparser.h" DrumGizmo::DrumGizmo(AudioOutputEngine *o, AudioInputEngine *i) : MessageReceiver(MSGRCV_ENGINE), @@ -448,51 +449,6 @@ std::string DrumGizmo::configString() "</config>"; } -#include "saxparser.h" - -class ConfigParser : public SAXParser { -public: - ConfigParser() - { - str = NULL; - } - - void 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 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::map<std::string, std::string> values; - std::string *str; -}; bool DrumGizmo::setConfigString(std::string cfg) { |