Gems3k
3.1
GEMS3K standalone solver for geochemical equilibria
|
00001 //------------------------------------------------------------------- 00002 // $Id: verror.h 725 2012-10-02 15:43:37Z kulik $ 00005 // 00006 // Copyright (C) 1996-2012 A.Rysin, S.Dmytriyeva 00007 // <GEMS Development Team, mailto:gems2.support@psi.ch> 00008 // 00009 // This file is part of the GEMS3K code for thermodynamic modelling 00010 // by Gibbs energy minimization <http://gems.web.psi.ch/GEMS3K/> 00011 // 00012 // GEMS3K is free software: you can redistribute it and/or modify 00013 // it under the terms of the GNU Lesser General Public License as 00014 // published by the Free Software Foundation, either version 3 of 00015 // the License, or (at your option) any later version. 00016 00017 // GEMS3K is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU Lesser General Public License for more details. 00021 00022 // You should have received a copy of the GNU General Public License 00023 // along with GEMS3K code. If not, see <http://www.gnu.org/licenses/>. 00024 //------------------------------------------------------------------- 00025 #ifndef _verror_h_ 00026 #define _verror_h_ 00027 00028 #ifdef IPMGEMPLUGIN 00029 00030 #include <string> 00031 00032 using namespace std; 00033 typedef string gstring; 00034 static const size_t npos = string::npos; 00035 // static const size_t npos = static_cast<size_t>(-1); 00036 // static const size_t npos=32767; /wp sergey 2004 from below assignment 00037 00038 void strip(string& str); 00039 00040 #else 00041 00042 #include "gstring.h" 00043 00044 #endif 00045 00046 struct TError 00047 { 00048 gstring mess; 00049 gstring title; 00050 TError() 00051 {} 00052 00053 TError(const gstring& titl, const gstring& msg): 00054 mess(msg), 00055 title(titl) 00056 {} 00057 00058 virtual ~TError() 00059 {} 00060 00061 }; 00062 00063 00064 struct TFatalError: 00065 public TError 00066 { 00067 TFatalError() 00068 {} 00069 00070 TFatalError(TError& err): 00071 TError(err) 00072 {} 00073 00074 TFatalError(const gstring& titl, const gstring& msg): 00075 TError( titl, msg ) 00076 {} 00077 00078 }; 00079 00080 00081 inline 00082 void Error(const gstring& title, const gstring& message) 00083 { 00084 throw TError(title, message); 00085 } 00086 00087 inline 00088 void ErrorIf(bool error, const gstring& title, const gstring& message) 00089 { 00090 if(error) 00091 throw TError(title, message); 00092 } 00093 00094 00095 #endif 00096 // _verror_h 00097