// class MoleculeParser
-MoleculeParser::MoleculeParser()
+MoleculeParser::MoleculeParser( const QList<Element*>& list)
: Parser()
{
+ m_elementList = list;
}
Element *
MoleculeParser::lookupElement( const QString& _name )
{
- /** PORTING this cannot work because of course there is no KDO known in
- * this library. We need to find a workaround here...
-
- QList<Element*> elementList = KalziumDataObject::instance()->ElementList;
+//X QList<Element*> elementList = KalziumDataObject::instance()->ElementList;
- //kdDebug() << "looking up " << _name << endl;
+ kdDebug() << "looking up " << _name << endl;
- QList<Element*>::ConstIterator it = elementList.constBegin();
- const QList<Element*>::ConstIterator end = elementList.constEnd();
+//X QList<Element*>::ConstIterator it = elementList.constBegin();
+//X const QList<Element*>::ConstIterator end = elementList.constEnd();
- for (; it != end; ++it) {
- if ( (*it)->dataAsVariant(ChemicalDataObject::symbol) == _name ) {
+ foreach( Element* e, m_elementList ){
+ if ( e->dataAsVariant(ChemicalDataObject::symbol) == _name ) {
kdDebug() << "Found element " << _name << endl;
- return *it;
+ return e;
}
}
+//X for (; it != end; ++it) {
+//X if ( (*it)->dataAsVariant(ChemicalDataObject::symbol) == _name ) {
+//X kdDebug() << "Found element " << _name << endl;
+//X return *it;
+//X }
+//X }
+
//if there is an error make m_error true.
m_error = true;
kdDebug() << k_funcinfo << "no such element, parsing error!: " << _name << endl;
- */
return NULL;
}
public:
/**
+ * @param list This list of chemical elements will be used internally
+ * for searching and matching with searched strings
* Constructor
*/
- MoleculeParser();
+ MoleculeParser( const QList<Element*>& list );
/**
* Constructor
bool parseTerm(double *_resultMass,
ElementCountMap *_resultMap);
+ QList<Element*> m_elementList;
+
static const int ELEMENT_TOKEN = 300;
Element *lookupElement( const QString& _name );
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#include <qpair.h>
-#include <qstringlist.h>
+#include <QPair>
+#include <QStringList>
/**
* This class obtains all the info needed to work with the units of measure
* of temperature.
*
* It has static methods you can call to get the various infos. The most
- * important methods is convert(), that performs conversions.
+ * important method is convert(), that performs conversions.
*
* @author Pino Toscano
*/