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