mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
mx::app::configTarget Struct Reference

A configuration target.

Specifies the details of a configuration target, which is a value that can be set from the command line and/or a config file. A target has a name used as a key for accessing it, and defines how it is set with short and long command line options and the section and key for the config file. Can also include help message details.

Definition at line 53 of file configTarget.hpp.

#include <app/configTarget.hpp>

Public Member Functions

 configTarget ()
 Default c'tor. More...
 
 configTarget (const std::string &n, const std::string &so, const std::string &lo, int clt, const std::string &s, const std::string &kw, bool isReq=false, const std::string &ht="", const std::string &he="", int oa=0)
 Construct and set values. More...
 

Public Attributes

std::string name
 The name of the target. More...
 
std::string shortOpt
 The command-line short option (e.g. "f" for -f) More...
 
std::string longOpt
 The command-line long option (e.g. "file" for –file) More...
 
int clType {0}
 The command-line option type, argType::false, argType::true, argType::optional, argType::required. More...
 
std::string section
 The config file section name, can be empty "". More...
 
std::string keyword
 The config file keyword, read in a "keyword=value" pair. More...
 
bool set {false}
 true if the value has been set by the configuration, use to distinguish empty strings More...
 
bool isRequired {false}
 Whether or not this is option is required to be set. More...
 
std::string helpType
 The type to display in the help message. More...
 
std::string helpExplanation
 The explanation to display in the help message. More...
 
std::vector< std::string > values
 holds the values in the order they are set by the configuration More...
 
std::vector< std::string > sources
 holds the sources of the values (command line or config file path) More...
 
int verbosity {0}
 Records the verbosity of command line options. E.g. for -v:1, -vv:2, -vvv:3 etc. More...
 
int orderAdded {0}
 The order in which this was added. Useful for displaying help messages. More...
 

Constructor & Destructor Documentation

◆ configTarget() [1/2]

mx::app::configTarget::configTarget ( )
inline

Default c'tor.

Definition at line 78 of file configTarget.hpp.

◆ configTarget() [2/2]

mx::app::configTarget::configTarget ( const std::string &  n,
const std::string &  so,
const std::string &  lo,
int  clt,
const std::string &  s,
const std::string &  kw,
bool  isReq = false,
const std::string &  ht = "",
const std::string &  he = "",
int  oa = 0 
)
inline

Construct and set values.

Parameters
[in]nThe name of the target
[in]soThe command-line short option (e.g. "f" for -f)
[in]loThe command-line long option (e.g. "file" for --file)
[in]cltThe command-line option type, argType::false, argType::true, argType::optional, argType::required
[in]sThe config file section name, can be empty ""
[in]kwThe config file keyword, read in a "keyword=value" pair
[in]isReqWhether or not this is option is required to be set
[in]htThe type to display in the help message
[in]heThe explanation to display in the help message
[in]oa[optional] ///< the order in which this was added.

Definition at line 83 of file configTarget.hpp.

Member Data Documentation

◆ clType

int mx::app::configTarget::clType {0}

The command-line option type, argType::false, argType::true, argType::optional, argType::required.

Definition at line 58 of file configTarget.hpp.

◆ helpExplanation

std::string mx::app::configTarget::helpExplanation

The explanation to display in the help message.

Definition at line 66 of file configTarget.hpp.

Referenced by mx::app::application::optionHelp().

◆ helpType

std::string mx::app::configTarget::helpType

The type to display in the help message.

Definition at line 65 of file configTarget.hpp.

Referenced by mx::app::application::optionHelp().

◆ isRequired

bool mx::app::configTarget::isRequired {false}

Whether or not this is option is required to be set.

Definition at line 64 of file configTarget.hpp.

◆ keyword

std::string mx::app::configTarget::keyword

The config file keyword, read in a "keyword=value" pair.

Definition at line 60 of file configTarget.hpp.

Referenced by mx::app::appConfigurator::add(), and mx::app::application::optionHelp().

◆ longOpt

std::string mx::app::configTarget::longOpt

The command-line long option (e.g. "file" for –file)

Definition at line 57 of file configTarget.hpp.

Referenced by mx::app::application::optionHelp().

◆ name

std::string mx::app::configTarget::name

The name of the target.

Definition at line 55 of file configTarget.hpp.

Referenced by mx::app::appConfigurator::add().

◆ orderAdded

int mx::app::configTarget::orderAdded {0}

The order in which this was added. Useful for displaying help messages.

Definition at line 73 of file configTarget.hpp.

Referenced by mx::app::application::optionHelp().

◆ section

std::string mx::app::configTarget::section

The config file section name, can be empty "".

Definition at line 59 of file configTarget.hpp.

Referenced by mx::app::appConfigurator::add(), and mx::app::application::optionHelp().

◆ set

bool mx::app::configTarget::set {false}

true if the value has been set by the configuration, use to distinguish empty strings

Definition at line 61 of file configTarget.hpp.

◆ shortOpt

std::string mx::app::configTarget::shortOpt

The command-line short option (e.g. "f" for -f)

Definition at line 56 of file configTarget.hpp.

Referenced by mx::app::application::optionHelp().

◆ sources

std::vector<std::string> mx::app::configTarget::sources

holds the sources of the values (command line or config file path)

Definition at line 70 of file configTarget.hpp.

◆ values

std::vector<std::string> mx::app::configTarget::values

holds the values in the order they are set by the configuration

Definition at line 69 of file configTarget.hpp.

◆ verbosity

int mx::app::configTarget::verbosity {0}

Records the verbosity of command line options. E.g. for -v:1, -vv:2, -vvv:3 etc.

Definition at line 72 of file configTarget.hpp.


The documentation for this struct was generated from the following file: