]> Git trees. - libqmvoc.git/commitdiff
abundance
authorCarsten Niehaus <cniehaus@gmx.de>
Sat, 29 Oct 2005 23:02:16 +0000 (23:02 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sat, 29 Oct 2005 23:02:16 +0000 (23:02 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=475636

libscience/isotopeparser.cpp
libscience/isotopeparser.h
libscience/tests/isotopereadingtest.cpp

index 3aecc9c322faf3592d506249858ce472a7c757a7..c54099090ed53fdecc759c6b0ea49c3e9a9eb3b4 100644 (file)
@@ -24,7 +24,8 @@ IsotopeParser::IsotopeParser()
        : QXmlDefaultHandler(), 
        currentIsotope_(0), 
        inAtomicNumber_(false),
-       inExactMass_(false)
+       inExactMass_(false),
+       inAbundance_(false)
 {
        currentElementSymbol_ = "";
 }
@@ -46,7 +47,6 @@ bool IsotopeParser::startElement(const QString&, const QString &localName, const
        {
                for (int i = 0; i < attrs.length(); ++i) 
                {
-
                        if ( attrs.localName( i ) == "errorValue" )
                        {
                                currentErrorValue_ = QVariant( attrs.value( i ) );
@@ -58,6 +58,9 @@ bool IsotopeParser::startElement(const QString&, const QString &localName, const
                        else if (attrs.value(i) == "bo:exactMass")
                                inExactMass_ = true;
                }
+       } else if (inIsotope_ && localName == "bo:relativeAbundance") {
+               kdDebug() << "bo:relativeAbundance" << endl;
+               inAbundance_ = true;
        }
        return true;
 }
@@ -99,6 +102,11 @@ bool IsotopeParser::characters(const QString &ch)
                type = ChemicalDataObject::atomicNumber; 
                inAtomicNumber_ = false;
        }
+       else if ( inAbundance_ ){
+               value = ch;
+               type = ChemicalDataObject::relativeAbundance;
+               inAbundance_ = false;
+       }
        else//it is a non known value. Do not create a wrong object but return
                return true;
 
index ea6e8004b3f1471c8d6f2fa305fadfe803584059..d8301d1acf77d1a157ebf5a94e055e31a7cea7cf 100644 (file)
@@ -52,6 +52,8 @@ class IsotopeParser : public QXmlDefaultHandler
                bool inIsotope_;
                bool inAtomicNumber_,
                         inExactMass_;
+
+               bool inAbundance_;
 };
 #endif // ISOTOPEPARSER_H
 
index 8549860e89e609e8a8370862df3ded823afaad79..92bc7d5ac5a0867d1a96dda8685ecca75eb90b9d 100644 (file)
@@ -27,7 +27,6 @@ int main(int argc, char *argv[])
                {
                        ChemicalDataObject* o = e->data();
                        kdDebug() << "Name: " << o->dictRef() << " " << o->valueAsString()  << " errorMargin: " << e->errorMargin() << " parent Element: " << e->parentElementSymbol() << endl;
-                       
                }
 
        }