00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2001, 2002, 2003 Stéphane Del Pino 00003 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2, or (at your option) 00007 // any later version. 00008 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software Foundation, 00016 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 // $Id: StringExpression.hpp,v 1.3 2003/10/18 16:07:27 delpinux Exp $ 00019 00020 #ifndef _STRING_EXPRESSION_HPP_ 00021 #define _STRING_EXPRESSION_HPP_ 00022 00023 #include <Expression.hpp> 00024 #include <cmath> 00025 00026 #include <Variable.hpp> 00027 00028 class StringExpression 00029 : public Expression 00030 { 00031 private: 00032 std::ostream& put(std::ostream& os) const 00033 { 00034 os << this->value(); 00035 return os; 00036 } 00037 00038 public: 00043 virtual const char* value() const = 0; 00044 00045 StringExpression(const StringExpression& e) 00046 : Expression(e) 00047 { 00048 ; 00049 } 00050 00051 StringExpression() 00052 : Expression(Expression::string) 00053 { 00054 ; 00055 } 00056 00057 virtual ~StringExpression() 00058 { 00059 ; 00060 } 00061 }; 00062 00063 class StringExpressionValue 00064 : public StringExpression 00065 { 00066 private: 00067 std::string __stringExpressionValue; 00068 00069 public: 00070 const char* value() const 00071 { 00072 return __stringExpressionValue.c_str(); 00073 } 00074 00075 void execute() 00076 { 00077 ; 00078 } 00079 00080 StringExpressionValue(const std::string& d) 00081 : __stringExpressionValue(d) 00082 { 00083 ; 00084 } 00085 00086 StringExpressionValue(const StringExpressionValue& re) 00087 : __stringExpressionValue(re.__stringExpressionValue) 00088 { 00089 ; 00090 } 00091 00092 ~StringExpressionValue() 00093 { 00094 ; 00095 } 00096 }; 00097 00098 class StringExpressionConcat 00099 : public StringExpression 00100 { 00101 private: 00102 std::string __stringExpressionValue; 00103 ReferenceCounting<StringExpression> __string1; 00104 ReferenceCounting<StringExpression> __string2; 00105 00106 public: 00107 const char* value() const 00108 { 00109 return __stringExpressionValue.c_str(); 00110 } 00111 00112 void execute() 00113 { 00114 (*__string1).execute(); 00115 (*__string2).execute(); 00116 __stringExpressionValue = (*__string1).value(); 00117 __stringExpressionValue += (*__string2).value(); 00118 } 00119 00120 StringExpressionConcat(ReferenceCounting<StringExpression> s1, 00121 ReferenceCounting<StringExpression> s2) 00122 : __string1(s1), 00123 __string2(s2) 00124 { 00125 ; 00126 } 00127 00128 StringExpressionConcat(const StringExpressionConcat& re) 00129 : __stringExpressionValue(re.__stringExpressionValue), 00130 __string1(re.__string1), 00131 __string2(re.__string2) 00132 { 00133 ; 00134 } 00135 00136 ~StringExpressionConcat() 00137 { 00138 ; 00139 } 00140 }; 00141 00142 class RealExpression; 00143 class StringExpressionReal 00144 : public StringExpression 00145 { 00146 private: 00147 std::string __stringExpressionValue; 00148 ReferenceCounting<RealExpression> __realExpression; 00149 00150 public: 00151 const char* value() const 00152 { 00153 return __stringExpressionValue.c_str(); 00154 } 00155 00156 void execute(); 00157 00158 StringExpressionReal(ReferenceCounting<RealExpression> r); 00159 00160 StringExpressionReal(const StringExpressionReal& re); 00161 00162 ~StringExpressionReal(); 00163 }; 00164 00165 00166 class StringExpressionVariable 00167 : public StringExpression 00168 { 00169 private: 00170 ReferenceCounting<StringVariable> __stringVariable; 00171 real_t __value; 00172 00173 public: 00174 const char* value() const; 00175 00176 void execute(); 00177 00178 StringExpressionVariable(ReferenceCounting<StringVariable> r); 00179 00180 StringExpressionVariable(const StringExpressionVariable& e); 00181 00182 ~StringExpressionVariable(); 00183 }; 00184 00185 #endif // _REAL_EXPRESSION_HPP_ 00186
1.5.6