1 #ifndef __JEEP__JEEPTOOLKIT__
2 #define __JEEP__JEEPTOOLKIT__
22 namespace JPP {
using namespace JEEP; }
30 static const char*
const PATH =
"PATH";
31 static const char*
const SHELL =
"SHELL";
46 inline std::string
strip(
const std::string& file_name)
50 string::const_iterator p = file_name. begin();
51 string::const_reverse_iterator q = file_name.rbegin();
53 for ( ; p != file_name.end() && q != file_name.rend() && isspace(*p); ++p) {}
54 for ( ; p != file_name.end() && q != file_name.rend() && isspace(*q); ++q) {}
56 return string(p,q.base());
72 if (pos != string::npos)
73 return file_name.substr(pos + 1);
89 const string buffer =
strip(file_name);
92 if (pos != string::npos)
93 return buffer.substr(pos + 1);
105 inline std::string
getPath(
const std::string& file_name)
109 const string buffer =
strip(file_name);
112 if (pos != string::npos)
113 return buffer.substr(0, pos + 1);
126 inline std::string
getFilename(
const std::string& path,
const std::string& file_name)
130 const string buffer =
strip(path);
132 if (buffer.empty()) {
134 return strip(file_name);
138 return buffer +
strip(file_name);
158 inline std::string
getPath(
const std::string& variable,
const std::string& file_name)
166 const string buffer(getenv(variable.c_str()));
168 if (!buffer.empty()) {
175 path = buffer.substr(pos,len);
177 }
while (!ifstream(
getFilename(path, file_name).c_str()).good() && len != string::npos && (pos += len + 1) != buffer.length());
181 if (ifstream(
getFilename(path, file_name).c_str()).good())
195 inline std::string
getFullFilename(
const std::string& variable,
const std::string& file_name)
213 if (pos != string::npos)
214 return type_name.substr(0, pos);
232 if (pos != string::npos)
233 return type_name.substr(pos + 2);
251 if (pos != string::npos)
252 return file_name.substr(0, pos);
265 inline T*
open(
const std::string& file_name);
275 inline std::istream*
open(
const std::string& file_name)
283 return new ifstream (file_name.c_str());
296 inline std::ostream*
open(
const std::string& file_name)
304 return new ofstream (file_name.c_str());
320 if (dynamic_cast<ifstream*> (pf) != NULL) {
dynamic_cast<ifstream*
> (pf)->
close();
return; }
321 if (dynamic_cast<igzstream*>(pf) != NULL) {
dynamic_cast<igzstream*
>(pf)->
close();
return; }
335 if (dynamic_cast<ofstream*> (pf) != NULL) {
dynamic_cast<ofstream*
> (pf)->
close();
return; }
336 if (dynamic_cast<ogzstream*>(pf) != NULL) {
dynamic_cast<ogzstream*
>(pf)->
close();
return; }
static const char *const TYPENAME_SEPARATOR
type name separator
static const char *const LD_LIBRARY_PATH
Nick names of environment variables.
std::string getPath(const std::string &file_name)
Get path, i.e.
std::string getNamespace(const std::string &type_name)
Get name space, i.e.
T * open(const std::string &file_name)
Open file.
static const char PROTOCOL_SEPARATOR
protocol separator
std::string getClassname(const std::string &type_name)
Get type name, i.e.
void close(std::istream *pf)
Close file.
std::string strip(const std::string &file_name)
Strip leading and trailing white spaces from file name.
std::string getProtocol(const std::string &file_name)
Get protocol, i.e.
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e.
static const char FILENAME_SEPARATOR
file name separator
static const char PATHLIST_SEPARATOR
path list separator
std::string getFilename(const std::string &file_name)
Get file name part, i.e.
std::string getFullFilename(const std::string &variable, const std::string &file_name)
Get full file name (see JEEP::getPath).
static const char *const SHELL
SHELL.
static const char PATHNAME_SEPARATOR
path name separator
static const char *const PATH
binary file paths