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

Classes

struct  initialised
 Empty structure for specification of parser element that is initialised (i.e. More...
 
struct  not_initialised
 Empty structure for specification of parser element that is not initialised (i.e. More...
 
class  JOption
 Auxiliary class to handle optional I/O. More...
 
class  JCounter
 Auxiliary class to handle multiple boolean-like I/O. More...
 
class  JParserElementInterface
 Interface for I/O of parser element. More...
 
class  JParserTemplateElement
 Template class holder for I/O of parser element. More...
 
class  JCSV
 Auxiliary class to assign the remainder of a sequence of Comma Separated Values. More...
 
class  JParserTemplateElement< JType_t, false >
 Template specialisation of JPARSER::JParserTemplateElement for data type without equal operator ==. More...
 
class  JParserTemplateElement< JType_t, true >
 Template specialisation of JPARSER::JParserTemplateElement for data type with equal operator ==. More...
 
class  JParserTemplateElement< bool >
 Template specialisation of JPARSER::JParserTemplateElement for type bool. More...
 
class  JParserTemplateElement< JCounter >
 Template specialisation of JPARSER::JParserTemplateElement for type JCounter. More...
 
class  JParserElement
 Auxiliary class to handle pointer to JPARSER::JParserElementInterface. More...
 
class  JParser
 Utility class to parse command line options. More...
 

Functions

bool fail (std::istream &in)
 Check for stream state. More...
 
template<template< class, class > class JContainer_t, class JAllocator_t >
std::istream & read (std::istream &in, JContainer_t< TString, JAllocator_t > &object, const JBool< false > &option)
 Auxiliary method for reading if TString does not exist. More...
 
template<template< class, class > class JContainer_t, class JAllocator_t >
std::istream & read (std::istream &in, JContainer_t< TString, JAllocator_t > &object, const JBool< true > &option)
 Auxiliary method for reading if TString exists. More...
 
JParserTemplateElement< bool > getOption (bool &object, const std::string &name, const std::string &help="")
 Auxiliary method for creation of template parser element object. More...
 
JParserTemplateElement< JCountergetOption (JCounter &object, const std::string &name, const std::string &help="")
 Auxiliary method for creation of template parser element object. More...
 
template<class JType_t >
JParserTemplateElement< JType_t > getOption (JType_t &object, const std::string &name, const std::string &help="")
 Auxiliary method for creation of template parser element object. More...
 
template<class JType_t , class T >
JParserTemplateElement< JType_t > getOption (JType_t &object, const std::string &name, const std::string &help, T __begin, T __end)
 Auxiliary method for creation of template parser element object. More...
 
template<class JType_t , class T >
JParserTemplateElement< JType_t > getOption (JType_t &object, const std::string &name, T __begin, T __end)
 Auxiliary method for creation of template parser element object. More...
 

Variables

static char START_OF_OPTION = '-'
 Parser options. More...
 
static char END_OF_OPTIONS = '-'
 end of all options More...
 
static char HELP_OPTION = 'h'
 help option More...
 
static char REVISION_OPTION = 'v'
 revision option More...
 
static char PRINT_OPTION = '!'
 print option More...
 
static char PID_OPTION = 'P'
 print PID to file More...
 
static int NORMAL_EXIT_CODE = 0
 exit code of normal end More...
 

Function Documentation

bool JPARSER::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 93 of file JParser.hh.

94  {
95  return in.bad() || (in.fail() && !in.eof());
96  }
template<template< class, class > class JContainer_t, class JAllocator_t >
std::istream& JPARSER::read ( std::istream &  in,
JContainer_t< TString, JAllocator_t > &  object,
const JBool< false > &  option 
)
inline

Auxiliary method for reading if TString does not exist.

Parameters
ininput stream
objectobject
option
Returns
input stream

Definition at line 720 of file JParser.hh.

721  {
722  THROW(JParserException, "JParser: invalid data type TString (include TString.h before JParser.hh)");
723  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:633
Exception when parsing a value.
Definition: JException.hh:504
template<template< class, class > class JContainer_t, class JAllocator_t >
std::istream& JPARSER::read ( std::istream &  in,
JContainer_t< TString, JAllocator_t > &  object,
const JBool< true > &  option 
)
inline

Auxiliary method for reading if TString exists.

Parameters
ininput stream
objectobject
option
Returns
input stream

Definition at line 735 of file JParser.hh.

736  {
737  for (std::string buffer; in >> buffer; ) {
738  object.push_back(TString(buffer.c_str()));
739  }
740 
741  return in;
742  }
JParserTemplateElement<bool> JPARSER::getOption ( bool &  object,
const std::string &  name,
const std::string &  help = "" 
)
inline

Auxiliary method for creation of template parser element object.

Parameters
objectobject
namename of object
helphelp of object
Returns
parser element

Definition at line 1757 of file JParser.hh.

1758  {
1759  return JParserTemplateElement<bool>(object, name, help);
1760  }
Template specialisation of JPARSER::JParserTemplateElement for type bool.
Definition: JParser.hh:981
JParserTemplateElement<JCounter> JPARSER::getOption ( JCounter object,
const std::string &  name,
const std::string &  help = "" 
)
inline

Auxiliary method for creation of template parser element object.

Parameters
objectobject
namename of object
helphelp of object
Returns
parser element

Definition at line 1771 of file JParser.hh.

1772  {
1773  return JParserTemplateElement<JCounter>(object, name, help);
1774  }
Template specialisation of JPARSER::JParserTemplateElement for type JCounter.
Definition: JParser.hh:1084
template<class JType_t >
JParserTemplateElement<JType_t> JPARSER::getOption ( JType_t &  object,
const std::string &  name,
const std::string &  help = "" 
)
inline

Auxiliary method for creation of template parser element object.

Parameters
objectobject
namename of object
helphelp of object
Returns
parser element

Definition at line 1786 of file JParser.hh.

1787  {
1788  return JParserTemplateElement<JType_t>(object, name, help);
1789  }
template<class JType_t , class T >
JParserTemplateElement<JType_t> JPARSER::getOption ( JType_t &  object,
const std::string &  name,
const std::string &  help,
__begin,
__end 
)
inline

Auxiliary method for creation of template parser element object.

Parameters
objectobject
namename of object
helphelp of object
__beginbegin of possible values
__endend of possible values
Returns
parser element

Definition at line 1803 of file JParser.hh.

1808  {
1809  return JParserTemplateElement<JType_t>(object, name, help, __begin, __end);
1810  }
template<class JType_t , class T >
JParserTemplateElement<JType_t> JPARSER::getOption ( JType_t &  object,
const std::string &  name,
__begin,
__end 
)
inline

Auxiliary method for creation of template parser element object.

Parameters
objectobject
namename of object
__beginbegin of possible values
__endend of possible values
Returns
parser element

Definition at line 1823 of file JParser.hh.

1827  {
1828  return getOption(object, name, "", __begin, __end);
1829  }
JParserTemplateElement< bool > getOption(bool &object, const std::string &name, const std::string &help="")
Auxiliary method for creation of template parser element object.
Definition: JParser.hh:1757

Variable Documentation

char JPARSER::START_OF_OPTION = '-'
static

Parser options.

start of an option

Definition at line 76 of file JParser.hh.

char JPARSER::END_OF_OPTIONS = '-'
static

end of all options

Definition at line 77 of file JParser.hh.

char JPARSER::HELP_OPTION = 'h'
static

help option

Definition at line 78 of file JParser.hh.

char JPARSER::REVISION_OPTION = 'v'
static

revision option

Definition at line 79 of file JParser.hh.

char JPARSER::PRINT_OPTION = '!'
static

print option

Definition at line 80 of file JParser.hh.

char JPARSER::PID_OPTION = 'P'
static

print PID to file

Definition at line 81 of file JParser.hh.

int JPARSER::NORMAL_EXIT_CODE = 0
static

exit code of normal end

Definition at line 82 of file JParser.hh.