EpcTools
An event based multi-threaded C++ development framework.
Classes | Public Types | Public Member Functions | List of all members
EGetOpt Class Reference

#include <egetopt.h>

Classes

struct  Option
 Describes the defined command line arguments. More...
 

Public Types

enum  ArgType { no_argument, required_argument, optional_argument }
 Indicates if an argument associated with a command line argument is required. More...
 
enum  DataType {
  dtNone, dtString, dtInt32, dtInt64,
  dtUInt32, dtUInt64, dtDouble, dtBool
}
 The data type of the command line argument. More...
 

Public Member Functions

 EGetOpt ()
 Class constructor. More...
 
 ~EGetOpt ()
 Class destructor. More...
 
Void setPrefix (const EString &path)
 Sets the search prefix. More...
 
Void setPrefix (cpStr path)
 Sets the search prefix. More...
 
Void loadCmdLine (Int argc, pStr *argv, const EGetOpt::Option *options)
 Parses and loads the command line arguments. More...
 
Void loadFile (cpStr filename)
 Parses and loads configuration values from the specified JSON file. More...
 
Long getCmdLine (cpStr path, Long def) const
 Returns the value of the specified command line argument as a 32-bit integer. More...
 
LongLong getCmdLine (cpStr path, LongLong def) const
 Returns the value of the specified command line argument as a 64-bit integer. More...
 
ULong getCmdLine (cpStr path, ULong def) const
 Returns the value of the specified command line argument as an unsigned 32-bit integer. More...
 
ULongLong getCmdLine (cpStr path, ULongLong def) const
 Returns the value of the specified command line argument as an unsigned 64-bit integer. More...
 
Double getCmdLine (cpStr path, Double def) const
 Returns the value of the specified command line argument as a double (8-byte floating point). More...
 
cpStr getCmdLine (cpStr path, cpStr def) const
 Returns the value of the specified command line argument as a string. More...
 
Bool getCmdLine (cpStr path, Bool def) const
 Returns the value of the specified command line argument as a boolean. More...
 
std::vector< EStringgetCmdLineArgs () const
 Returns a std::vector containing positional command line arguments. More...
 
std::vector< EStringgetCmdLineRaw () const
 Returns a std::vector containing the "raw" string command line arguments. More...
 
Long get (cpStr path, Long def) const
 Returns the value of the specified configuration value as a 32-bit integer. More...
 
LongLong get (cpStr path, LongLong def) const
 Returns the value of the specified configuration value as a 64-bit integer. More...
 
ULong get (cpStr path, ULong def) const
 Returns the value of the specified configuration value as an unsigned 32-bit integer. More...
 
ULongLong get (cpStr path, ULongLong def) const
 Returns the value of the specified configuration value as a unsigned 64-bit integer. More...
 
Double get (cpStr path, Double def) const
 Returns the value of the specified configuration value as a double (8-byte floating point). More...
 
cpStr get (cpStr path, cpStr def) const
 Returns the value of the specified configuration value as a string. More...
 
Bool get (cpStr path, Bool def) const
 Returns the value of the specified configuration value as a boolean. More...
 
UInt getCount (cpStr path) const
 returns the number of configuration entries specified in a JSON array. More...
 
template<typename T >
get (UInt idx, cpStr path, cpStr member, T def) const
 Returns the value associated with an array. More...
 
Void print () const
 Prints the current loaded values (command line and file). More...
 

Member Enumeration Documentation

◆ ArgType

Indicates if an argument associated with a command line argument is required.

Enumerator
no_argument 

no argument required

required_argument 

an argument is required

optional_argument 

the argument is optional *** NOT IMPLEMENTED ***

◆ DataType

The data type of the command line argument.

Enumerator
dtNone 

no argument

dtString 

string

dtInt32 

32-bit integer

dtInt64 

64-bit integer

dtUInt32 

32-bit unsigned integer

dtUInt64 

64-bit unsigned integer

dtDouble 

8-byte floating point number

dtBool 

boolean

Constructor & Destructor Documentation

◆ EGetOpt()

EGetOpt::EGetOpt ( )

Class constructor.

◆ ~EGetOpt()

EGetOpt::~EGetOpt ( )

Class destructor.

Member Function Documentation

◆ get() [1/8]

Bool EGetOpt::get ( cpStr  path,
Bool  def 
) const

Returns the value of the specified configuration value as a boolean.

Parameters
pathThe path of the requested configuration parameter.
defThe value to return if the requested path is not found.

◆ get() [2/8]

cpStr EGetOpt::get ( cpStr  path,
cpStr  def 
) const

Returns the value of the specified configuration value as a string.

Parameters
pathThe path of the requested configuration parameter.
defThe value to return if the requested path is not found.

◆ get() [3/8]

Double EGetOpt::get ( cpStr  path,
Double  def 
) const

Returns the value of the specified configuration value as a double (8-byte floating point).

Parameters
pathThe path of the requested configuration parameter.
defThe value to return if the requested path is not found.

◆ get() [4/8]

Long EGetOpt::get ( cpStr  path,
Long  def 
) const

Returns the value of the specified configuration value as a 32-bit integer.

Parameters
pathThe path of the requested configuration parameter.
defThe value to return if the requested path is not found.

◆ get() [5/8]

LongLong EGetOpt::get ( cpStr  path,
LongLong  def 
) const

Returns the value of the specified configuration value as a 64-bit integer.

Parameters
pathThe path of the requested configuration parameter.
defThe value to return if the requested path is not found.

◆ get() [6/8]

ULong EGetOpt::get ( cpStr  path,
ULong  def 
) const

Returns the value of the specified configuration value as an unsigned 32-bit integer.

Parameters
pathThe path of the requested configuration parameter.
defThe value to return if the requested path is not found.

◆ get() [7/8]

ULongLong EGetOpt::get ( cpStr  path,
ULongLong  def 
) const

Returns the value of the specified configuration value as a unsigned 64-bit integer.

Parameters
pathThe path of the requested configuration parameter.
defThe value to return if the requested path is not found.

◆ get() [8/8]

template<typename T >
T EGetOpt::get ( UInt  idx,
cpStr  path,
cpStr  member,
def 
) const
inline

Returns the value associated with an array.

Parameters
idxThe index associated with the parent JSON object.
pathThe path of the parent object of the requested configuration value.
memberThe member name of the requested configurtion value.
defThe value to return if the requested path/member is not found.

◆ getCmdLine() [1/7]

Bool EGetOpt::getCmdLine ( cpStr  path,
Bool  def 
) const

Returns the value of the specified command line argument as a boolean.

Parameters
pathThe path of the command line argument.
defThe value to return if the requested path is not found.

◆ getCmdLine() [2/7]

cpStr EGetOpt::getCmdLine ( cpStr  path,
cpStr  def 
) const

Returns the value of the specified command line argument as a string.

Parameters
pathThe path of the command line argument.
defThe value to return if the requested path is not found.

◆ getCmdLine() [3/7]

Double EGetOpt::getCmdLine ( cpStr  path,
Double  def 
) const

Returns the value of the specified command line argument as a double (8-byte floating point).

Parameters
pathThe path of the command line argument.
defThe value to return if the requested path is not found.

◆ getCmdLine() [4/7]

Long EGetOpt::getCmdLine ( cpStr  path,
Long  def 
) const

Returns the value of the specified command line argument as a 32-bit integer.

Parameters
pathThe path of the command line argument.
defThe value to return if the requested path is not found.

◆ getCmdLine() [5/7]

LongLong EGetOpt::getCmdLine ( cpStr  path,
LongLong  def 
) const

Returns the value of the specified command line argument as a 64-bit integer.

Parameters
pathThe path of the command line argument.
defThe value to return if the requested path is not found.

◆ getCmdLine() [6/7]

ULong EGetOpt::getCmdLine ( cpStr  path,
ULong  def 
) const

Returns the value of the specified command line argument as an unsigned 32-bit integer.

Parameters
pathThe path of the command line argument.
defThe value to return if the requested path is not found.

◆ getCmdLine() [7/7]

ULongLong EGetOpt::getCmdLine ( cpStr  path,
ULongLong  def 
) const

Returns the value of the specified command line argument as an unsigned 64-bit integer.

Parameters
pathThe path of the command line argument.
defThe value to return if the requested path is not found.

◆ getCmdLineArgs()

std::vector< EString > EGetOpt::getCmdLineArgs ( ) const

Returns a std::vector containing positional command line arguments.

◆ getCmdLineRaw()

std::vector< EString > EGetOpt::getCmdLineRaw ( ) const

Returns a std::vector containing the "raw" string command line arguments.

◆ getCount()

UInt EGetOpt::getCount ( cpStr  path) const

returns the number of configuration entries specified in a JSON array.

Parameters
pathThe path of the requested configuration parameter.

◆ loadCmdLine()

Void EGetOpt::loadCmdLine ( Int  argc,
pStr *  argv,
const EGetOpt::Option options 
)

Parses and loads the command line arguments.

Parameters
argcThe number of command line arguments.
argvA pointer to the array of command line string arguments.
optionsThe array of supported arguments.
Exceptions
EGetOptError_UnsupportedDataType
EGetOptError_UnsupportedBooleanValue
EGetOptError_UnsupportedArgType

◆ loadFile()

Void EGetOpt::loadFile ( cpStr  filename)

Parses and loads configuration values from the specified JSON file.

Parameters
filenameThe name of the JSON file to load.
Exceptions
EGetOptError_FileParsing

◆ print()

Void EGetOpt::print ( ) const

Prints the current loaded values (command line and file).

◆ setPrefix() [1/2]

Void EGetOpt::setPrefix ( const EString path)
inline

Sets the search prefix.

Parameters
pathThe prefix path.

◆ setPrefix() [2/2]

Void EGetOpt::setPrefix ( cpStr  path)
inline

Sets the search prefix.

Parameters
pathThe prefix path.

The documentation for this class was generated from the following files: