Jpp 20.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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 <type_traits>
#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"
#include "Jeep/JPrint.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::JProxy< T, true >
 Template specialisation of JProxy for fundamental data type. More...
 
class  JPARSER::JProxy< T, false >
 Template specialisation of JProxy for non-fundamental data type. 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::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< 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

namespace  JPARSER
 Local namespace for command line parser.
 

Macros

#define VARGS_STRING(A, B, ...)
 Make string for variadic macro.
 
#define make_field(A, ...)
 macro to convert parameter to JParserTemplateElement object
 
#define make_option(A, ...)
 macro to convert parameter to JParserTemplateElement object
 

Functions

bool JPARSER::fail (std::istream &in)
 Check for stream state.
 
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.
 
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.
 
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.
 

Variables

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

Detailed Description

Utility class to parse command line options.

Author
mdejong

Definition in file JParser.hh.

Macro Definition Documentation

◆ VARGS_STRING

#define VARGS_STRING ( A,
B,
... )
Value:
(static_cast<std::ostringstream&>(JEEP::getOstream() << B << std::flush)).str()
std::ostream & getOstream()
Get output stream for conversion to std::string.
Definition JPrint.hh:28

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 2136 of file JParser.hh.

◆ make_field

#define make_field ( A,
... )
Value:
JPARSER::getOption(A, #A, VARGS_STRING("", ##__VA_ARGS__, ""))
#define VARGS_STRING(A, B,...)
Make string for variadic macro.
Definition JParser.hh:2136
JParserTemplateElement< JType_t > getOption(JType_t &object, const std::string &name, const std::string &help="")
Auxiliary method for creation of template parser element object.
Definition JParser.hh:2077

macro to convert parameter to JParserTemplateElement object

Definition at line 2142 of file JParser.hh.

◆ make_option

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

macro to convert parameter to JParserTemplateElement object

Definition at line 2148 of file JParser.hh.