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 string m_msg;
00046 int m_start, m_length;
00047
00048 public:
00052 explicit
00053 parse_error (const string& __arg, int start, int length);
00054
00055 virtual
00056 ~parse_error () throw ();
00057
00061 virtual const char*
00062 what () const throw ();
00066 const char*
00067 what (int& start, int& length) const throw ();
00068
00072 void add_offset (int offset) {m_start += offset;}
00073
00074 };
00075
00076 class FormulaElt;
00077
00083 class Formula
00084 {
00085 public:
00091 Formula (string entry) throw (parse_error);
00092 virtual ~Formula ();
00093
00097 char const *GetMarkup ();
00101 map<int,int> &GetRawFormula ();
00105 char const *GetRawMarkup ();
00112 void SetFormula (string entry) throw (parse_error);
00116 void Clear ();
00123 double GetMolecularWeight (int &prec, bool &artificial);
00129 void CalculateIsotopicPattern (IsotopicPattern &pattern);
00130
00131 private:
00132 void Parse (string &formula, list<FormulaElt *>&result) throw (parse_error);
00133
00134 private:
00135 string Entry, Markup, RawMarkup;
00136 map<int,int> Raw;
00137 list<FormulaElt *> Details;
00138 double m_Weight;
00139 int m_WeightPrec;
00140 bool m_WeightCached;
00141 bool m_Artificial;
00142 };
00143
00144 }
00145
00146 #endif // GCU_FORMULA_H