Mercurial > hg > svcore
comparison plugin/PluginXml.cpp @ 689:573d45e9487b
Merge from debug-output branch
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 14:47:59 +0100 |
parents | 06f13a3b9e9e |
children | 1424aa29ae95 |
comparison
equal
deleted
inserted
replaced
688:be43b2fe68e8 | 689:573d45e9487b |
---|---|
79 m_plugin->getParameterDescriptors(); | 79 m_plugin->getParameterDescriptors(); |
80 | 80 |
81 for (Vamp::PluginBase::ParameterList::const_iterator i = parameters.begin(); | 81 for (Vamp::PluginBase::ParameterList::const_iterator i = parameters.begin(); |
82 i != parameters.end(); ++i) { | 82 i != parameters.end(); ++i) { |
83 | 83 |
84 // std::cerr << "PluginXml::toXml: parameter name \"" | 84 // DEBUG << "PluginXml::toXml: parameter name \"" |
85 // << i->name.c_str() << "\" has value " | 85 // << i->name.c_str() << "\" has value " |
86 // << m_plugin->getParameter(i->name) << std::endl; | 86 // << m_plugin->getParameter(i->name) << endl; |
87 | 87 |
88 stream << QString("param-%1=\"%2\" ") | 88 stream << QString("param-%1=\"%2\" ") |
89 .arg(stripInvalidParameterNameCharacters(QString(i->identifier.c_str()))) | 89 .arg(stripInvalidParameterNameCharacters(QString(i->identifier.c_str()))) |
90 .arg(m_plugin->getParameter(i->identifier)); | 90 .arg(m_plugin->getParameter(i->identifier)); |
91 } | 91 } |
117 #define CHECK_ATTRIBUTE(ATTRIBUTE, ACCESSOR) \ | 117 #define CHECK_ATTRIBUTE(ATTRIBUTE, ACCESSOR) \ |
118 QString ATTRIBUTE = attrs.value(#ATTRIBUTE); \ | 118 QString ATTRIBUTE = attrs.value(#ATTRIBUTE); \ |
119 if (ATTRIBUTE != "" && ATTRIBUTE != ACCESSOR().c_str()) { \ | 119 if (ATTRIBUTE != "" && ATTRIBUTE != ACCESSOR().c_str()) { \ |
120 std::cerr << "WARNING: PluginXml::setParameters: Plugin " \ | 120 std::cerr << "WARNING: PluginXml::setParameters: Plugin " \ |
121 << #ATTRIBUTE << " does not match (attributes have \"" \ | 121 << #ATTRIBUTE << " does not match (attributes have \"" \ |
122 << ATTRIBUTE.toStdString() << "\", my " \ | 122 << ATTRIBUTE << "\", my " \ |
123 << #ATTRIBUTE << " is \"" << ACCESSOR() << "\")" << std::endl; \ | 123 << #ATTRIBUTE << " is \"" << ACCESSOR() << "\")" << std::endl; \ |
124 } | 124 } |
125 | 125 |
126 void | 126 void |
127 PluginXml::setParameters(const QXmlAttributes &attrs) | 127 PluginXml::setParameters(const QXmlAttributes &attrs) |
172 QString pname = QString("param-%1") | 172 QString pname = QString("param-%1") |
173 .arg(stripInvalidParameterNameCharacters | 173 .arg(stripInvalidParameterNameCharacters |
174 (QString(i->identifier.c_str()))); | 174 (QString(i->identifier.c_str()))); |
175 | 175 |
176 if (attrs.value(pname) == "") { | 176 if (attrs.value(pname) == "") { |
177 // std::cerr << "PluginXml::setParameters: no parameter \"" << i->name << "\" (attribute \"" << name.toStdString() << "\")" << std::endl; | 177 // DEBUG << "PluginXml::setParameters: no parameter \"" << i->name << "\" (attribute \"" << name << "\")" << endl; |
178 continue; | 178 continue; |
179 } | 179 } |
180 | 180 |
181 bool ok; | 181 bool ok; |
182 float value = attrs.value(pname).trimmed().toFloat(&ok); | 182 float value = attrs.value(pname).trimmed().toFloat(&ok); |
183 if (ok) { | 183 if (ok) { |
184 // std::cerr << "PluginXml::setParameters: setting parameter \"" | 184 // DEBUG << "PluginXml::setParameters: setting parameter \"" |
185 // << i->identifier << "\" to value " << value << std::endl; | 185 // << i->identifier << "\" to value " << value << endl; |
186 m_plugin->setParameter(i->identifier, value); | 186 m_plugin->setParameter(i->identifier, value); |
187 } else { | 187 } else { |
188 std::cerr << "WARNING: PluginXml::setParameters: Invalid value \"" << attrs.value(pname).toStdString() << "\" for parameter \"" << i->identifier << "\" (attribute \"" << pname.toStdString() << "\")" << std::endl; | 188 std::cerr << "WARNING: PluginXml::setParameters: Invalid value \"" << attrs.value(pname) << "\" for parameter \"" << i->identifier << "\" (attribute \"" << pname << "\")" << std::endl; |
189 } | 189 } |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 void | 193 void |
197 | 197 |
198 QString error; | 198 QString error; |
199 int errorLine; | 199 int errorLine; |
200 int errorColumn; | 200 int errorColumn; |
201 | 201 |
202 // std::cerr << "PluginXml::setParametersFromXml: XML is \"" | 202 // DEBUG << "PluginXml::setParametersFromXml: XML is \"" |
203 // << xml.toLocal8Bit().data() << "\"" << std::endl; | 203 // << xml.toLocal8Bit().data() << "\"" << endl; |
204 | 204 |
205 if (!doc.setContent(xml, false, &error, &errorLine, &errorColumn)) { | 205 if (!doc.setContent(xml, false, &error, &errorLine, &errorColumn)) { |
206 std::cerr << "PluginXml::setParametersFromXml: Error in parsing XML: " << error.toStdString() << " at line " << errorLine << ", column " << errorColumn << std::endl; | 206 std::cerr << "PluginXml::setParametersFromXml: Error in parsing XML: " << error << " at line " << errorLine << ", column " << errorColumn << std::endl; |
207 std::cerr << "Input follows:" << std::endl; | 207 std::cerr << "Input follows:" << std::endl; |
208 std::cerr << xml.toStdString() << std::endl; | 208 std::cerr << xml << std::endl; |
209 std::cerr << "Input ends." << std::endl; | 209 std::cerr << "Input ends." << std::endl; |
210 return; | 210 return; |
211 } | 211 } |
212 | 212 |
213 QDomElement pluginElt = doc.firstChildElement("plugin"); | 213 QDomElement pluginElt = doc.firstChildElement("plugin"); |
215 QXmlAttributes attrs; | 215 QXmlAttributes attrs; |
216 | 216 |
217 for (unsigned int i = 0; i < attrNodes.length(); ++i) { | 217 for (unsigned int i = 0; i < attrNodes.length(); ++i) { |
218 QDomAttr attr = attrNodes.item(i).toAttr(); | 218 QDomAttr attr = attrNodes.item(i).toAttr(); |
219 if (attr.isNull()) continue; | 219 if (attr.isNull()) continue; |
220 // std::cerr << "PluginXml::setParametersFromXml: Adding attribute \"" << attr.name().toStdString() | 220 // DEBUG << "PluginXml::setParametersFromXml: Adding attribute \"" << attr.name()// << "\" with value \"" << attr.value() << "\"" << endl; |
221 // << "\" with value \"" << attr.value().toStdString() << "\"" << std::endl; | |
222 attrs.append(attr.name(), "", "", attr.value()); | 221 attrs.append(attr.name(), "", "", attr.value()); |
223 } | 222 } |
224 | 223 |
225 setParameters(attrs); | 224 setParameters(attrs); |
226 } | 225 } |