summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2016-03-23 15:59:41 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-03-29 22:43:31 +0200
commit390f6f094d43f0d8cfca4efff13d002eb4cf6f19 (patch)
tree1e8644e553d349eb26bba373354f751717b8a598 /src
parenteaf8c01ac99f9561870528ff608a073166be2163 (diff)
Make attr a const ref.
Diffstat (limited to 'src')
-rw-r--r--src/configparser.cc6
-rw-r--r--src/configparser.h2
-rw-r--r--src/drumkitparser.cc21
-rw-r--r--src/drumkitparser.h2
-rw-r--r--src/instrumentparser.cc24
-rw-r--r--src/instrumentparser.h2
-rw-r--r--src/midimapparser.cc4
-rw-r--r--src/midimapparser.h2
-rw-r--r--src/saxparser.h2
9 files changed, 32 insertions, 33 deletions
diff --git a/src/configparser.cc b/src/configparser.cc
index 1ada879..ef657b0 100644
--- a/src/configparser.cc
+++ b/src/configparser.cc
@@ -43,12 +43,12 @@ void ConfigParser::characterData(const std::string& data)
}
}
-void ConfigParser::startTag(const std::string& name, attr_t& attr)
+void ConfigParser::startTag(const std::string& name, const attr_t& attr)
{
if(name == "value" && attr.find("name") != attr.end())
{
- values[attr["name"]] = "";
- str = &values[attr["name"]];
+ values[attr.at("name")] = "";
+ str = &values[attr.at("name")];
}
}
diff --git a/src/configparser.h b/src/configparser.h
index 1e8aa56..b8bde05 100644
--- a/src/configparser.h
+++ b/src/configparser.h
@@ -37,7 +37,7 @@ public:
ConfigParser();
void characterData(const std::string& data) override;
- void startTag(const std::string& name, attr_t& attr) override;
+ void startTag(const std::string& name, const attr_t& attr) override;
void endTag(const std::string& name) override;
std::string value(const std::string& name, const std::string& def = "");
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc
index b3f3b99..2d0262d 100644
--- a/src/drumkitparser.cc
+++ b/src/drumkitparser.cc
@@ -76,19 +76,18 @@ DrumKitParser::~DrumKitParser()
}
-void DrumKitParser::startTag(const std::string& name,
- attr_t& attr)
+void DrumKitParser::startTag(const std::string& name, const attr_t& attr)
{
if(name == "drumkit")
{
if(attr.find("name") != attr.end())
{
- kit._name = attr["name"];
+ kit._name = attr.at("name");
}
if(attr.find("samplerate") != attr.end())
{
- kit._samplerate = std::stoi(attr["samplerate"]);
+ kit._samplerate = std::stoi(attr.at("samplerate"));
}
else
{
@@ -99,14 +98,14 @@ void DrumKitParser::startTag(const std::string& name,
if(attr.find("description") != attr.end())
{
- kit._description = attr["description"];
+ kit._description = attr.at("description");
}
if(attr.find("version") != attr.end())
{
try
{
- kit._version = VersionStr(attr["version"]);
+ kit._version = VersionStr(attr.at("version"));
}
catch(const char *err)
{
@@ -134,7 +133,7 @@ void DrumKitParser::startTag(const std::string& name,
return;
}
- Channel c(attr["name"]);
+ Channel c(attr.at("name"));
c.num = kit.channels.size();
kit.channels.push_back(c);
}
@@ -157,11 +156,11 @@ void DrumKitParser::startTag(const std::string& name,
return;
}
- instr_name = attr["name"];
- instr_file = attr["file"];
+ instr_name = attr.at("name");
+ instr_file = attr.at("file");
if(attr.find("group") != attr.end())
{
- instr_group = attr["group"];
+ instr_group = attr.at("group");
}
else
{
@@ -183,7 +182,7 @@ void DrumKitParser::startTag(const std::string& name,
return;
}
- channelmap[attr["in"]] = attr["out"];
+ channelmap[attr.at("in")] = attr.at("out");
}
}
diff --git a/src/drumkitparser.h b/src/drumkitparser.h
index 91456d4..1c49ed8 100644
--- a/src/drumkitparser.h
+++ b/src/drumkitparser.h
@@ -38,7 +38,7 @@ public:
~DrumKitParser();
protected:
- void startTag(const std::string& name, attr_t& attributes) override;
+ void startTag(const std::string& name, const attr_t& attributes) override;
void endTag(const std::string& name) override;
int readData(std::string& data, std::size_t size) override;
diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc
index eed179d..8c3c737 100644
--- a/src/instrumentparser.cc
+++ b/src/instrumentparser.cc
@@ -57,24 +57,24 @@ InstrumentParser::~InstrumentParser()
}
}
-void InstrumentParser::startTag(const std::string& name, attr_t& attr)
+void InstrumentParser::startTag(const std::string& name, const attr_t& attr)
{
if(name == "instrument")
{
if(attr.find("name") != attr.end())
{
- instrument._name = attr["name"];
+ instrument._name = attr.at("name");
}
if(attr.find("description") != attr.end())
{
- instrument._description = attr["description"];
+ instrument._description = attr.at("description");
}
if(attr.find("version") != attr.end())
{
try {
- instrument.version = VersionStr(attr["version"]);
+ instrument.version = VersionStr(attr.at("version"));
}
catch(const char *err)
{
@@ -109,12 +109,12 @@ void InstrumentParser::startTag(const std::string& name, attr_t& attr)
}
else
{
- power = atof_nol(attr["power"].c_str());
+ power = atof_nol(attr.at("power").c_str());
DEBUG(instrparser, "Instrument power set to %f\n", power);
}
// TODO get rid of new or delete it properly
- s = new Sample(attr["name"], power);
+ s = new Sample(attr.at("name"), power);
}
if(name == "audiofile")
@@ -140,7 +140,7 @@ void InstrumentParser::startTag(const std::string& name, attr_t& attr)
int filechannel = 1; // default, override with optional attribute
if(attr.find("filechannel") != attr.end())
{
- filechannel = std::stoi(attr["filechannel"]);
+ filechannel = std::stoi(attr.at("filechannel"));
if(filechannel < 1)
{
ERR(instrparser,"Invalid value for attribute 'filechannel'.\n");
@@ -150,8 +150,8 @@ void InstrumentParser::startTag(const std::string& name, attr_t& attr)
filechannel = filechannel - 1; // 1-based in file, but zero-based internally
// TODO do those next two lines correspond with proper deletes? If not fix it.
- AudioFile *af = new AudioFile(path + "/" + attr["file"], filechannel);
- InstrumentChannel *ch = new InstrumentChannel(attr["channel"]);
+ AudioFile *af = new AudioFile(path + "/" + attr.at("file"), filechannel);
+ InstrumentChannel *ch = new InstrumentChannel(attr.at("channel"));
channellist.push_back(ch);
s->addAudioFile(ch, af);
instrument.audiofiles.push_back(af);
@@ -176,8 +176,8 @@ void InstrumentParser::startTag(const std::string& name, attr_t& attr)
return;
}
- lower = atof_nol(attr["lower"].c_str());
- upper = atof_nol(attr["upper"].c_str());
+ lower = atof_nol(attr.at("lower").c_str());
+ upper = atof_nol(attr.at("upper").c_str());
}
if(name == "sampleref")
@@ -192,7 +192,7 @@ void InstrumentParser::startTag(const std::string& name, attr_t& attr)
std::vector<Sample *>::iterator i = instrument.samplelist.begin();
while(i != instrument.samplelist.end())
{
- if((*i)->name == attr["name"])
+ if((*i)->name == attr.at("name"))
{
sample = *i;
break;
diff --git a/src/instrumentparser.h b/src/instrumentparser.h
index 3fee916..a203444 100644
--- a/src/instrumentparser.h
+++ b/src/instrumentparser.h
@@ -43,7 +43,7 @@ public:
protected:
int readData(std::string& data, std::size_t size) override;
- virtual void startTag(const std::string& name, attr_t& attr) override;
+ virtual void startTag(const std::string& name, const attr_t& attr) override;
virtual void endTag(const std::string& name) override;
private:
diff --git a/src/midimapparser.cc b/src/midimapparser.cc
index 2d4563a..38a4124 100644
--- a/src/midimapparser.cc
+++ b/src/midimapparser.cc
@@ -39,13 +39,13 @@ MidiMapParser::~MidiMapParser()
}
}
-void MidiMapParser::startTag(const std::string& name, attr_t& attr)
+void MidiMapParser::startTag(const std::string& name, const attr_t& attr)
{
if(name == "map")
{
if(attr.find("note") != attr.end() && attr.find("instr") != attr.end())
{
- midimap[std::stoi(attr["note"])] = attr["instr"];
+ midimap[std::stoi(attr.at("note"))] = attr.at("instr");
}
}
}
diff --git a/src/midimapparser.h b/src/midimapparser.h
index 80b7507..02e79df 100644
--- a/src/midimapparser.h
+++ b/src/midimapparser.h
@@ -38,7 +38,7 @@ public:
MidiMapParser(const std::string& file);
~MidiMapParser();
- void startTag(const std::string& name, attr_t& attr) override;
+ void startTag(const std::string& name, const attr_t& attr) override;
midimap_t midimap;
diff --git a/src/saxparser.h b/src/saxparser.h
index 3222b4e..c43f00a 100644
--- a/src/saxparser.h
+++ b/src/saxparser.h
@@ -45,7 +45,7 @@ protected:
using attr_t = std::map<std::string, std::string>;
virtual void characterData(const std::string& data) {}
- virtual void startTag(const std::string& name, attr_t& attr) {}
+ virtual void startTag(const std::string& name, const attr_t& attr) {}
virtual void endTag(const std::string& name) {}
virtual void parseError(const std::string& buf, std::size_t len, const std::string& error, std::size_t lineno);