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 {
00040
00041 class parse_error: public exception
00042 {
00043 string m_msg;
00044 int m_start, m_length;
00045
00046 public:
00049 explicit
00050 parse_error (const string& __arg, int start, int length);
00051
00052 virtual
00053 ~parse_error () throw ();
00054
00057 virtual const char*
00058 what () const throw ();
00061 const char*
00062 what (int& start, int& length) const throw ();
00063
00064 void add_offset (int offset) {m_start += offset;}
00065
00066 };
00067
00068 class FormulaElt;
00069
00070 class Formula
00071 {
00072 public:
00073 Formula (string entry) throw (parse_error);
00074 virtual ~Formula ();
00075
00076 char const *GetMarkup ();
00077 map<int,int> &GetRawFormula ();
00078 char const *GetRawMarkup ();
00079 void SetFormula (string entry) throw (parse_error);
00080 void Clear ();
00081 double GetMolecularWeight (int &prec, bool &artificial);
00082 void CalculateIsotopicPattern (IsotopicPattern &pattern);
00083
00084 private:
00085 void Parse (string &formula, list<FormulaElt *>&result) throw (parse_error);
00086
00087 private:
00088 string Entry, Markup, RawMarkup;
00089 map<int,int> Raw;
00090 list<FormulaElt *> Details;
00091 double m_Weight;
00092 int m_WeightPrec;
00093 bool m_WeightCached;
00094 bool m_Artificial;
00095 };
00096
00097 }
00098
00099 #endif