Jpp  18.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Functions | Variables
JParser.hh File Reference

Utility class to parse command line options. More...

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <map>
#include <ctype.h>
#include "JLang/Jpp.hh"
#include "JLang/JAbstractIO.hh"
#include "JLang/JException.hh"
#include "JLang/JSharedPointer.hh"
#include "JLang/JAbstractObjectStatus.hh"
#include "JLang/JComparable.hh"
#include "JLang/JComparisonAvailable.hh"
#include "JLang/JBool.hh"
#include "JLang/JResolve.hh"
#include "JLang/JLangToolkit.hh"
#include "JLang/JManip.hh"
#include "Jeep/JStreamToolkit.hh"
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JArgs.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Classes

struct  JPARSER::initialised
 Empty structure for specification of parser element that is initialised (i.e. does not require input). More...
 
struct  JPARSER::not_initialised
 Empty structure for specification of parser element that is not initialised (i.e. does require input). More...
 
class  JPARSER::JOption< T >
 Auxiliary class to handle optional I/O. More...
 
class  JPARSER::JCounter
 Auxiliary class to handle multiple boolean-like I/O. More...
 
class  JPARSER::JParserElementInterface
 Interface for I/O of parser element. More...
 
class  JPARSER::JParserTemplateElement< JType_t, has_eq >
 Template class holder for I/O of parser element. More...
 
class  JPARSER::JCSV< JType_t >
 Auxiliary class to assign the remainder of a sequence of Comma Separated Values. More...
 
class  JPARSER::JParserTemplateElement< JType_t, false >
 Template specialisation of JPARSER::JParserTemplateElement for data type without equal operator ==. More...
 
struct  JPARSER::TStringHelper< option >
 Auxiliary class for handling I/O of TString depending on its existence. More...
 
struct  JPARSER::TStringHelper< false >
 Specialisation of TStringHelper if TString does not exist. More...
 
struct  JPARSER::TStringHelper< true >
 Specialisation of TStringHelper if TString exists. More...
 
class  JPARSER::JParserTemplateElement< JType_t, true >
 Template specialisation of JPARSER::JParserTemplateElement for data type with equal operator ==. More...
 
class  JPARSER::JParserTemplateElement< bool >
 Template specialisation of JPARSER::JParserTemplateElement for type bool. More...
 
class  JPARSER::JParserTemplateElement< JCounter >
 Template specialisation of JPARSER::JParserTemplateElement for type JCounter. More...
 
class  JPARSER::JParserElement
 Auxiliary class to handle pointer to JPARSER::JParserElementInterface. More...
 
class  JPARSER::JParser< JKey_t >
 Utility class to parse command line options. More...
 

Namespaces

 JPARSER
 Local namespace for command line parser.
 

Macros

#define VARGS_STRING(A, B,...)   (static_cast<std::ostringstream&>(JPARSER::getOstream() << B << std::flush)).str()
 Make string for variadic macro. More...
 
#define make_field(A,...)   JPARSER::getOption(A, #A, VARGS_STRING("", ##__VA_ARGS__, ""))
 macro to convert parameter to JParserTemplateElement object More...
 
#define make_option(A,...)   JPARSER::getOption(A, #A, VARGS_STRING("", ##__VA_ARGS__, ""))
 macro to convert parameter to JParserTemplateElement object More...
 

Functions

std::ostream & JPARSER::getOstream ()
 Get output stream for conversion to std::string. More...
 
bool JPARSER::fail (std::istream &in)
 Check for stream state. More...
 
JParserTemplateElement< bool > JPARSER::getOption (bool &object, const std::string &name, const std::string &help="")
 Auxiliary method for creation of template parser element object. More...
 
JParserTemplateElement< JCounterJPARSER::getOption (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 > JPARSER::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 > JPARSER::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 > JPARSER::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 JPARSER::START_OF_OPTION = '-'
 Parser options. More...
 
static char JPARSER::END_OF_OPTIONS = '-'
 end of all options More...
 
static char JPARSER::HELP_OPTION = 'h'
 help option More...
 
static char JPARSER::REVISION_OPTION = 'v'
 revision option More...
 
static char JPARSER::PRINT_OPTION = '!'
 print option More...
 
static char JPARSER::PID_OPTION = 'P'
 print PID to file More...
 
static int JPARSER::NORMAL_EXIT_CODE = 0
 exit code of normal end More...
 
static int JPARSER::WIDTH = 12
 format specifier More...
 

Detailed Description

Utility class to parse command line options.

Author
mdejong

Definition in file JParser.hh.

Macro Definition Documentation

#define VARGS_STRING (   A,
  B,
  ... 
)    (static_cast<std::ostringstream&>(JPARSER::getOstream() << B << std::flush)).str()

Make string for variadic macro.

When called,

  • first argument should correspond to a dummy value;
  • second to the ##__VA_ARGS__ macro; and
  • third to the fall back value (e.g. "");
Parameters
Adummy value
B##__VA_ARGS__ macro
Returns
std::string

Definition at line 1983 of file JParser.hh.

#define make_field (   A,
  ... 
)    JPARSER::getOption(A, #A, VARGS_STRING("", ##__VA_ARGS__, ""))

macro to convert parameter to JParserTemplateElement object

Definition at line 1989 of file JParser.hh.

#define make_option (   A,
  ... 
)    JPARSER::getOption(A, #A, VARGS_STRING("", ##__VA_ARGS__, ""))

macro to convert parameter to JParserTemplateElement object

Definition at line 1995 of file JParser.hh.