file_format.h

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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.