Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

formula.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * formula.h 
00006  *
00007  * Copyright (C) 2005-2006
00008  *
00009  * Developed by Jean Bréfort <jean.brefort@normalesup.org>
00010  *
00011  * This program is free software; you can redistribute it and/or 
00012  * modify it under the terms of the GNU General Public License as 
00013  * published by the Free Software Foundation; either version 2 of the
00014  * License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00024  * USA
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 {
00045 class parse_error: public exception
00046 {
00047         string m_msg;
00048         int m_start, m_length;
00049 
00050 public:
00054     explicit 
00055     parse_error (const string&  __arg, int start, int length);
00056 
00057     virtual 
00058     ~parse_error () throw ();
00059 
00063     virtual const char* 
00064     what () const throw ();
00068     const char* 
00069     what (int& start, int& length) const throw ();
00070 
00074         void add_offset (int offset) {m_start += offset;}
00075 
00076 };
00077 
00078 class FormulaElt;
00079 
00085 class Formula
00086 {
00087 public:
00093         Formula (string entry) throw (parse_error);
00094         virtual ~Formula ();
00095 
00099         char const *GetMarkup ();
00103         map<int,int> &GetRawFormula ();
00107         char const *GetRawMarkup ();
00114         void SetFormula (string entry) throw (parse_error);
00118         void Clear ();
00125         double GetMolecularWeight (int &prec, bool &artificial);
00131         void CalculateIsotopicPattern (IsotopicPattern &pattern);
00132 
00133 private:
00134         void Parse (string &formula, list<FormulaElt *>&result) throw (parse_error);
00135 
00136 private:
00137         string Entry, Markup, RawMarkup;
00138         map<int,int> Raw;
00139         list<FormulaElt *> Details;
00140         double m_Weight;
00141         int m_WeightPrec;
00142         bool m_WeightCached;
00143         bool m_Artificial;
00144 };
00145         
00146 }
00147 
00148 #endif // GCU_FORMULA_H

Generated on Wed Feb 8 09:59:43 2006 for The Gnome Chemistry Utils by  doxygen 1.4.1