From: Kashyap Ramesh Puranik Date: Tue, 30 Jun 2009 13:59:48 +0000 (+0000) Subject: Updating the molecular parser, to return the list of aliases used. X-Git-Tag: v4.3.80~1^2 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=refs%2Fremotes%2Fupstream%2Fgsoc2009;p=libqmvoc.git Updating the molecular parser, to return the list of aliases used. svn path=/branches/kalzium/gsoc2009/kalzium/libscience/; revision=989557 --- diff --git a/libscience/moleculeparser.cpp b/libscience/moleculeparser.cpp index efd8186..e1ec0ca 100644 --- a/libscience/moleculeparser.cpp +++ b/libscience/moleculeparser.cpp @@ -101,12 +101,14 @@ MoleculeParser::MoleculeParser( const QList& list) : Parser() { m_elementList = list; + m_aliasList = new (QSet); } MoleculeParser::MoleculeParser(const QString& _str) : Parser(_str) { + m_aliasList = new (QSet); } @@ -130,6 +132,9 @@ MoleculeParser::weight(const QString& _shortMoleculeString, { if ( _shortMoleculeString.isEmpty() ) return false; + // Clear the list of aliases and start filling it again. + + m_aliasList -> clear(); QString _moleculeString; // Clear the result variables and set m_error to false _resultMap->clear(); @@ -156,7 +161,11 @@ MoleculeParser::weight(const QString& _shortMoleculeString, return true; } - +QSet* +MoleculeParser::getAliasList(void) +{ + return m_aliasList; +} // ---------------------------------------------------------------- // helper methods for the public methods @@ -404,7 +413,10 @@ MoleculeParser::expandTerm (const QString& _group) // If short term is found, return fullForm if (shortForm == _group) + { + *m_aliasList << (_group + " : " + fullForm); return (fullForm); + } } } else @@ -432,7 +444,10 @@ MoleculeParser::expandTerm (const QString& _group) fullForm.remove(QChar('\"')); if (shortForm == _group) + { + *m_aliasList << (_group + " : " + fullForm); return (fullForm); + } } } else diff --git a/libscience/moleculeparser.h b/libscience/moleculeparser.h index 2e02964..6e8afbf 100644 --- a/libscience/moleculeparser.h +++ b/libscience/moleculeparser.h @@ -73,7 +73,6 @@ class SCIENCE_EXPORT ElementCount * The Element of the object */ Element *m_element; - /** * The number of occurrences */ @@ -215,6 +214,8 @@ public: bool weight(const QString& _moleculeString, double *_resultMass, ElementCountMap *_resultMap); + + QSet* getAliasList(void); private: // Helper functions bool parseSubmolecule(double *_resultMass, @@ -235,7 +236,9 @@ public: Element *lookupElement( const QString& _name ); QMap m_elementMap; - + + // Contains the list of aliases eg, { "Et - C2H5", "Me - CH3"} + QSet *m_aliasList; //if this booloean is "true" the parser found an error bool m_error;