return m_mass->value().toDouble();
}
-double Isotope::errorMargin() const
+QString Isotope::errorMargin() const
{
- return m_mass->errorValue().toDouble();
+ return m_mass->errorValue().toString();
}
int Isotope::parentElementNumber() const
double mass() const;
- double errorMargin() const;
+ QString errorMargin() const;
int parentElementNumber() const;
{
for (int i = 0; i < attrs.length(); ++i)
{
+
+ if ( attrs.localName( i ) == "errorValue" )
+ {
+ currentErrorValue_ = QVariant( attrs.value( i ) );
+ continue;
+ }
+
if (attrs.value(i) == "bo:atomicNumber")
inAtomicNumber_ = true;
else if (attrs.value(i) == "bo:exactMass")
currentDataObject_ = 0;
inIsotope_ = false;
}
+ else if ( localName == "scalar" )
+ {
+ if ( currentDataObject_->type() == ChemicalDataObject::exactMass ){
+ currentDataObject_->setErrorValue( currentErrorValue_ );
+ }
+ }
return true;
}
private:
ChemicalDataObject *currentDataObject_;
ChemicalDataObject::BlueObeliskUnit currentUnit_;
+
+ QVariant currentErrorValue_;
Isotope* currentIsotope_;
QList<Isotope*> isotopes_;
AM_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) $(KDE_RPATH)
-check_PROGRAMS = xmlreadingtest
+check_PROGRAMS = xmlreadingtest isotopereadingtest
xmlreadingtest_SOURCES = xmlreadingtest.cpp
xmlreadingtest_LDFLAGS = $(all_libraries)
xmlreadingtest_LDADD = ../libscience.la
+isotopereadingtest_SOURCES = isotopereadingtest.cpp
+isotopereadingtest_LDFLAGS = $(all_libraries)
+isotopereadingtest_LDADD = ../libscience.la
METASOURCES = AUTO
--- /dev/null
+/* Sample parsing with QT's SAX2 by Riku Leino <tsoots@gmail.com> */
+
+#include "../isotopeparser.h"
+#include "../isotope.h"
+#include <kdebug.h>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2 || argc > 2) {
+ std::cout << "Usage: elements <XML_FILE>\n";
+ return 1;
+ }
+
+ IsotopeParser * parser = new IsotopeParser();
+ QFile xmlFile(argv[1]);
+ QXmlInputSource source(xmlFile);
+ QXmlSimpleReader reader;
+
+ reader.setContentHandler(parser);
+ reader.parse(source);
+
+ QList<Isotope*> v = parser->getIsotopes();
+
+ foreach( Isotope* e, v ){
+ if ( e )
+ {
+ ChemicalDataObject* o = e->data();
+ kdDebug() << "Name: " << o->dictRef() << " " << o->valueAsString() << " errorMargin: " << e->errorMargin() << " parent Element: " << e->parentElementSymbol() << endl;
+
+ }
+
+ }
+
+ return 0;
+}