#include <FileInPath.h>
Public Types | |
typedef std::string | String |
Public Member Functions | |
FileInPath (const String &ipath, const String &ifile) | |
constructor | |
FileInPath (const FileInPath &rh) | |
const String & | name () const |
return full name | |
std::ifstream * | operator() () |
return stream | |
FileInPath & | operator= (const FileInPath &rh) |
and usual operator | |
~FileInPath () | |
destructor | |
Private Member Functions | |
void | init (const String &ipath, const String &ifile) |
Private Attributes | |
std::vector< String > | directories |
String | file |
own_ptr< std::ifstream > | in |
Static Private Attributes | |
static const String | semicolon |
open the first file found in a ":"-separated list of files (path)
Definition at line 14 of file FileInPath.h.
typedef std::string FileInPath::String |
Definition at line 16 of file FileInPath.h.
FileInPath::FileInPath | ( | const FileInPath & | rh | ) |
Definition at line 25 of file FileInPath.cc.
References file, own_ptr< X, P >::get(), and in.
: directories(rh.directories), file(rh.file) { if (rh.in.get()) in = own_ptr<std::ifstream>(new std::ifstream(file.c_str())); }
FileInPath::~FileInPath | ( | ) |
Definition at line 12 of file FileInPath.cc.
References directories, file, compare_using_db::ifile, in, own_ptr< X, P >::release(), and semicolon.
Referenced by FileInPath().
{ if (ipath.empty()||ifile.empty()) return; directories = Tokenizer(semicolon,ipath); typedef std::vector<std::string>::const_iterator Itr; for (Itr d=directories.begin(); d!=directories.end(); d++) { file = *d; file += "/"; file += ifile; in = own_ptr<std::ifstream>(new std::ifstream(file.c_str())); if (in->good()) break; } if (!in->good()) { in.release(); file="";} }
const String& FileInPath::name | ( | void | ) | const [inline] |
return full name
Definition at line 34 of file FileInPath.h.
References file.
Referenced by CSCGasCollisions::readCollisionTable().
{ return file;}
std::ifstream* FileInPath::operator() | ( | ) | [inline] |
return stream
Definition at line 31 of file FileInPath.h.
References own_ptr< X, P >::get(), and in.
FileInPath & FileInPath::operator= | ( | const FileInPath & | rh | ) |
and usual operator
Definition at line 31 of file FileInPath.cc.
References directories, file, own_ptr< X, P >::get(), and in.
{ directories = rh.directories; file = rh.file; if (rh.in.get()&&(!file.empty())) in = own_ptr<std::ifstream>(new std::ifstream(file.c_str())); return *this; }
std::vector<String> FileInPath::directories [private] |
Definition at line 41 of file FileInPath.h.
Referenced by init(), and operator=().
String FileInPath::file [private] |
Definition at line 42 of file FileInPath.h.
Referenced by FileInPath(), init(), name(), and operator=().
own_ptr<std::ifstream> FileInPath::in [private] |
Definition at line 43 of file FileInPath.h.
Referenced by FileInPath(), init(), operator()(), and operator=().
const std::string FileInPath::semicolon [static, private] |
Definition at line 39 of file FileInPath.h.
Referenced by init().