formula.h
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 #ifndef GCU_FORMULA_H
00026 #define GCU_FORMULA_H
00027
00028 #include <string>
00029 #include <map>
00030 #include <list>
00031 #include <stdexcept>
00032 #include "isotope.h"
00033
00034 using namespace std;
00035
00036 namespace gcu
00037 {
00043 class parse_error: public exception
00044 {
00045 public:
00049 explicit
00050 parse_error (const string& __arg, int start, int length);
00051
00052 virtual
00053 ~parse_error () throw ();
00054
00058 virtual const char*
00059 what () const throw ();
00063 const char*
00064 what (int& start, int& length) const throw ();
00065
00069 void add_offset (int offset) {m_start += offset;}
00070
00071 private:
00072 string m_msg;
00073 int m_start, m_length;
00074
00075 };
00076
00077 class FormulaElt;
00078
00084 class Formula
00085 {
00086 public:
00092 Formula (string entry) throw (parse_error);
00093 virtual ~Formula ();
00094
00098 char const *GetMarkup ();
00102 map<int,int> &GetRawFormula ();
00106 char const *GetRawMarkup ();
00113 void SetFormula (string entry) throw (parse_error);
00117 void Clear ();
00124 double GetMolecularWeight (int &prec, bool &artificial);
00130 void CalculateIsotopicPattern (IsotopicPattern &pattern);
00131
00132 private:
00133 void Parse (string &formula, list<FormulaElt *>&result) throw (parse_error);
00134
00135 private:
00136 string Entry, Markup, RawMarkup;
00137 map<int,int> Raw;
00138 list<FormulaElt *> Details;
00139 double m_Weight;
00140 int m_WeightPrec;
00141 bool m_WeightCached;
00142 bool m_Artificial;
00143 };
00144
00145 }
00146
00147 #endif // GCU_FORMULA_H