ParFilename.h

00001 #ifndef ParFilename_H
00002 #define ParFilename_H
00003 
00004 // --8<--8<--8<--8<--
00005 //
00006 // Copyright (C) 2006 Smithsonian Astrophysical Observatory
00007 //
00008 // This file is part of paramxx
00009 //
00010 // paramxx is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public License
00012 // as published by the Free Software Foundation; either version 2
00013 // of the License, or (at your option) any later version.
00014 //
00015 // paramxx is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU General Public License
00021 // along with this program; if not, write to the 
00022 //       Free Software Foundation, Inc. 
00023 //       51 Franklin Street, Fifth Floor
00024 //       Boston, MA  02110-1301, USA
00025 //
00026 // -->8-->8-->8-->8--
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

Generated on Thu Oct 2 17:54:19 2008 for paramxx by  doxygen 1.5.6