comparison plugin/PluginXml.cpp @ 686:b4a8d8221eaf debug-output

Remove most toStdString calls (no longer needed, with debug header)
author Chris Cannam
date Thu, 12 May 2011 17:31:24 +0100
parents a70dcfed59c1
children 06f13a3b9e9e
comparison
equal deleted inserted replaced
685:99222d4bfc78 686:b4a8d8221eaf
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 // std::cerr << "PluginXml::setParameters: no parameter \"" << i->name << "\" (attribute \"" << name << "\")" << std::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 // std::cerr << "PluginXml::setParameters: setting parameter \""
185 // << i->identifier << "\" to value " << value << std::endl; 185 // << i->identifier << "\" to value " << value << std::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
201 201
202 // std::cerr << "PluginXml::setParametersFromXml: XML is \"" 202 // std::cerr << "PluginXml::setParametersFromXml: XML is \""
203 // << xml.toLocal8Bit().data() << "\"" << std::endl; 203 // << xml.toLocal8Bit().data() << "\"" << std::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");
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 // std::cerr << "PluginXml::setParametersFromXml: Adding attribute \"" << attr.name().toStdString()
221 // << "\" with value \"" << attr.value().toStdString() << "\"" << std::endl; 221 // << "\" with value \"" << attr.value() << "\"" << std::endl;
222 attrs.append(attr.name(), "", "", attr.value()); 222 attrs.append(attr.name(), "", "", attr.value());
223 } 223 }
224 224
225 setParameters(attrs); 225 setParameters(attrs);
226 } 226 }