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: OFStreamExpression.hpp,v 1.3 2007/02/08 23:19:38 delpinux Exp $ 00019 00020 #ifndef OFSTREAM_EXPRESSION_HPP 00021 #define OFSTREAM_EXPRESSION_HPP 00022 00023 #include <Expression.hpp> 00024 #include <StringExpression.hpp> 00025 #include <ErrorHandler.hpp> 00026 00027 #include <fstream> 00028 00036 class OFStreamExpression 00037 : public Expression 00038 { 00039 public: 00040 enum Type { 00041 undefined, 00042 value, 00043 variable 00044 }; 00045 00046 protected: 00047 const Type __type; 00048 ReferenceCounting<std::ofstream> __fout; 00049 00050 virtual std::ostream& 00051 put(std::ostream & os) const 00052 { 00053 return os; 00054 } 00055 00056 public: 00057 00063 std::ofstream* ofstream() 00064 { 00065 if (__type == undefined) { 00066 throw ErrorHandler(__FILE__,__LINE__, 00067 "using undefined stream", 00068 ErrorHandler::normal); 00069 } 00070 return __fout; 00071 } 00072 00073 OFStreamExpression(const OFStreamExpression::Type& type) 00074 : Expression(Expression::ofstreamexpression), 00075 __type(type), 00076 __fout(0) 00077 { 00078 ; 00079 } 00080 00081 OFStreamExpression(const OFStreamExpression& ofs) 00082 : Expression(ofs), 00083 __type(ofs.__type), 00084 __fout(ofs.__fout) 00085 { 00086 ; 00087 } 00088 00089 virtual ~OFStreamExpression() 00090 { 00091 ; 00092 } 00093 }; 00094 00095 #endif // OFSTREAM_EXPRESSION_HPP
1.5.6