ParFilename.h
00001 #ifndef ParFilename_H
00002 #define ParFilename_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 #include <string>
00030 #include <vector>
00031
00032 #include "ParFileException.h"
00033
00034 using namespace std;
00035
00044 class ParFilename {
00045
00049 friend ostream& operator << ( ostream& os, ParFilename& a ) {
00050 a.print( os );
00051 return os;
00052 }
00053
00057 friend ostream& operator << ( ostream& os, ParFilename* a ) {
00058 os << *a;
00059 return os;
00060 }
00061
00062 enum ParFileDelimit { pfiles_delimit = ':', dir_delimit = '/' };
00063
00064 public:
00065
00069 ~ParFilename( void ) { }
00070
00074 ParFilename( ) { }
00075
00079 ParFilename( int argc, char** argv, const char* file = NULL )
00080 throw ( ParFileException );
00081
00085 string get_filename( void ) { return filename; }
00086
00090 void init_ParFilename( int argc, char** argv,
00091 const char* file = NULL ) throw ( ParFileException );
00092
00093 static vector< string > parse_string( string& str, char delimit );
00094
00095 void print( ostream& os ) {
00096 os << filename;
00097 }
00098
00099 private:
00100
00104 string filename;
00105
00106 int accessible( const char* str ) throw ( ParFileException );
00107
00108 void copy_pfile( const char* str ) const throw ( ParFileException );
00109
00117 void check_environment_variables( ) throw ( ParFileException );
00118
00125 int find_pfile( const char* name ) throw ( ParFileException );
00126
00127 const char* get_basename( const char* name ) const ;
00128
00132 ParFilename( const ParFilename& pf );
00133
00137 ParFilename& operator = ( const ParFilename& pf );
00138
00139 };
00140
00141 #define PFILE "pfile="
00142
00143 #endif