17 #include <kunitconversion/converter.h>
21 class IsotopeParser::Private
25 : currentUnit(KUnitConversion::NoUnit),
26 currentErrorValue(QVariant()),
27 currentElementSymbol(QString()),
31 inAtomicNumber(false),
36 inAlphaDecayLikeliness(false),
38 inBetaplusDecayLikeliness(false),
39 inBetaplusDecay(false),
40 inBetaminusDecayLikeliness(false),
41 inBetaminusDecay(false),
42 inECDecayLikeliness(false),
49 delete currentIsotope;
55 QVariant currentErrorValue;
56 QString currentElementSymbol;
59 QList<Isotope*> isotopes;
68 bool inAlphaDecayLikeliness;
70 bool inBetaplusDecayLikeliness;
72 bool inBetaminusDecayLikeliness;
73 bool inBetaminusDecay;
74 bool inECDecayLikeliness;
91 if (localName ==
"isotopeList")
96 for (
int i = 0; i < attrs.length(); ++i)
98 if ( attrs.localName( i ) ==
"id" )
99 d->currentElementSymbol = attrs.value( i );
102 }
else if ( d->inElement && localName ==
"isotope")
104 d->currentIsotope =
new Isotope();
107 for (
int i = 0; i < attrs.length(); ++i)
109 if ( attrs.localName( i ) ==
"number" )
111 d->currentIsotope->setNucleons( attrs.value( i ).toInt() );
114 }
else if (d->inIsotope && localName ==
"scalar")
116 for (
int i = 0; i < attrs.length(); ++i)
118 if ( attrs.localName( i ) ==
"errorValue" )
120 d->currentErrorValue = QVariant( attrs.value( i ) );
124 if (attrs.value(i) ==
"bo:atomicNumber")
125 d->inAtomicNumber =
true;
126 else if (attrs.value(i) ==
"bo:exactMass")
127 d->inExactMass =
true;
128 else if (attrs.value(i) ==
"bo:halfLife"){
129 for (
int i = 0; i < attrs.length(); ++i)
131 if (attrs.localName(i) ==
"units") {
132 if ( attrs.value(i) ==
"siUnits:s" ) {
133 d->currentUnit = KUnitConversion::Second;
134 }
else if ( attrs.value(i) ==
"units:y" ) {
135 d->currentUnit = KUnitConversion::Year;
137 d->currentUnit = KUnitConversion::NoUnit;
142 d->currentDataObject.setUnit( d->currentUnit );
143 d->inHalfLife =
true;
145 else if (attrs.value(i) ==
"bo:alphaDecay")
146 d->inAlphaDecay =
true;
147 else if (attrs.value(i) ==
"bo:alphaDecayLikeliness")
148 d->inAlphaDecayLikeliness =
true;
149 else if (attrs.value(i) ==
"bo:ecDecay")
151 else if (attrs.value(i) ==
"bo:ecDecayLikeliness")
152 d->inECDecayLikeliness =
true;
153 else if (attrs.value(i) ==
"bo:betaminusDecay")
154 d->inBetaminusDecay =
true;
155 else if (attrs.value(i) ==
"bo:betaminusDecayLikeliness")
156 d->inBetaminusDecayLikeliness =
true;
157 else if (attrs.value(i) ==
"bo:betaplusDecay")
158 d->inBetaplusDecay =
true;
159 else if (attrs.value(i) ==
"bo:betaplusDecayLikeliness")
160 d->inBetaplusDecayLikeliness =
true;
161 else if (attrs.value(i) ==
"bo:spin")
163 else if (attrs.value(i) ==
"bo:magneticMoment")
164 d->inMagMoment =
true;
165 else if (attrs.value(i) ==
"bo:relativeAbundance")
166 d->inAbundance =
true;
174 if ( localName ==
"isotope" )
176 d->isotopes.append(d->currentIsotope);
178 d->currentIsotope = 0;
179 d->inIsotope =
false;
181 else if ( localName ==
"isotopeList" )
183 d->inElement =
false;
195 value = ch.toDouble();
197 d->inExactMass =
false;
199 else if (d->inAtomicNumber) {
202 d->inAtomicNumber =
false;
204 else if (d->inSpin) {
209 else if (d->inMagMoment) {
212 d->inMagMoment =
false;
214 else if (d->inHalfLife) {
215 value = ch.toDouble();
217 d->inHalfLife =
false;
219 else if (d->inAlphaDecay) {
220 value = ch.toDouble();
222 d->inAlphaDecay =
false;
224 else if (d->inAlphaDecayLikeliness) {
225 value = ch.toDouble();
227 d->inAlphaDecayLikeliness =
false;
229 else if (d->inBetaplusDecay) {
230 value = ch.toDouble();
232 d->inBetaplusDecay =
false;
234 else if (d->inBetaplusDecayLikeliness) {
235 value = ch.toDouble();
237 d->inBetaplusDecayLikeliness =
false;
239 else if (d->inBetaminusDecay) {
240 value = ch.toDouble();
242 d->inBetaminusDecay =
false;
244 else if (d->inBetaminusDecayLikeliness) {
245 value = ch.toDouble();
247 d->inBetaminusDecayLikeliness =
false;
249 else if (d->inECDecayLikeliness) {
250 value = ch.toDouble();
252 d->inECDecayLikeliness =
false;
254 else if (d->inECDecay) {
255 value = ch.toDouble();
257 d->inECDecay =
false;
259 else if (d->inAbundance){
262 d->inAbundance =
false;
269 d->currentDataObject.setErrorValue( d->currentErrorValue );
272 d->currentDataObject.setData( value );
273 d->currentDataObject.setType( type );
275 if ( d->currentIsotope )
277 d->currentIsotope->addData( d->currentDataObject );
QList< Isotope * > getIsotopes()
bool startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attrs)
bool characters(const QString &ch)
The percentage of alphadecay.
the symbol of the element
The decayenergy of ecminusdecay in MeV.
The abundance, relative to 100.
A ChemicalDataObject is an object which contains information about a chemical element.
The magnetic dipole moment.
The decayenergy of betaminusdecay in MeV.
BlueObelisk
The BlueObelisk-project defines in their XML file the dataset with the names of the enum plus "bo:"...
The percentage of betaplusdecay.
The decayenergy of alphadecay in MeV.
The atomic number of the element.
The percentage of ecdecay.
exact masses of the most common isotopes for each element
IsotopeParser()
Constructor.
The percentage of betaminusdecay.
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
The decayenergy of betaplusdecay in MeV.