Logo Search packages:      
Sourcecode: kalzium version File versions  Download package

Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes

MoleculeParser Class Reference

#include <moleculeparser.h>

Inheritance diagram for MoleculeParser:
Inheritance graph
[legend]
Collaboration diagram for MoleculeParser:
Collaboration graph
[legend]

List of all members.

Public Member Functions

QSet< QString > aliasList ()
float floatVal () const
int intVal () const
 MoleculeParser (const QList< Element * > &list)
 MoleculeParser (const QString &_str)
int nextChar () const
int nextToken () const
void start (const QString &_str)
bool weight (const QString &_moleculeString, double *_resultMass, ElementCountMap *_resultMap)
virtual ~MoleculeParser ()

Protected Member Functions

int getNextChar ()
virtual int getNextToken ()
int skipWhitespace ()

Protected Attributes

double m_floatVal
int m_intVal
int m_nextToken

Static Protected Attributes

static const int FLOAT_TOKEN = 258
static const int INT_TOKEN = 257

Private Member Functions

QString expandFormula (const QString &_shortMolecularMass)
QString expandTerm (const QString &_group)
ElementlookupElement (const QString &_name)
bool parseSubmolecule (double *_resultMass, ElementCountMap *_resultMap)
bool parseTerm (double *_resultMass, ElementCountMap *_resultMap)

Private Attributes

QSet< QString > * m_aliasList
QList< Element * > m_elementList
QMap< Element *, int > m_elementMap
Elementm_elementVal
bool m_error

Static Private Attributes

static const int ELEMENT_TOKEN = 300

Detailed Description

Parse molecule formulas.

Usage:

   MoleculeParser  parser;
   QString         chemical_formula = "C2H5OH";
   double          weight;

   if (parser.weight(chemical_formula, &weight))
     cout << "Weight of " << chemical_formula << " = " << weight << ".\n";
   else
     cout << "Parse error\n";

If a short form of a compound is specified, it will be expanded. Example :- EtOH -> (C2H5OH)

   MoleculeParser  parser;
   QString         chemical_formula = "EtOH";
   double          weight;

   if (parser.weight(chemical_formula, &weight))
     cout << "Weight of " << chemical_formula << " = " << weight << ".\n";
   else
     cout << "Parse error\n";
Author:
Inge Wallin
Kashyap R Puranik

Definition at line 182 of file moleculeparser.h.


The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index