00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef GCU_FORMULA_H
00028 #define GCU_FORMULA_H
00029
00030 #include <string>
00031 #include <map>
00032 #include <list>
00033 #include <stdexcept>
00034 #include "isotope.h"
00035
00036 using namespace std;
00037
00038 namespace gcu
00039 {
00045 class parse_error: public exception
00046 {
00047 string m_msg;
00048 int m_start, m_length;
00049
00050 public:
00054 explicit
00055 parse_error (const string& __arg, int start, int length);
00056
00057 virtual
00058 ~parse_error () throw ();
00059
00063 virtual const char*
00064 what () const throw ();
00068 const char*
00069 what (int& start, int& length) const throw ();
00070
00074 void add_offset (int offset) {m_start += offset;}
00075
00076 };
00077
00078 class FormulaElt;
00079
00085 class Formula
00086 {
00087 public:
00093 Formula (string entry) throw (parse_error);
00094 virtual ~Formula ();
00095
00099 char const *GetMarkup ();
00103 map<int,int> &GetRawFormula ();
00107 char const *GetRawMarkup ();
00114 void SetFormula (string entry) throw (parse_error);
00118 void Clear ();
00125 double GetMolecularWeight (int &prec, bool &artificial);
00131 void CalculateIsotopicPattern (IsotopicPattern &pattern);
00132
00133 private:
00134 void Parse (string &formula, list<FormulaElt *>&result) throw (parse_error);
00135
00136 private:
00137 string Entry, Markup, RawMarkup;
00138 map<int,int> Raw;
00139 list<FormulaElt *> Details;
00140 double m_Weight;
00141 int m_WeightPrec;
00142 bool m_WeightCached;
00143 bool m_Artificial;
00144 };
00145
00146 }
00147
00148 #endif // GCU_FORMULA_H