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
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 {
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 // GCU_FORMULA_H

Generated on Sat Nov 12 15:50:14 2005 for The Gnome Chemistry Utils by  doxygen 1.4.1