]> Git trees. - libqmvoc.git/commitdiff
Updating the molecular parser, to return the list of aliases used. upstream/gsoc2009
authorKashyap Ramesh Puranik <kashthealien@gmail.com>
Tue, 30 Jun 2009 13:59:48 +0000 (13:59 +0000)
committerKashyap Ramesh Puranik <kashthealien@gmail.com>
Tue, 30 Jun 2009 13:59:48 +0000 (13:59 +0000)
svn path=/branches/kalzium/gsoc2009/kalzium/libscience/; revision=989557

libscience/moleculeparser.cpp
libscience/moleculeparser.h

index efd8186d503fcd5127c2177cf08b18713f699b74..e1ec0cae6dcee6a6effd06e52ea835a30c68147a 100644 (file)
@@ -101,12 +101,14 @@ MoleculeParser::MoleculeParser( const QList<Element*>& list)
     : Parser()
 {
        m_elementList = list;
+       m_aliasList = new (QSet<QString>);
 }
 
 
 MoleculeParser::MoleculeParser(const QString& _str)
     : Parser(_str)
 {
+       m_aliasList = new (QSet<QString>);
 }
 
 
@@ -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<QString>*
+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
index 2e02964d2b8b49965f61c04da155cb469232cdb0..6e8afbfe26a80ac1677887abd20f00c76f3d2b38 100644 (file)
@@ -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<QString>* getAliasList(void);
  private:
     // Helper functions
     bool      parseSubmolecule(double          *_resultMass,
@@ -235,7 +236,9 @@ public:
     Element  *lookupElement( const QString& _name );
 
     QMap<Element*, int> m_elementMap;
-               
+       
+       // Contains the list of aliases eg, { "Et - C2H5", "Me - CH3"}
+       QSet<QString> *m_aliasList;     
        //if this booloean is "true" the parser found an error
        bool             m_error;