Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Enumerations | Functions | Variables
JEEP Namespace Reference

General puprpose classes and methods. More...

Classes

class  JArgs
 Data structure to store command line arguments. More...
 
struct  JComment
 Auxiliary class for comment. More...
 
class  JCommunicator
 Auxiliary class to control standard input and output. More...
 
struct  JFunctionAdaptorHelper
 Auxiliary base class for function adaptor. More...
 
struct  JFunctionAdaptor
 Function adaptor. More...
 
struct  JFunctionAdaptor< JReturn_t, JFirst_t, void >
 Function adaptor for function with one argument. More...
 
struct  JMessage
 Auxiliary class for handling debug parameter within a class. More...
 
class  JPropertiesElementInterface
 Interface for I/O of properties element. More...
 
class  JPropertiesTemplateElement
 Template class for I/O of properties element. More...
 
class  JPropertiesTemplateElement< const T >
 Template specialisation of JPropertiesTemplateElement for const data type. More...
 
class  JPropertiesElement
 The property value class. More...
 
class  JProperties
 Utility class to parse parameter values. More...
 
class  JPropertiesTemplateElement< JProperties::JFileReader >
 Template specialisation for JFileReader. More...
 
class  JPropertiesTemplateElement< JProperties >
 Template specialisation for JProperties. More...
 
class  JStatus
 Auxiliary class for status identifier. More...
 
class  JTimekeeper
 Time keeper. More...
 
class  JTimer
 Auxiliary class for CPU timing and usage. More...
 
class  JVersion
 Auxiliary class for version identifier. More...
 

Enumerations

enum  JMessage_t {
  debug_t = 3, status_t = 2, warning_t = 2, notice_t = 1,
  error_t = 0, fatal_t = 0
}
 Debug level. More...
 
enum  JPrintOption_t { SHORT_PRINT = 1, MEDIUM_PRINT = 2, LONG_PRINT = 3 }
 Print options. More...
 
enum  JScale_t {
  femto_t = -15, pico_t = -12, nano_t = -9, micro_t = -6,
  milli_t = -3, unit_t = 0, kilo_t = +3, mega_t = +6,
  giga_t = +9, tera_t = +12, peta_t = +15, exa_t = +18
}
 Enumeration for scaling of quantity. More...
 

Functions

template<class T >
bool compareObjects (const T &first, const T &second, JBool< true >)
 Comparison of comparable objects. More...
 
template<class T >
bool compareObjects (const T &first, const T &second, JBool< false >)
 Comparison of uncomparable objects. More...
 
template<class T >
bool compareObjects (const T &first, const T &second)
 Comparison of objects. More...
 
std::string strip (const std::string &file_name)
 Strip leading and trailing white spaces from file name. More...
 
std::string getFilenameExtension (const std::string &file_name)
 Get file name extension, i.e. More...
 
std::string getFilename (const std::string &file_name)
 Get file name part, i.e. More...
 
std::string getPath (const std::string &file_name)
 Get path, i.e. More...
 
std::string getFilename (const std::string &path, const std::string &file_name)
 Compose full file name and introduce JEEP::PATHNAME_SEPARATOR if needed. More...
 
std::string getPath (const std::string &variable, const std::string &file_name)
 Get selected path from environment variable for given file name. More...
 
std::string getFullFilename (const std::string &variable, const std::string &file_name)
 Get full file name (see JEEP::getPath). More...
 
std::string getNamespace (const std::string &type_name)
 Get name space, i.e. More...
 
std::string getClassname (const std::string &type_name)
 Get type name, i.e. More...
 
std::string getProtocol (const std::string &file_name)
 Get protocol, i.e. More...
 
template<class T >
T * open (const std::string &file_name)
 Open file. More...
 
template<>
std::istream * open (const std::string &file_name)
 Open file. More...
 
template<>
std::ostream * open (const std::string &file_name)
 Open file. More...
 
void close (std::istream *pf)
 Close file. More...
 
void close (std::ostream *pf)
 Close file. More...
 
template<class T >
int sign (const T &value)
 Get sign of value. More...
 
int getIndex ()
 Get index for user I/O manipulation. More...
 
std::ostream & getOstream ()
 Get output stream for conversion to std::string or C-string. More...
 
bool fail (std::istream &in)
 Check for stream state. More...
 
template<class T >
JPropertiesgetProperties (T &object, const JEquationParameters &parameters=JEquationParameters(), const int debug=1)
 Get properties of a given object. More...
 
template<class T >
JPropertiesgetProperties (const T &object, const JEquationParameters &parameters=JEquationParameters(), const int debug=1)
 Get properties of a given object. More...
 
double getValue (const JScale_t scale)
 Get numerical value corresponding to scale. More...
 
const char * getUnit (const int scale)
 Get textual unit corresponding to scale. More...
 
JScale_t getScale (const char unit)
 Get scale corresponding to textual unit. More...
 
template<class T >
std::istream & readObject (std::istream &in, T &object)
 Stream input of object. More...
 
template<class T >
std::ostream & writeObject (std::ostream &out, const T &object)
 Stream output of object. More...
 
template<class T >
std::ostream & writeObject (std::ostream &out, const char *prefix, const T &object, const char postfix)
 Stream output of object. More...
 
template<class JElement_t , class JAllocator_t >
std::istream & readObject (std::istream &in, std::vector< JElement_t, JAllocator_t > &object)
 Template specialisation of method readObject() for std::vector. More...
 
template<class JElement_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const std::vector< JElement_t, JAllocator_t > &object)
 Template specialisation of method writeObject() for std::vector. More...
 
template<class JElement_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const char *prefix, const std::vector< JElement_t, JAllocator_t > &object, const char postfix)
 Template specialisation of method writeObject() for std::vector. More...
 
template<class JElement_t , class JAllocator_t >
std::istream & readObject (std::istream &in, std::list< JElement_t, JAllocator_t > &object)
 Template specialisation of method readObject() for std::list. More...
 
template<class JElement_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const std::list< JElement_t, JAllocator_t > &object)
 Template specialisation of method writeObject() for std::list. More...
 
template<class JElement_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const char *prefix, const std::list< JElement_t, JAllocator_t > &object, const char postfix)
 Template specialisation of method writeObject() for std::list. More...
 
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::istream & readObject (std::istream &in, std::set< JElement_t, JComparator_t, JAllocator_t > &object)
 Template specialisation of method readObject() for std::set. More...
 
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const std::set< JElement_t, JComparator_t, JAllocator_t > &object)
 Template specialisation of method writeObject() for std::set. More...
 
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const char *prefix, const std::set< JElement_t, JComparator_t, JAllocator_t > &object, const char postfix)
 Template specialisation of method writeObject() for std::set. More...
 
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::istream & readObject (std::istream &in, std::multiset< JElement_t, JComparator_t, JAllocator_t > &object)
 Template specialisation of method readObject() for std::multiset. More...
 
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const std::multiset< JElement_t, JComparator_t, JAllocator_t > &object)
 Template specialisation of method writeObject() for std::multiset. More...
 
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const char *prefix, const std::multiset< JElement_t, JComparator_t, JAllocator_t > &object, const char postfix)
 Template specialisation of method writeObject() for std::multiset. More...
 
template<class JFirst_t , class JSecond_t >
std::istream & readObject (std::istream &in, std::pair< JFirst_t, JSecond_t > &object)
 Template specialisation of method readObject() for std::pair. More...
 
template<class JFirst_t , class JSecond_t >
std::ostream & writeObject (std::ostream &out, const std::pair< JFirst_t, JSecond_t > &object)
 Template specialisation of method writeObject() for std::pair. More...
 
template<class JFirst_t , class JSecond_t >
std::ostream & writeObject (std::ostream &out, const char *prefix, const std::pair< JFirst_t, JSecond_t > &object, const char postfix)
 Template specialisation of method writeObject() for std::pair. More...
 
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::istream & readObject (std::istream &in, std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &object)
 Template specialisation of method readObject() for std::map. More...
 
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &object)
 Template specialisation of method writeObject() for std::map. More...
 
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const char *prefix, const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &object, const char postfix)
 Template specialisation of method writeObject() for std::map. More...
 
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::istream & readObject (std::istream &in, std::multimap< JKey_t, JValue_t, JComparator_t, JAllocator_t > &object)
 Template specialisation of method readObject() for std::multimap. More...
 
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const std::multimap< JKey_t, JValue_t, JComparator_t, JAllocator_t > &object)
 Template specialisation of method writeObject() for std::multimap. More...
 
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::ostream & writeObject (std::ostream &out, const char *prefix, const std::multimap< JKey_t, JValue_t, JComparator_t, JAllocator_t > &object, const char postfix)
 Template specialisation of method writeObject() for std::multimap. More...
 
template<class T >
std::ostream & writeArray (std::ostream &out, const char *left, const char *right, const char *sep, T __begin, T __end)
 Write array of objects. More...
 
bool operator< (const JVersion &first, const JVersion &second)
 Less-than operator for versions. More...
 

Variables

static const char *const LD_LIBRARY_PATH = "LD_LIBRARY_PATH"
 Nick names of environment variables. More...
 
static const char *const PATH = "PATH"
 binary file paths More...
 
static const char *const SHELL = "SHELL"
 SHELL. More...
 
static const char PATHNAME_SEPARATOR = '/'
 path name separator More...
 
static const char PATHLIST_SEPARATOR = ':'
 path list separator More...
 
static const char FILENAME_SEPARATOR = '.'
 file name separator More...
 
static const char *const TYPENAME_SEPARATOR = "::"
 type name separator More...
 
static const char PROTOCOL_SEPARATOR = ':'
 protocol separator More...
 

Detailed Description

General puprpose classes and methods.

Author
mdejong

Enumeration Type Documentation

Debug level.

Enumerator
debug_t 

debug

status_t 

status

warning_t 

warning

notice_t 

notice

error_t 

error

fatal_t 

fatal; exit

Definition at line 25 of file JMessage.hh.

25  {
26 
27  debug_t = 3, //!< debug
28  status_t = 2, //!< status
29  warning_t = 2, //!< warning
30  notice_t = 1, //!< notice
31  error_t = 0, //!< error
32  fatal_t = 0 //!< fatal; exit
33  };
fatal; exit
Definition: JMessage.hh:32
debug
Definition: JMessage.hh:27
notice
Definition: JMessage.hh:30
warning
Definition: JMessage.hh:29
status
Definition: JMessage.hh:28
error
Definition: JMessage.hh:31

Print options.

Enumerator
SHORT_PRINT 

short print

MEDIUM_PRINT 

medium print

LONG_PRINT 

long print

Definition at line 37 of file JPrint.hh.

37  {
38  SHORT_PRINT = 1, //!< short print
39  MEDIUM_PRINT = 2, //!< medium print
40  LONG_PRINT = 3 //!< long print
41  };
long print
Definition: JPrint.hh:40
short print
Definition: JPrint.hh:38
medium print
Definition: JPrint.hh:39

Enumeration for scaling of quantity.

Enumerator
femto_t 

femto

pico_t 

pico

nano_t 

nano

micro_t 

micro

milli_t 

milli

unit_t 

unit

kilo_t 

kilo

mega_t 

mega

giga_t 

giga

tera_t 

tera

peta_t 

peta

exa_t 

exa

Definition at line 24 of file JScale.hh.

24  {
25 
26  femto_t = -15, //!< femto
27  pico_t = -12, //!< pico
28  nano_t = -9, //!< nano
29  micro_t = -6, //!< micro
30  milli_t = -3, //!< milli
31  unit_t = 0, //!< unit
32  kilo_t = +3, //!< kilo
33  mega_t = +6, //!< mega
34  giga_t = +9, //!< giga
35  tera_t = +12, //!< tera
36  peta_t = +15, //!< peta
37  exa_t = +18 //!< exa
38  };
exa
Definition: JScale.hh:37
micro
Definition: JScale.hh:29
giga
Definition: JScale.hh:34
kilo
Definition: JScale.hh:32
milli
Definition: JScale.hh:30
peta
Definition: JScale.hh:36
femto
Definition: JScale.hh:26
mega
Definition: JScale.hh:33
nano
Definition: JScale.hh:28
pico
Definition: JScale.hh:27
unit
Definition: JScale.hh:31
tera
Definition: JScale.hh:35

Function Documentation

template<class T >
bool JEEP::compareObjects ( const T &  first,
const T &  second,
JBool< true >   
)
inline

Comparison of comparable objects.

Parameters
firstfirst object
secondsecond object
Returns
true if objects are equal; else false

Definition at line 30 of file JComparisonToolkit.hh.

33  {
34  return first == second;
35  }
template<class T >
bool JEEP::compareObjects ( const T &  first,
const T &  second,
JBool< false >   
)
inline

Comparison of uncomparable objects.

Parameters
firstfirst object
secondsecond object
Returns
false

Definition at line 46 of file JComparisonToolkit.hh.

49  {
50  return false;
51  }
template<class T >
bool JEEP::compareObjects ( const T &  first,
const T &  second 
)
inline

Comparison of objects.

Parameters
firstfirst object
secondsecond object
Returns
true if objects are comparable and equal; else false

Definition at line 62 of file JComparisonToolkit.hh.

64  {
65  return compareObjects(first, second, JBool<JComparisonAvailable<T>::has_eq>());
66  }
bool compareObjects(const T &first, const T &second, JBool< true >)
Comparison of comparable objects.
std::string JEEP::strip ( const std::string &  file_name)
inline

Strip leading and trailing white spaces from file name.

Parameters
file_namefile name
Returns
file name

Definition at line 46 of file JeepToolkit.hh.

47  {
48  using namespace std;
49 
50  string::const_iterator p = file_name. begin();
51  string::const_reverse_iterator q = file_name.rbegin();
52 
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) {}
55 
56  return string(p,q.base());
57  }
std::string JEEP::getFilenameExtension ( const std::string &  file_name)
inline

Get file name extension, i.e.

part after last JEEP::FILENAME_SEPARATOR if any.

Parameters
file_namefile name
Returns
extension (excluding separator)

Definition at line 66 of file JeepToolkit.hh.

67  {
68  using namespace std;
69 
70  const size_t pos = file_name.rfind(FILENAME_SEPARATOR);
71 
72  if (pos != string::npos)
73  return file_name.substr(pos + 1);
74  else
75  return "";
76  }
static const char FILENAME_SEPARATOR
file name separator
Definition: JeepToolkit.hh:35
std::string JEEP::getFilename ( const std::string &  file_name)
inline

Get file name part, i.e.

part after last JEEP::PATHNAME_SEPARATOR if any.

Parameters
file_namefile name
Returns
file name part (excluding separator)

Definition at line 85 of file JeepToolkit.hh.

86  {
87  using namespace std;
88 
89  const string buffer = strip(file_name);
90  const size_t pos = buffer.rfind(PATHNAME_SEPARATOR);
91 
92  if (pos != string::npos)
93  return buffer.substr(pos + 1);
94  else
95  return buffer;
96  }
std::string strip(const std::string &file_name)
Strip leading and trailing white spaces from file name.
Definition: JeepToolkit.hh:46
static const char PATHNAME_SEPARATOR
path name separator
Definition: JeepToolkit.hh:33
std::string JEEP::getPath ( const std::string &  file_name)
inline

Get path, i.e.

part before last JEEP::PATHNAME_SEPARATOR if any.

Parameters
file_namefile name
Returns
path (including separator)

Definition at line 105 of file JeepToolkit.hh.

106  {
107  using namespace std;
108 
109  const string buffer = strip(file_name);
110  const size_t pos = buffer.rfind(PATHNAME_SEPARATOR);
111 
112  if (pos != string::npos)
113  return buffer.substr(0, pos + 1);
114  else
115  return "";
116  }
std::string strip(const std::string &file_name)
Strip leading and trailing white spaces from file name.
Definition: JeepToolkit.hh:46
static const char PATHNAME_SEPARATOR
path name separator
Definition: JeepToolkit.hh:33
std::string JEEP::getFilename ( const std::string &  path,
const std::string &  file_name 
)
inline

Compose full file name and introduce JEEP::PATHNAME_SEPARATOR if needed.

Parameters
pathpath
file_namefile name
Returns
file name

Definition at line 126 of file JeepToolkit.hh.

127  {
128  using namespace std;
129 
130  const string buffer = strip(path);
131 
132  if (buffer.empty()) {
133 
134  return strip(file_name);
135 
136  } else if (*buffer.rbegin() == PATHNAME_SEPARATOR) {
137 
138  return buffer + strip(file_name);
139 
140  } else {
141 
142  return buffer + PATHNAME_SEPARATOR + strip(file_name);
143  }
144  }
std::string strip(const std::string &file_name)
Strip leading and trailing white spaces from file name.
Definition: JeepToolkit.hh:46
static const char PATHNAME_SEPARATOR
path name separator
Definition: JeepToolkit.hh:33
std::string JEEP::getPath ( const std::string &  variable,
const std::string &  file_name 
)
inline

Get selected path from environment variable for given file name.

The environment variable is parsed according character JEEP::PATHLIST_SEPARATOR. The first path in which a file exists with the given file name is returned. If no existing file is found, an empty path is returned.

Parameters
variableenvironment variable
file_namefile name
Returns
path

Definition at line 158 of file JeepToolkit.hh.

159  {
160  using namespace std;
161 
162  string path = "";
163 
164  if (!file_name.empty() && file_name[0] != PATHNAME_SEPARATOR) {
165 
166  const string buffer(getenv(variable.c_str()));
167 
168  if (!buffer.empty()) {
169 
170  size_t pos = 0, len;
171 
172  do {
173 
174  len = buffer.substr(pos).find(PATHLIST_SEPARATOR);
175  path = buffer.substr(pos,len);
176 
177  } while (!ifstream(getFilename(path, file_name).c_str()).good() && len != string::npos && (pos += len + 1) != buffer.length());
178  }
179  }
180 
181  if (ifstream(getFilename(path, file_name).c_str()).good())
182  return path;
183  else
184  return "";
185  }
static const char PATHLIST_SEPARATOR
path list separator
Definition: JeepToolkit.hh:34
std::string getFilename(const std::string &file_name)
Get file name part, i.e.
Definition: JeepToolkit.hh:85
static const char PATHNAME_SEPARATOR
path name separator
Definition: JeepToolkit.hh:33
std::string JEEP::getFullFilename ( const std::string &  variable,
const std::string &  file_name 
)
inline

Get full file name (see JEEP::getPath).

Parameters
variableenvironment variable
file_namefile name
Returns
file name

Definition at line 195 of file JeepToolkit.hh.

196  {
197  return getFilename(getPath(variable, file_name), file_name);
198  }
std::string getPath(const std::string &file_name)
Get path, i.e.
Definition: JeepToolkit.hh:105
std::string getFilename(const std::string &file_name)
Get file name part, i.e.
Definition: JeepToolkit.hh:85
std::string JEEP::getNamespace ( const std::string &  type_name)
inline

Get name space, i.e.

part before JEEP::TYPENAME_SEPARATOR.

Parameters
type_nametype name
Returns
name space (possibly empty)

Definition at line 207 of file JeepToolkit.hh.

208  {
209  using namespace std;
210 
211  const size_t pos = type_name.rfind(TYPENAME_SEPARATOR);
212 
213  if (pos != string::npos)
214  return type_name.substr(0, pos);
215  else
216  return "";
217  }
static const char *const TYPENAME_SEPARATOR
type name separator
Definition: JeepToolkit.hh:36
std::string JEEP::getClassname ( const std::string &  type_name)
inline

Get type name, i.e.

part after JEEP::TYPENAME_SEPARATOR.

Parameters
type_nametype name
Returns
class name

Definition at line 226 of file JeepToolkit.hh.

227  {
228  using namespace std;
229 
230  const size_t pos = type_name.rfind(TYPENAME_SEPARATOR);
231 
232  if (pos != string::npos)
233  return type_name.substr(pos + 2);
234  else
235  return type_name;
236  }
static const char *const TYPENAME_SEPARATOR
type name separator
Definition: JeepToolkit.hh:36
std::string JEEP::getProtocol ( const std::string &  file_name)
inline

Get protocol, i.e.

part before first JEEP::PROTOCOL_SEPARATOR if any.

Parameters
file_namefile name
Returns
protocol (excluding separator)

Definition at line 245 of file JeepToolkit.hh.

246  {
247  using namespace std;
248 
249  const size_t pos = file_name.find(PROTOCOL_SEPARATOR);
250 
251  if (pos != string::npos)
252  return file_name.substr(0, pos);
253  else
254  return "";
255  }
static const char PROTOCOL_SEPARATOR
protocol separator
Definition: JeepToolkit.hh:37
template<class T >
T* JEEP::open ( const std::string &  file_name)
inline

Open file.

Parameters
file_namefile name
Returns
pointer to input stream
Parameters
file_namefile name
Returns
pointer to output stream

Definition at line 275 of file JeepToolkit.hh.

276  {
277  using namespace std;
278  using namespace JPP;
279 
280  if (getFilenameExtension(file_name) == "gz")
281  return new igzstream(file_name.c_str());
282  else if (getFilenameExtension(file_name) == "txt")
283  return new ifstream (file_name.c_str());
284  else
285  return NULL;
286  }
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e.
Definition: JeepToolkit.hh:66
template<>
std::istream* JEEP::open ( const std::string &  file_name)
inline

Open file.

Parameters
file_namefile name
Returns
pointer to input stream

Definition at line 275 of file JeepToolkit.hh.

276  {
277  using namespace std;
278  using namespace JPP;
279 
280  if (getFilenameExtension(file_name) == "gz")
281  return new igzstream(file_name.c_str());
282  else if (getFilenameExtension(file_name) == "txt")
283  return new ifstream (file_name.c_str());
284  else
285  return NULL;
286  }
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e.
Definition: JeepToolkit.hh:66
template<>
std::ostream* JEEP::open ( const std::string &  file_name)
inline

Open file.

Parameters
file_namefile name
Returns
pointer to output stream

Definition at line 296 of file JeepToolkit.hh.

297  {
298  using namespace std;
299  using namespace JPP;
300 
301  if (getFilenameExtension(file_name) == "gz")
302  return new ogzstream(file_name.c_str());
303  else if (getFilenameExtension(file_name) == "txt")
304  return new ofstream (file_name.c_str());
305  else
306  return NULL;
307  }
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e.
Definition: JeepToolkit.hh:66
void JEEP::close ( std::istream *  pf)
inline

Close file.

Parameters
pfpointer to file stream

Definition at line 315 of file JeepToolkit.hh.

316  {
317  using namespace std;
318  using namespace JPP;
319 
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; }
322  }
void close(std::istream *pf)
Close file.
Definition: JeepToolkit.hh:315
void JEEP::close ( std::ostream *  pf)
inline

Close file.

Parameters
pfpointer to file stream

Definition at line 330 of file JeepToolkit.hh.

331  {
332  using namespace std;
333  using namespace JPP;
334 
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; }
337  }
void close(std::istream *pf)
Close file.
Definition: JeepToolkit.hh:315
template<class T >
int JEEP::sign ( const T &  value)
inline

Get sign of value.

Parameters
valuevalue
Returns
-1 if value < 0; 0 if value == 0; +1 if value > 0

Definition at line 20 of file JLib.hh.

21  {
22  return (value > T(0)) - (value < T(0));
23  }
int JEEP::getIndex ( )
inline

Get index for user I/O manipulation.

Returns
index

Definition at line 26 of file JPrint.hh.

27  {
28  static const int index = std::ios_base::xalloc();
29 
30  return index;
31  }
std::ostream& JEEP::getOstream ( )
inline

Get output stream for conversion to std::string or C-string.

Note that the ostream is emptied before use.

Returns
ostream

Definition at line 51 of file JPrint.hh.

52  {
53  static std::ostringstream buffer;
54 
55  buffer.str("");
56 
57  return buffer;
58  }
bool JEEP::fail ( std::istream &  in)
inline

Check for stream state.

Note that end-of-file is not defined as an error so to normally process e.g. std::string and std::vector.

Parameters
ininput stream
Returns
true if failure; else false

Definition at line 57 of file JProperties.hh.

58  {
59  return in.bad() || (in.fail() && !in.eof());
60  }
template<class T >
JProperties& JEEP::getProperties ( T &  object,
const JEquationParameters parameters = JEquationParameters(),
const int  debug = 1 
)
inline

Get properties of a given object.

This method transfers the making of the property object to the corresponding class whilst preserving the constness of the argument.
The corresponding class should implement the method:

  template<bool is_const>
  static JProperties getProperties(typename JCategory<T, is_const>::reference_type object,
                                const JEquationParameters& equation,
                                const int debug)
Parameters
objectobject
parametersequation parameters
debugdebug level

Definition at line 1255 of file JProperties.hh.

1258  {
1259  static JProperties properties;
1260 
1261  properties = T::template getProperties<true>(object, parameters, debug);
1262 
1263  return properties;
1264  }
Utility class to parse parameter values.
Definition: JProperties.hh:484
int debug
debug level
Definition: JSirene.cc:59
template<class T >
JProperties& JEEP::getProperties ( const T &  object,
const JEquationParameters parameters = JEquationParameters(),
const int  debug = 1 
)
inline

Get properties of a given object.

This method transfers the making of the property object to the corresponding class whilst preserving the constness of the argument.
The corresponding class should implement the method:

  template<bool is_const>
  static JProperties getProperties(typename JCategory<T, is_const>::reference_type object,
                                const JEquationParameters& equation,
                                const int debug)
Parameters
objectobject
parametersequation parameters
debugdebug level

Definition at line 1285 of file JProperties.hh.

1288  {
1289  static JProperties properties;
1290 
1291  properties = T::template getProperties<false>(object, parameters, debug);
1292 
1293  return properties;
1294  }
Utility class to parse parameter values.
Definition: JProperties.hh:484
int debug
debug level
Definition: JSirene.cc:59
double JEEP::getValue ( const JScale_t  scale)
inline

Get numerical value corresponding to scale.

Parameters
scalescale
Returns
value

Definition at line 47 of file JScale.hh.

48  {
49  return pow(10.0, scale);
50  }
void scale(vector< double > &v, double c)
scale vector content
const char* JEEP::getUnit ( const int  scale)
inline

Get textual unit corresponding to scale.

Parameters
scalescale
Returns
textual unit

Definition at line 59 of file JScale.hh.

60  {
61  switch (scale) {
62 
63  case femto_t:
64  return "f";
65 
66  case pico_t:
67  return "p";
68 
69  case nano_t:
70  return "n";
71 
72  case micro_t:
73  return "u";
74 
75  case milli_t:
76  return "m";
77 
78  case unit_t:
79  return "";
80 
81  case kilo_t:
82  return "k";
83 
84  case mega_t:
85  return "M";
86 
87  case giga_t:
88  return "G";
89 
90  case tera_t:
91  return "T";
92 
93  case peta_t:
94  return "P";
95 
96  case exa_t:
97  return "E";
98 
99  default:
100  THROW(JValueOutOfRange, "getUnit(): invalid scale " << scale);
101  };
102  }
exa
Definition: JScale.hh:37
micro
Definition: JScale.hh:29
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:633
giga
Definition: JScale.hh:34
kilo
Definition: JScale.hh:32
milli
Definition: JScale.hh:30
peta
Definition: JScale.hh:36
femto
Definition: JScale.hh:26
mega
Definition: JScale.hh:33
nano
Definition: JScale.hh:28
pico
Definition: JScale.hh:27
unit
Definition: JScale.hh:31
tera
Definition: JScale.hh:35
void scale(vector< double > &v, double c)
scale vector content
JScale_t JEEP::getScale ( const char  unit)
inline

Get scale corresponding to textual unit.

Parameters
unittextual unit
Returns
scale

Definition at line 111 of file JScale.hh.

112  {
113  switch (unit) {
114 
115  case 'f':
116  return femto_t;
117 
118  case 'p':
119  return pico_t;
120 
121  case 'n':
122  return nano_t;
123 
124  case 'u':
125  return micro_t;
126 
127  case 'm':
128  return milli_t;
129 
130  case ' ':
131  return unit_t;
132 
133  case 'k':
134  return kilo_t;
135 
136  case 'M':
137  return mega_t;
138 
139  case 'G':
140  return giga_t;
141 
142  case 'T':
143  return tera_t;
144 
145  case 'P':
146  return peta_t;
147 
148  case 'E':
149  return exa_t;
150 
151  default:
152  THROW(JValueOutOfRange, "getScale(): invalid unit " << unit);
153  };
154  }
exa
Definition: JScale.hh:37
micro
Definition: JScale.hh:29
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:633
giga
Definition: JScale.hh:34
kilo
Definition: JScale.hh:32
milli
Definition: JScale.hh:30
peta
Definition: JScale.hh:36
femto
Definition: JScale.hh:26
mega
Definition: JScale.hh:33
nano
Definition: JScale.hh:28
pico
Definition: JScale.hh:27
unit
Definition: JScale.hh:31
tera
Definition: JScale.hh:35
template<class T >
std::istream& JEEP::readObject ( std::istream &  in,
T &  object 
)
inline

Stream input of object.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 28 of file JStreamToolkit.hh.

29  {
30  return in >> object;
31  }
template<class T >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const T &  object 
)
inline

Stream output of object.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 42 of file JStreamToolkit.hh.

43  {
44  return out << object;
45  }
template<class T >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const char *  prefix,
const T &  object,
const char  postfix 
)
inline

Stream output of object.

Parameters
outoutput stream
prefixprefix
objectobject
postfixpostfix
Returns
output stream

Definition at line 58 of file JStreamToolkit.hh.

62  {
63  return out << prefix << object << postfix;
64  }
template<class JElement_t , class JAllocator_t >
std::istream& JEEP::readObject ( std::istream &  in,
std::vector< JElement_t, JAllocator_t > &  object 
)
inline

Template specialisation of method readObject() for std::vector.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 75 of file JStreamToolkit.hh.

76  {
77  for (JElement_t element; readObject(in, element); ) {
78  object.push_back(element);
79  }
80 
81  return in;
82  }
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
template<class JElement_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const std::vector< JElement_t, JAllocator_t > &  object 
)
inline

Template specialisation of method writeObject() for std::vector.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 93 of file JStreamToolkit.hh.

94  {
95  for (typename std::vector<JElement_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
96  writeObject(out, ' ');
97  writeObject(out, *i);
98  }
99 
100  return out;
101  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JElement_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const char *  prefix,
const std::vector< JElement_t, JAllocator_t > &  object,
const char  postfix 
)
inline

Template specialisation of method writeObject() for std::vector.

Parameters
outoutput stream
prefixprefix
objectobject
postfixpostfix
Returns
output stream

Definition at line 114 of file JStreamToolkit.hh.

118  {
119  for (typename std::vector<JElement_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
120  writeObject(out, prefix, *i, postfix);
121  }
122 
123  return out;
124  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JElement_t , class JAllocator_t >
std::istream& JEEP::readObject ( std::istream &  in,
std::list< JElement_t, JAllocator_t > &  object 
)
inline

Template specialisation of method readObject() for std::list.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 135 of file JStreamToolkit.hh.

136  {
137  for (JElement_t element; readObject(in, element); ) {
138  object.push_back(element);
139  }
140 
141  return in;
142  }
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
template<class JElement_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const std::list< JElement_t, JAllocator_t > &  object 
)
inline

Template specialisation of method writeObject() for std::list.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 153 of file JStreamToolkit.hh.

154  {
155  for (typename std::list<JElement_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
156  writeObject(out, ' ');
157  writeObject(out, *i);
158  }
159 
160  return out;
161  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JElement_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const char *  prefix,
const std::list< JElement_t, JAllocator_t > &  object,
const char  postfix 
)
inline

Template specialisation of method writeObject() for std::list.

Parameters
outoutput stream
prefixprefix
objectobject
postfixpostfix
Returns
output stream

Definition at line 174 of file JStreamToolkit.hh.

178  {
179  for (typename std::list<JElement_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
180  writeObject(out, prefix, *i, postfix);
181  }
182 
183  return out;
184  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::istream& JEEP::readObject ( std::istream &  in,
std::set< JElement_t, JComparator_t, JAllocator_t > &  object 
)
inline

Template specialisation of method readObject() for std::set.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 195 of file JStreamToolkit.hh.

196  {
197  for (JElement_t element; readObject(in, element); ) {
198 
199  const std::pair<typename std::set<JElement_t, JComparator_t, JAllocator_t>::iterator, bool> result = object.insert(element);
200 
201  if (!result.second) {
202  object.erase (result.first);
203  object.insert(element);
204  }
205  }
206 
207  return in;
208  }
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const std::set< JElement_t, JComparator_t, JAllocator_t > &  object 
)
inline

Template specialisation of method writeObject() for std::set.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 219 of file JStreamToolkit.hh.

220  {
221  for (typename std::set<JElement_t, JComparator_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
222  writeObject(out, ' ');
223  writeObject(out, *i);
224  }
225 
226  return out;
227  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const char *  prefix,
const std::set< JElement_t, JComparator_t, JAllocator_t > &  object,
const char  postfix 
)
inline

Template specialisation of method writeObject() for std::set.

Parameters
outoutput stream
prefixprefix
objectobject
postfixpostfix
Returns
output stream

Definition at line 240 of file JStreamToolkit.hh.

244  {
245  for (typename std::set<JElement_t, JComparator_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
246  writeObject(out, prefix, *i, postfix);
247  }
248 
249  return out;
250  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::istream& JEEP::readObject ( std::istream &  in,
std::multiset< JElement_t, JComparator_t, JAllocator_t > &  object 
)
inline

Template specialisation of method readObject() for std::multiset.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 261 of file JStreamToolkit.hh.

262  {
263  for (JElement_t element; readObject(in, element); ) {
264  object.insert(element);
265  }
266 
267  return in;
268  }
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const std::multiset< JElement_t, JComparator_t, JAllocator_t > &  object 
)
inline

Template specialisation of method writeObject() for std::multiset.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 279 of file JStreamToolkit.hh.

280  {
281  for (typename std::multiset<JElement_t, JComparator_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
282  writeObject(out, ' ');
283  writeObject(out, *i);
284  }
285 
286  return out;
287  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JElement_t , class JComparator_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const char *  prefix,
const std::multiset< JElement_t, JComparator_t, JAllocator_t > &  object,
const char  postfix 
)
inline

Template specialisation of method writeObject() for std::multiset.

Parameters
outoutput stream
prefixprefix
objectobject
postfixpostfix
Returns
output stream

Definition at line 300 of file JStreamToolkit.hh.

304  {
305  for (typename std::multiset<JElement_t, JComparator_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
306  writeObject(out, prefix, *i, postfix);
307  }
308 
309  return out;
310  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JFirst_t , class JSecond_t >
std::istream& JEEP::readObject ( std::istream &  in,
std::pair< JFirst_t, JSecond_t > &  object 
)
inline

Template specialisation of method readObject() for std::pair.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 321 of file JStreamToolkit.hh.

322  {
323  readObject(in, object.first);
324  readObject(in, object.second);
325 
326  return in;
327  }
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
template<class JFirst_t , class JSecond_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const std::pair< JFirst_t, JSecond_t > &  object 
)
inline

Template specialisation of method writeObject() for std::pair.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 338 of file JStreamToolkit.hh.

339  {
340  writeObject(out, object.first);
341  writeObject(out, ' ');
342  writeObject(out, object.second);
343 
344  return out;
345  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JFirst_t , class JSecond_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const char *  prefix,
const std::pair< JFirst_t, JSecond_t > &  object,
const char  postfix 
)
inline

Template specialisation of method writeObject() for std::pair.

Parameters
outoutput stream
prefixprefix
objectobject
postfixpostfix
Returns
output stream

Definition at line 358 of file JStreamToolkit.hh.

362  {
363  writeObject(out, prefix);
364  writeObject(out, object.first);
365  writeObject(out, ' ');
366  writeObject(out, object.second);
367  writeObject(out, postfix);
368 
369  return out;
370  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::istream& JEEP::readObject ( std::istream &  in,
std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &  object 
)
inline

Template specialisation of method readObject() for std::map.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 381 of file JStreamToolkit.hh.

382  {
383  for (std::pair<JKey_t, JValue_t> element; readObject(in, element); ) {
384 
386 
387  if (!result.second) {
388  result.first->second = element.second;
389  }
390  }
391 
392  return in;
393  }
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &  object 
)
inline

Template specialisation of method writeObject() for std::map.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 404 of file JStreamToolkit.hh.

405  {
406  for (typename std::map<JKey_t, JValue_t, JComparator_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
407  writeObject(out, ' ');
408  writeObject(out, *i);
409  }
410 
411  return out;
412  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const char *  prefix,
const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &  object,
const char  postfix 
)
inline

Template specialisation of method writeObject() for std::map.

Parameters
outoutput stream
prefixprefix
objectobject
postfixpostfix
Returns
output stream

Definition at line 425 of file JStreamToolkit.hh.

429  {
430  for (typename std::map<JKey_t, JValue_t, JComparator_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
431  writeObject(out, prefix, *i, postfix);
432  }
433 
434  return out;
435  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::istream& JEEP::readObject ( std::istream &  in,
std::multimap< JKey_t, JValue_t, JComparator_t, JAllocator_t > &  object 
)
inline

Template specialisation of method readObject() for std::multimap.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 446 of file JStreamToolkit.hh.

447  {
448  for (std::pair<JKey_t, JValue_t> element; readObject(in, element); ) {
449  object.insert(element);
450  }
451 
452  return in;
453  }
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const std::multimap< JKey_t, JValue_t, JComparator_t, JAllocator_t > &  object 
)
inline

Template specialisation of method writeObject() for std::multimap.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 464 of file JStreamToolkit.hh.

465  {
466  for (typename std::multimap<JKey_t, JValue_t, JComparator_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
467  writeObject(out, ' ');
468  writeObject(out, *i);
469  }
470 
471  return out;
472  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class JKey_t , class JValue_t , class JComparator_t , class JAllocator_t >
std::ostream& JEEP::writeObject ( std::ostream &  out,
const char *  prefix,
const std::multimap< JKey_t, JValue_t, JComparator_t, JAllocator_t > &  object,
const char  postfix 
)
inline

Template specialisation of method writeObject() for std::multimap.

Parameters
outoutput stream
prefixprefix
objectobject
postfixpostfix
Returns
output stream

Definition at line 485 of file JStreamToolkit.hh.

489  {
490  for (typename std::multimap<JKey_t, JValue_t, JComparator_t, JAllocator_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
491  writeObject(out, prefix, *i, postfix);
492  }
493 
494  return out;
495  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
template<class T >
std::ostream& JEEP::writeArray ( std::ostream &  out,
const char *  left,
const char *  right,
const char *  sep,
__begin,
__end 
)
inline

Write array of objects.

Parameters
outoutput stream
leftleft bracket
rightright bracket
sepseparator
__beginbegin of data
__endend of data
Returns
output stream

Definition at line 510 of file JStreamToolkit.hh.

516  {
517  if (std::distance(__begin, __end) != 0) {
518 
519  out << left;
520 
521  T i = __begin;
522 
523  writeObject(out, *i);
524 
525  while (++i != __end) {
526 
527  out << sep;
528 
529  JEEP::writeObject(out, *i);
530  }
531 
532  out << right;
533  }
534 
535  return out;
536  }
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
bool JEEP::operator< ( const JVersion first,
const JVersion second 
)
inline

Less-than operator for versions.

Parameters
firstfirst version
secondsecond version
Returns
true if first version before second; else false

Definition at line 182 of file JVersion.hh.

183  {
184  return first.getVariant() < second.getVariant();
185  }
const std::string & getVariant() const
Get variant.
Definition: JVersion.hh:90

Variable Documentation

const char* const JEEP::LD_LIBRARY_PATH = "LD_LIBRARY_PATH"
static

Nick names of environment variables.

library file paths

Definition at line 29 of file JeepToolkit.hh.

const char* const JEEP::PATH = "PATH"
static

binary file paths

Definition at line 30 of file JeepToolkit.hh.

const char* const JEEP::SHELL = "SHELL"
static

SHELL.

Definition at line 31 of file JeepToolkit.hh.

const char JEEP::PATHNAME_SEPARATOR = '/'
static

path name separator

Definition at line 33 of file JeepToolkit.hh.

const char JEEP::PATHLIST_SEPARATOR = ':'
static

path list separator

Definition at line 34 of file JeepToolkit.hh.

const char JEEP::FILENAME_SEPARATOR = '.'
static

file name separator

Definition at line 35 of file JeepToolkit.hh.

const char* const JEEP::TYPENAME_SEPARATOR = "::"
static

type name separator

Definition at line 36 of file JeepToolkit.hh.

const char JEEP::PROTOCOL_SEPARATOR = ':'
static

protocol separator

Definition at line 37 of file JeepToolkit.hh.