ParFile.h
00001 #ifndef PARFILE_H
00002 #define PARFILE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <iostream>
00029
00030 #include "Par.h"
00031 #include "ParFilename.h"
00032
00033 using namespace std;
00034
00038 class ParFile {
00039
00043 friend ostream& operator << ( ostream& os, ParFile& parFile ) {
00044 parFile.print( os );
00045 return os;
00046 }
00047
00051 friend ostream& operator << ( ostream& os, ParFile* parFile ) {
00052 parFile->print( os );
00053 return os;
00054 }
00055
00056 public:
00057
00061 ~ParFile( );
00062
00066 ParFile( ) : parameters( NULL ) { }
00067
00078 ParFile( int argc, char** argv, const char* file=NULL )
00079 throw ( ParFileException, Exception );
00080
00085 string get_filename( ) { return parFilename.get_filename( ); }
00086
00095 void init_ParFile( int argc, char** argv, const char* file=NULL )
00096 throw ( ParFileException, Exception );
00097
00099 Par* get_par( const char* name ) const throw ( ParFileException );
00100
00107 void print( ostream& os ) const;
00108
00115 bool pgetb( const char* name ) const throw ( ParFileException );
00116
00123 double pgetd( const char* name ) const throw ( ParFileException );
00124
00131 int pgeti( const char* name ) const throw ( ParFileException );
00132
00139 long pgetl( const char* name ) const throw ( ParFileException );
00140
00148 void pgetstr( const char* name, char result[], size_t size )
00149 const throw ( ParFileException );
00150
00157 string pgetstring( const char* name ) const throw ( ParFileException );
00158
00160 void pget( const char* name, bool& result ) const throw ( ParFileException );
00161
00163 void pget( const char* name, double& result ) const
00164 throw ( ParFileException );
00165
00167 void pget( const char* name, int& result ) const throw ( ParFileException );
00168
00170 void pget( const char* name, long& result ) const throw ( ParFileException );
00171
00173 void pget( const char* name, char result[], size_t ) const
00174 throw ( ParFileException );
00175
00177 void pget( const char* name, string& rult ) const throw ( ParFileException );
00178
00184 int traverse( int (*fct)( Par* ) ) const;
00185
00186 static int is_blank( const char* str );
00187
00188 static int is_comment( const char* str, char delimit='#' );
00189
00190 private:
00191
00192
00193 bool return_on_error;
00194
00195
00196 ParFilename parFilename;
00197
00198
00199 Par** parameters;
00200
00201 void get_mode_of_parameter_file( int argc, char** argv )
00202 throw ( ParFileException );
00203
00204 bool is_duplicate_cmdline_args( int argc, char** argv )
00205 throw( ParFileException );
00206
00207 bool is_parlist( string& cmdline_name, string& cmdline_value );
00208
00209 void querry_user( Par* par, char* str );
00210
00214 void read_ParFile( int argc, char** argv, const char* file )
00215 throw ( ParFileException );
00216
00217 void setpar( char* ) throw ( ParFileException, Exception );
00218
00219 void set_return_on_error( const string& str );
00220
00224 Par* search_name( const char* str ) const
00225 throw ( ParFileException );
00226
00230 ParFile( const ParFile& pf );
00231
00235 ParFile& operator = ( const ParFile& pf );
00236
00237 };
00238
00249 #endif