00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 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 int o2scl_make_tfile(std::string &fname, int st=0); 00040 00041 /** 00042 \brief Class for output file formats [abstract base] 00043 */ 00044 class out_file_format { 00045 public: 00046 00047 virtual ~out_file_format() {} 00048 00049 /** \brief Output a bool variable 00050 */ 00051 virtual int bool_out(bool dat, std::string name="")=0; 00052 00053 /** \brief Output a char variable 00054 */ 00055 virtual int char_out(char dat, std::string name="")=0; 00056 00057 /** \brief Output a float variable 00058 */ 00059 virtual int float_out(float dat, std::string name="")=0; 00060 00061 /** \brief Output a double variable 00062 */ 00063 virtual int double_out(double dat, std::string name="")=0; 00064 00065 /** \brief Output an int variable 00066 */ 00067 virtual int int_out(int dat, std::string name="")=0; 00068 00069 /** \brief Output an long variable 00070 */ 00071 virtual int long_out(unsigned long int dat, std::string name="")=0; 00072 00073 /** \brief Output a string 00074 */ 00075 virtual int string_out(std::string dat, std::string name="")=0; 00076 00077 /** \brief Output a word 00078 */ 00079 virtual int word_out(std::string dat, std::string name="")=0; 00080 00081 /** \brief Start object output 00082 */ 00083 virtual int start_object(std::string type, std::string name="")=0; 00084 00085 /** \brief End object output 00086 */ 00087 virtual int end_object()=0; 00088 00089 /** \brief End a line of output 00090 */ 00091 virtual int end_line()=0; 00092 00093 /** \brief Output initialization */ 00094 virtual int init_file()=0; 00095 00096 /// Finish the file 00097 virtual int clean_up()=0; 00098 00099 }; 00100 00101 /** 00102 \brief Class for input file formats [abstract base] 00103 */ 00104 class in_file_format { 00105 public: 00106 00107 virtual ~in_file_format() {} 00108 00109 /** \brief Input a bool variable 00110 */ 00111 virtual int bool_in(bool &dat, std::string name="")=0; 00112 00113 /** \brief Input a char variable 00114 */ 00115 virtual int char_in(char &dat, std::string name="")=0; 00116 00117 /** \brief Input a double variable 00118 */ 00119 virtual int double_in(double &dat, std::string name="")=0; 00120 00121 /** \brief Input a float variable 00122 */ 00123 virtual int float_in(float &dat, std::string name="")=0; 00124 00125 /** \brief Input an int variable 00126 */ 00127 virtual int int_in(int &dat, std::string name="")=0; 00128 00129 /** \brief Input an long variable 00130 */ 00131 virtual int long_in(unsigned long int &dat, std::string name="")=0; 00132 00133 /** \brief Input a string variable 00134 */ 00135 virtual int string_in(std::string &dat, std::string name="")=0; 00136 00137 /** \brief Input a word variable 00138 */ 00139 virtual int word_in(std::string &dat, std::string name="")=0; 00140 00141 /// Start object input 00142 virtual int start_object(std::string &type, std::string &name)=0; 00143 00144 /** \brief Skip the present object for the next call to read_type(). 00145 */ 00146 virtual int skip_object()=0; 00147 00148 /// End object input 00149 virtual int end_object()=0; 00150 00151 /** \brief Read initialization */ 00152 virtual int init_file()=0; 00153 00154 /// Finish file input 00155 virtual int clean_up()=0; 00156 }; 00157 00158 } 00159 00160 #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