00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef O2SCL_FILE_FORMAT_H 00024 #define O2SCL_FILE_FORMAT_H 00025 00026 #include <iostream> 00027 #include <fstream> 00028 #include <sstream> 00029 00030 #include <o2scl/lib_settings.h> 00031 00032 #ifndef DOXYGENP 00033 namespace o2scl { 00034 #endif 00035 00036 /** 00037 \brief Make a temporary file 00038 00039 \todo This is a temporary hack until a suitable replacement is 00040 found. 00041 */ 00042 int o2scl_make_tfile(std::string &fname, int st=0); 00043 00044 /** 00045 \brief Class for output file formats [abstract base] 00046 00047 This class is experimental. 00048 */ 00049 class out_file_format { 00050 public: 00051 00052 virtual ~out_file_format() {} 00053 00054 /** \brief Output a bool variable 00055 */ 00056 virtual int bool_out(bool dat, std::string name="")=0; 00057 00058 /** \brief Output a char variable 00059 */ 00060 virtual int char_out(char dat, std::string name="")=0; 00061 00062 /** \brief Output a float variable 00063 */ 00064 virtual int float_out(float dat, std::string name="")=0; 00065 00066 /** \brief Output a double variable 00067 */ 00068 virtual int double_out(double dat, std::string name="")=0; 00069 00070 /** \brief Output an int variable 00071 */ 00072 virtual int int_out(int dat, std::string name="")=0; 00073 00074 /** \brief Output an long variable 00075 */ 00076 virtual int long_out(unsigned long int dat, std::string name="")=0; 00077 00078 /** \brief Output a string 00079 */ 00080 virtual int string_out(std::string dat, std::string name="")=0; 00081 00082 /** \brief Output a word 00083 */ 00084 virtual int word_out(std::string dat, std::string name="")=0; 00085 00086 /** \brief Start object output 00087 */ 00088 virtual int start_object(std::string type, std::string name="")=0; 00089 00090 /** \brief End object output 00091 */ 00092 virtual int end_object()=0; 00093 00094 /** \brief End a line of output 00095 */ 00096 virtual int end_line()=0; 00097 00098 /** \brief Output initialization */ 00099 virtual int init_file()=0; 00100 00101 /// Finish the file 00102 virtual int clean_up()=0; 00103 00104 }; 00105 00106 /** 00107 \brief Class for input file formats [abstract base] 00108 00109 This class is experimental. 00110 */ 00111 class in_file_format { 00112 public: 00113 00114 virtual ~in_file_format() {} 00115 00116 /** \brief Input a bool variable 00117 */ 00118 virtual int bool_in(bool &dat, std::string name="")=0; 00119 00120 /** \brief Input a char variable 00121 */ 00122 virtual int char_in(char &dat, std::string name="")=0; 00123 00124 /** \brief Input a double variable 00125 */ 00126 virtual int double_in(double &dat, std::string name="")=0; 00127 00128 /** \brief Input a float variable 00129 */ 00130 virtual int float_in(float &dat, std::string name="")=0; 00131 00132 /** \brief Input an int variable 00133 */ 00134 virtual int int_in(int &dat, std::string name="")=0; 00135 00136 /** \brief Input an long variable 00137 */ 00138 virtual int long_in(unsigned long int &dat, std::string name="")=0; 00139 00140 /** \brief Input a string variable 00141 */ 00142 virtual int string_in(std::string &dat, std::string name="")=0; 00143 00144 /** \brief Input a word variable 00145 */ 00146 virtual int word_in(std::string &dat, std::string name="")=0; 00147 00148 /// Start object input 00149 virtual int start_object(std::string &type, std::string &name)=0; 00150 00151 /** \brief Skip the present object for the next call to read_type(). 00152 */ 00153 virtual int skip_object()=0; 00154 00155 /// End object input 00156 virtual int end_object()=0; 00157 00158 /** \brief Read initialization */ 00159 virtual int init_file()=0; 00160 00161 /// Finish file input 00162 virtual int clean_up()=0; 00163 }; 00164 00165 } 00166 00167 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page