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 namespace gcu
00035 {
00041 class parse_error: public std::exception
00042 {
00043 public:
00047 explicit
00048 parse_error (const std::string& __arg, int start, int length);
00049
00050 virtual
00051 ~parse_error () throw ();
00052
00056 virtual const char*
00057 what () const throw ();
00061 const char*
00062 what (int& start, int& length) const throw ();
00063
00067 void add_offset (int offset) {m_start += offset;}
00068
00069 private:
00070 std::string m_msg;
00071 int m_start, m_length;
00072
00073 };
00074
00075 class FormulaElt;
00076
00082 class Formula
00083 {
00084 public:
00090 Formula (std::string entry) throw (parse_error);
00091 virtual ~Formula ();
00092
00096 char const *GetMarkup ();
00100 std::map<int,int> &GetRawFormula ();
00104 char const *GetRawMarkup ();
00111 void SetFormula (std::string entry) throw (parse_error);
00115 void Clear ();
00122 double GetMolecularWeight (int &prec, bool &artificial);
00128 void CalculateIsotopicPattern (IsotopicPattern &pattern);
00129
00130 bool BuildConnectivity ();
00131
00132 private:
00133 void Parse (std::string &formula, std::list<FormulaElt *>&result) throw (parse_error);
00134
00135 private:
00136 std::string Entry, Markup, RawMarkup;
00137 std::map<int,int> Raw;
00138 std::list<FormulaElt *> Details;
00139 double m_Weight;
00140 int m_WeightPrec;
00141 bool m_WeightCached;
00142 bool m_Artificial;
00143 bool m_ConnectivityCached;
00144 };
00145
00146 }
00147
00148 #endif // GCU_FORMULA_H