To pass to all informations required during the construction to configure Case instances. More...

#include <Defaults.h>

Inheritance diagram for Libpf::User::Defaults:

Public Member Functions

 Defaults (const std::string &tag="", const std::string &description="")
 
int parseArgv (int argc, char *argv[])
 
Defaults relay (const std::string &tag, const std::string &description) const
 
Defaults filter (const std::string &prefix) const
 
void addIntegerOption (std::string name, int value)
 set Integer option with name to the value, but only if that option is not already set More...
 
Defaultsoperator() (std::string name, int value)
 set Integer option with name to the value with currying syntax, but only if that option is not already set More...
 
void addStringOption (std::string name, std::string value)
 set String option with name to the value, but only if that option is not already set More...
 
Defaultsoperator() (std::string name, std::string value)
 set String option with name to the value with currying syntax, but only if that option is not already set More...
 
const std::string & tag (void) const
 return tag More...
 
const std::string & description (void) const
 return description More...
 
int size (void) const
 return total number of options More...
 
int si (const std::string &s) const
 
const std::string & ss (const std::string &s) const
 
const std::map< std::string,
int > & 
msi (void) const
 
const std::map< std::string,
std::string > & 
mss (void) const
 
bool ssCheck (const std::string &s) const
 
bool siCheck (const std::string &s) const
 

Protected Member Functions

std::ostream & print_ (std::ostream &os) const
 

Protected Attributes

std::string tag_
 UTF-8 encoded human-readable label. More...
 
std::string description_
 UTF-8 encoded description. More...
 
std::map< std::string, int > integerOptions_
 associative array of Integer tags / values More...
 
std::map< std::string,
std::string > 
stringOptions_
 associative array of String tags / values More...
 

Static Protected Attributes

static std::string emptyString_
 used to return an empty string if no option is found More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Defaults &opt)
 

Detailed Description

To pass to all informations required during the construction to configure Case instances.

#include <libpf/user/Defaults.h>

Remarks
Warning
Thread safe:
Extendable:
Platform dependencies:

Constructor & Destructor Documentation

Libpf::User::Defaults::Defaults ( const std::string &  tag = "",
const std::string &  description = "" 
)
Parameters
tagUTF-8 encoded human-readable label
descriptionUTF-8 encoded description

Member Function Documentation

void Libpf::User::Defaults::addIntegerOption ( std::string  name,
int  value 
)

set Integer option with name to the value, but only if that option is not already set

void Libpf::User::Defaults::addStringOption ( std::string  name,
std::string  value 
)

set String option with name to the value, but only if that option is not already set

const std::string& Libpf::User::Defaults::description ( void  ) const

return description

Defaults Libpf::User::Defaults::filter ( const std::string &  prefix) const

return a copy, containing only the options starting with prefix, stripped of prefix

Parameters
prefixthe prefix for the options to forward
const std::map<std::string, int>& Libpf::User::Defaults::msi ( void  ) const
Returns
reference to the associative array of Integer tags / values
const std::map<std::string, std::string>& Libpf::User::Defaults::mss ( void  ) const
Returns
reference to the associative array of String tags / values
Defaults& Libpf::User::Defaults::operator() ( std::string  name,
int  value 
)

set Integer option with name to the value with currying syntax, but only if that option is not already set

Defaults& Libpf::User::Defaults::operator() ( std::string  name,
std::string  value 
)

set String option with name to the value with currying syntax, but only if that option is not already set

int Libpf::User::Defaults::parseArgv ( int  argc,
char *  argv[] 
)

read in options in argument list, in the format option1=a option2=b ... empty option values and values starting with an alphabetic (a-z, A-Z) character will go in Strings all the other option values will be read in as Integers returns the number of read options

std::ostream& Libpf::User::Defaults::print_ ( std::ostream &  os) const
protected
Defaults Libpf::User::Defaults::relay ( const std::string &  tag,
const std::string &  description 
) const

return a copy, with overridden tag and description

Parameters
tagUTF-8 encoded human-readable label
descriptionUTF-8 encoded description
int Libpf::User::Defaults::si ( const std::string &  s) const
Returns
value of Integer option with tag s or -1 if not specified
Parameters
stag of Integer option
bool Libpf::User::Defaults::siCheck ( const std::string &  s) const

check for existence of String option with tag s

Returns
true if String option with tag s exists
Parameters
stag of String option
int Libpf::User::Defaults::size ( void  ) const

return total number of options

const std::string& Libpf::User::Defaults::ss ( const std::string &  s) const
Returns
value of String option with tag s or empty string if not specified
Parameters
stag of String option
bool Libpf::User::Defaults::ssCheck ( const std::string &  s) const

check for existence of Integer option with tag s

Returns
true if Integer option with tag s exists
Parameters
stag of Integer option
const std::string& Libpf::User::Defaults::tag ( void  ) const

return tag

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Defaults opt 
)
friend

Member Data Documentation

std::string Libpf::User::Defaults::description_
protected

UTF-8 encoded description.

std::string Libpf::User::Defaults::emptyString_
staticprotected

used to return an empty string if no option is found

std::map<std::string, int> Libpf::User::Defaults::integerOptions_
protected

associative array of Integer tags / values

std::map<std::string, std::string> Libpf::User::Defaults::stringOptions_
protected

associative array of String tags / values

std::string Libpf::User::Defaults::tag_
protected

UTF-8 encoded human-readable label.


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