AppArgs(3)

NAME
AppArgs -

Application arguments'.

SYNOPSIS

#include <appargs.h>

  Static Public Member Functions
static void Init (size_t valMinCnt=0, size_t valMaxCnt=APPARGS_NOLIMIT)
Initializes the processor'.
static void Destroy ()
Releases resources allocated by the processor'.
static void Parse (int argc, const char *const *argv)
Parses arguments and builds the appropriate structure'.
static bool IsValid ()
Checks whether the arguments have valid form'.
static bool ExistsOption (const std::string &rArg)
Checks whether an option exists'.
static bool GetOption (const std::string &rArg, std::string &rVal)
Extracts an option value'.
static bool AddOption (const std::string &rName, char cShort, AppArgType_t type, bool fMandatory)
Adds an option'.
static size_t GetValueCount ()
Returns the count of values'.
static bool GetValue (size_t index, std::string &rVal)
Extracts a value'.
static void Dump ()
Dumps information about options and value to STDERR'.

  Static Protected Member Functions
static bool IsOption (const char *pchStr)
Checks whether a string is an option'.
static bool IsLongOption (const char *pchStr)
Checks whether a string is a long option'.
static bool ParseLong (const char *pchStr, std::string &rName, std::string &rVal, bool &rfHasVal)
Parses a string and attempts to treat it as a long option'.
static void ParseShort (const char *pchStr, char &rcName, std::string &rVal, bool &rfHasVal)
Parses a string and attempts to treat it as a short option'.
static void DumpOption (const std::string &rName, char cShort, AppArgOption_t *pOpt)
Dumps an option to STDERR'.

Detailed Description

Application arguments'. This class is set-up for processing command line arguments'. Then it parses these arguments and builds data which can be queried later'.

There are two categories of arguments:
•   options (a'.k'.a'. switches)
•   values
Options represent changeable parameters of the application'. Values are a kind of input data'.
Each option has one of the following types:
•   no value (two-state logic, e'.g'. running on foreground/background)
•   optional value (e'.g'. for logging: another file than default can be specified)
•   mandatory value (e'.g'. custom configuration file)
Each option always have two forms - long one (introcuded by two hyphens, e'.g'. --edit) and short one (introduced by one hyphen, e'.g'. -e)'. These forms are functionally equivalent'.
Unknown options are silently ignored'.

Member Function Documentation

  bool AppArgs::AddOption (const std::string &rName, charcShort, AppArgType_ttype, boolfMandatory) [static]
Adds an option'. This method is intended to be called between initilization and parsing'. It adds an option which may (or must) occur inside the argument vector'.
Parameters:
    rName long option name
    cShort short (one-character) option name
    type argument type
    fMandatory option is mandatory yes/no
Returns:
    true = success, false = failure (e'.g'. option already exists)

  void AppArgs::Destroy () [static]
Releases resources allocated by the processor'. This method should be called if the argument values are no longer needed'.

  void AppArgs::Dump () [static]
Dumps information about options and value to STDERR'. Attention:
    This method may be very slow'.

  void AppArgs::DumpOption (const std::string &rName, charcShort, AppArgOption_t *pOpt) [static, protected]
Dumps an option to STDERR'. Parameters:
    rName long option name
    cShort short option name
    pOpt option data

  bool AppArgs::ExistsOption (const std::string &rArg) [static]
Checks whether an option exists'. Parameters:
    rArg long option name
Returns:
    true = option exists, false = otherwise

  bool AppArgs::GetOption (const std::string &rArg, std::string &rVal) [static]
Extracts an option value'. Parameters:
    rArg long option name
    rVal option value
Returns:
    true = value extracted, false = option not found or has no value

  bool AppArgs::GetValue (size_tindex, std::string &rVal) [static]
Extracts a value'. Parameters:
    index value index
    rVal extracted value
Returns:
    true = value extracted, false = otherwise

  size_t AppArgs::GetValueCount () [static]
Returns the count of values'. Returns:
    count of values

  void AppArgs::Init (size_tvalMinCnt = 0, size_tvalMaxCnt = APPARGS_NOLIMIT) [static]
Initializes the processor'. Parameters:
    valMinCnt minimum count of values
    valMaxCnt maximum number of values (no effect if lower than valMinCnt)

  bool AppArgs::IsLongOption (const char *pchStr) [static, protected]
Checks whether a string is a long option'. This methos assumes the string is an option (if not the behavior is undefined)'.
Parameters:
    pchStr text string
Returns:
    true = option, false = otherwise

  bool AppArgs::IsOption (const char *pchStr) [static, protected]
Checks whether a string is an option'. Parameters:
    pchStr text string
Returns:
    true = option, false = otherwise

  bool AppArgs::IsValid () [static]
Checks whether the arguments have valid form'. Arguments are valid if:
•   all mandatory options are present
•   all options with mandatory values have their values
•   value count is between its minimum and maximum
•   there are no unknown options (if unknown options are not accepted)
Returns:
    true = arguments valid, false = otherwise

  void AppArgs::Parse (intargc, const char *const *argv) [static]
Parses arguments and builds the appropriate structure'. Parameters:
    argc argument count
    argv argument vector
Attention:
    All errors are silently ignored'.

  bool AppArgs::ParseLong (const char *pchStr, std::string &rName, std::string &rVal, bool &rfHasVal) [static, protected]
Parses a string and attempts to treat it as a long option'. Parameters:
    pchStr text string
    rName option name
    rVal value string
    rfHasVal option has value yes/no
Returns:
    true = success, false = failure

  void AppArgs::ParseShort (const char *pchStr, char &rcName, std::string &rVal, bool &rfHasVal) [static, protected]
Parses a string and attempts to treat it as a short option'. Parameters:
    pchStr text string
    rcName option name
    rVal value string
    rfHasVal option has value yes/no
Attention:
    This method assumes the string is a valid short option'.

Author
Generated automatically by Doxygen for incron from the source code'.