summaryrefslogtreecommitdiff
path: root/src/drumkitparser.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-03-23 21:57:41 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-03-31 21:03:08 +0200
commit45521d593560b120d406acfb9926697e7ad5e423 (patch)
tree4d25de9d5aa29a029ac46e3bc6551a32491f8ea8 /src/drumkitparser.cc
parentd172d756cfcdfbde5c6b8c6d25a51f58624739e6 (diff)
More cleanup.
Diffstat (limited to 'src/drumkitparser.cc')
-rw-r--r--src/drumkitparser.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc
index a538996..c727590 100644
--- a/src/drumkitparser.cc
+++ b/src/drumkitparser.cc
@@ -46,9 +46,9 @@ int DrumKitParser::parseFile(const std::string& filename)
if(refs.load())
{
- if(filename.size() > 1 && filename[0] == '@')
+ if((filename.size() > 1) && (filename[0] == '@'))
{
- edited_filename = refs.getValue(filename.substr(1));
+ edited_filename = refs.getValue(filename.substr(1));
}
}
else
@@ -59,7 +59,8 @@ int DrumKitParser::parseFile(const std::string& filename)
path = getPath(edited_filename);
auto result = SAXParser::parseFile(filename);
- if (result == 0) {
+ if(result == 0)
+ {
kit._file = edited_filename;
}
@@ -140,6 +141,7 @@ void DrumKitParser::startTag(const std::string& name, const attr_t& attr)
ERR(kitparser, "Missing name in instrument tag.\n");
return;
}
+
if(attr.find("file") == attr.end())
{
ERR(kitparser, "Missing file in instrument tag.\n");
@@ -180,12 +182,14 @@ void DrumKitParser::endTag(const std::string& name)
{
if(name == "instrument")
{
- Instrument* i = new Instrument();
- i->setGroup(instr_group);
- // Instrument &i = kit.instruments[kit.instruments.size() - 1];
- InstrumentParser parser(*i);
+ Instrument* instrument = new Instrument();
+ instrument->setGroup(instr_group);
+
+ InstrumentParser parser(*instrument);
parser.parseFile(path + "/" + instr_file);
- kit.instruments.push_back(i);
+
+ // Transfer ownership to the DrumKit object.
+ kit.instruments.push_back(instrument);
// Assign kit channel numbers to instruments channels.
std::vector<InstrumentChannel*>::iterator ic = parser.channellist.begin();
@@ -206,16 +210,18 @@ void DrumKitParser::endTag(const std::string& name)
c->num = kit.channels[cnt].num;
}
}
+
if(c->num == NO_CHANNEL)
{
ERR(kitparser, "Missing channel '%s' in instrument '%s'\n",
c->name.c_str(), i->getName().c_str());
}
- else {
+ else
+ {
/*
- DEBUG(kitparser, "Assigned channel '%s' to number %d in instrument '%s'\n",
- c->name.c_str(), c->num, i.name().c_str());
- */
+ DEBUG(kitparser, "Assigned channel '%s' to number %d in instrument '%s'\n",
+ c->name.c_str(), c->num, i.name().c_str());
+ */
}
ic++;
}