1 #ifndef __JEEP__JEEPTOOLKIT__
2 #define __JEEP__JEEPTOOLKIT__
25 namespace JPP {
using namespace JEEP; }
35 static const char*
const PATH =
"PATH";
36 static const char*
const SHELL =
"SHELL";
66 inline std::string
setWildCard(
const std::string& file_name,
const std::string& value)
71 string buffer = file_name;
75 if (pos == string::npos) {
79 return buffer.replace(pos, 1, value);
89 inline std::string
strip(
const std::string& file_name)
93 string::const_iterator p = file_name. begin();
94 string::const_reverse_iterator q = file_name.rbegin();
96 for ( ; p != file_name.end() && q != file_name.rend() && isspace(*p); ++p) {}
97 for ( ; p != file_name.end() && q != file_name.rend() && isspace(*q); ++q) {}
99 return string(p,q.base());
115 if (pos != string::npos)
116 return file_name.substr(pos + 1);
132 const string buffer =
strip(file_name);
135 if (pos != string::npos)
136 return buffer.substr(pos + 1);
148 inline std::string
getPath(
const std::string& file_name)
152 const string buffer =
strip(file_name);
155 if (pos != string::npos)
156 return buffer.substr(0, pos + 1);
172 const string buffer =
strip(path);
199 return strip(file_name);
201 return buffer +
strip(file_name);
216 inline std::string
getPath(
const std::string& variable,
const std::string& file_name)
224 const char*
const p = getenv(variable.c_str());
228 const string buffer(p);
230 if (!buffer.empty()) {
237 path = buffer.substr(pos,len);
239 }
while (!ifstream(
getFilename(
path, file_name).c_str()).good() && len != string::npos && (pos += len + 1) != buffer.length());
258 inline std::string
getFullFilename(
const std::string& variable,
const std::string& file_name)
276 if (pos != string::npos)
277 return type_name.substr(0, pos);
295 if (pos != string::npos)
296 return type_name.substr(pos + 2);
314 if (pos != string::npos)
315 return file_name.substr(0, pos);
328 const char*
const url = getenv(
JPP_PAGES);
330 return std::string(url != NULL ? url :
"");
341 inline T*
open(
const std::string& file_name);
351 inline std::istream*
open(
const std::string& file_name)
359 return new ifstream (file_name.c_str());
372 inline std::ostream*
open(
const std::string& file_name)
380 return new ofstream (file_name.c_str());
396 if (dynamic_cast<ifstream*> (pf) != NULL) {
dynamic_cast<ifstream*
> (pf)->
close();
return; }
397 if (dynamic_cast<igzstream*>(pf) != NULL) {
dynamic_cast<igzstream*
>(pf)->
close();
return; }
411 if (dynamic_cast<ofstream*> (pf) != NULL) {
dynamic_cast<ofstream*
> (pf)->
close();
return; }
412 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. part before last JEEP::PATHNAME_SEPARATOR if any.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
std::string getFullPath(const std::string &path)
Get full path, i.e. add JEEP::PATHNAME_SEPARATOR if necessary.
std::string getNamespace(const std::string &type_name)
Get name space, i.e. part before JEEP::TYPENAME_SEPARATOR.
T * open(const std::string &file_name)
Open file.
Exception for missing value.
static const char PROTOCOL_SEPARATOR
protocol separator
std::string getClassname(const std::string &type_name)
Get type name, i.e. part after JEEP::TYPENAME_SEPARATOR.
void close(std::istream *pf)
Close file.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
std::string getURL()
Get URL of document pages.
$WORKDIR driver txt done cat $WORKDIR driver txt<< EOFprocess ${DATAFILTER}$FILTER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&(JDataFilter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAFILTER}-P $PORT</dev/null > &/dev/null &))';process ${DATAWRITER}$WRITER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&(JDataWriter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAWRITER}</dev/null > &/dev/null &))';print enterevent ev_init{RC_CMD}event ev_reset{RC_CMD}event ev_init{RC_CMD}event ev_configure{RC_DFLTR%<$WORKDIR/ev_configure_datafilter.txt > RC_DQSIM<$WORKDIR/ev_configure_dqsimulator.txt > RC_DWRT path
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. part before first JEEP::PROTOCOL_SEPARATOR if any.
std::string setWildCard(const std::string &file_name, const std::string &value)
Get file name by setting wild card to given value.
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e. part after last JEEP::FILENAME_SEPARATOR if any.
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. part after last JEEP::PATHNAME_SEPARATOR if any.
static const char *const JPP_PAGES
Jpp document pages.
std::string getFullFilename(const std::string &variable, const std::string &file_name)
Get full file name (see JEEP::getPath).
static const char FILENAME_WILDCARD
wild card character for file name substitution
static const char PATHNAME_SEPARATOR
path name separator
static const char *const PATH
binary file paths
bool hasWildCard(const std::string &file_name)
Check presence of wild card.