o_f_stream.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library 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 GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_OFSTREAM_H 00021 #define LIBMESH_OFSTREAM_H 00022 00023 // Local Includes 00024 #include "libmesh/libmesh_common.h" 00025 00026 // C++ includes 00027 #include <fstream> 00028 #include <string> 00029 #include <vector> 00030 00031 /* 00032 * Some compilers, at least HP \p aCC do not even 00033 * accept empty classes derived from \p std::ostringstream. 00034 * Therefore, resort to preprocessor definitions. 00035 */ 00036 00037 #ifndef LIBMESH_BROKEN_IOSTREAM 00038 /* 00039 * --------------------------------------------------------------------------------- 00040 * Everything for a clean iostream 00041 */ 00042 00043 # include <iomanip> 00044 00045 /* 00046 * Outputs \p Real \p d with width 00047 * \p v in scientific format to stream \p o. 00048 */ 00049 # define OFSRealscientific(o,v,d) (o) << std::setprecision(v) << std::scientific << (d) 00050 00051 /* 00052 * Outputs \p Number \p d, (note that \p Number 00053 * may be either real or complex) with width 00054 * \p v in scientific format to stream \p o. 00055 */ 00056 # if defined(LIBMESH_USE_COMPLEX_NUMBERS) 00057 # define OFSNumberscientific(o,v,d) (o) << std::setprecision(v) << std::scientific << (d).real() << " " \ 00058 << std::setprecision(v) << std::scientific << (d).imag() 00059 # else 00060 # define OFSNumberscientific(o,v,d) (o) << std::setprecision(v) << std::scientific << (d) 00061 # endif 00062 00063 /* 00064 * class alias 00065 */ 00066 # define OFStream std::ofstream 00067 00068 00069 #else 00070 /* 00071 * --------------------------------------------------------------------------------- 00072 * Everything for broken iostream 00073 */ 00074 00075 # include <cstdio> 00076 00077 /* 00078 * Outputs \p Real \p d with width 00079 * \p v in scientific format to stream \p o. 00080 */ 00081 # define OFSRealscientific(o,v,d) (o).scientific( (v), (d) ) 00082 00083 /* 00084 * Outputs \p Number \p d, (note that \p Number 00085 * may be either real or complex) with width 00086 * \p v in scientific format to stream \p o. 00087 */ 00088 # define OFSNumberscientific(o,v,d) (o).scientific( (v), (d) ) 00089 00090 // /* 00091 // * class alias 00092 // */ 00093 // # define OFSOFStream OFStream 00094 00095 00096 namespace libMesh 00097 { 00098 00099 00106 // ------------------------------------------------------------ 00107 // OFStream class definition 00108 class OFStream : public std::ofstream 00109 { 00110 public: 00111 00115 OFStream () 00116 { 00117 // [JWP] TODO: I will remove this class at the next libmesh 00118 // release or on on March 21, 2013, whichever comes first. 00119 libmesh_deprecated(); 00120 } 00121 00125 ~OFStream () {} 00126 00130 typedef std::string::size_type sizetype; 00131 00137 template <typename T> 00138 OFStream& scientific (const sizetype w, 00139 const T r); 00140 00141 }; 00142 00143 00144 } // namespace libMesh 00145 00146 // ------------------------------------------------------------ 00147 // OFStream inline methods 00148 00149 00150 #endif // ifndef ... else ... LIBMESH_BROKEN_IOSTREAM 00151 00152 00153 00154 #endif // LIBMESH_OFSTREAM_H 00155
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:48 UTC
Hosted By: