FONTAINE  1.0
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CLP Class Reference

#include <CLP.h>

Public Member Functions

 CLP (std::string name, std::string version, std::string copyright, std::string url, std::string usage)
 
void addUsage (const std::string usage)
 
void addSwitch (std::string name, std::string shortName, std::string description, unsigned numberOfArguments=0)
 
std::string getSwitchArgument (std::string name, unsigned index)
 
bool parse (unsigned int argc, const char *argv[])
 
bool hasSwitchSet (std::string name)
 
const std::vector< std::string > & getArguments ()
 
const std::vector< std::string > & getNetworkArguments ()
 
const std::vector< std::string > & getMysqlArguments ()
 
bool hasMysqlArguments ()
 
void printCopyrightNotice () const
 
void printHelp () const
 
void printArguments () const
 

Private Member Functions

void _setSwitchArguments (std::string currentSwitch, unsigned int argc, const char *argv[], unsigned int &currentIndex, CLS &cls)
 
void _processMysqlArguments (std::string argument)
 
std::string _getShortSwitchNameMapping (const std::string &shortName)
 
bool _shortNameExists (const std::string &shortName)
 

Private Attributes

std::string _name
 
std::string _version
 
std::string _copyright
 
std::string _url
 
std::string _usage
 
std::map< std::string, std::string > _shortSwitchMapping
 
std::map< std::string, CLS_switches
 
std::vector< std::string > _arguments
 
std::vector< std::string > _networkArguments
 
std::vector< std::string > _mysqlArguments
 

Static Private Attributes

static const std::string _NETWORK_TYPE = "http://"
 
static const std::string _NETWORK_TYPE_SECURE = "https://"
 
static const std::string _MYSQL_TYPE = "mysql://"
 

Constructor & Destructor Documentation

§ CLP()

CLP::CLP ( std::string  name,
std::string  version,
std::string  copyright,
std::string  url,
std::string  usage 
)

References _copyright, _name, _url, _usage, and _version.

Member Function Documentation

§ _getShortSwitchNameMapping()

std::string CLP::_getShortSwitchNameMapping ( const std::string &  shortName)
private

§ _processMysqlArguments()

void CLP::_processMysqlArguments ( std::string  argument)
private

References _mysqlArguments.

Referenced by parse().

§ _setSwitchArguments()

void CLP::_setSwitchArguments ( std::string  currentSwitch,
unsigned int  argc,
const char *  argv[],
unsigned int &  currentIndex,
CLS cls 
)
private

_setSwitchArguments: Some of the switches require arguments. This method saves the arguments passed to a switch in a map.

References CLS::addSwitchArgument(), CLS::getNumberOfSwitchArguments(), CLS::resetSwitch(), and CLS::setSwitch().

Referenced by parse().

§ _shortNameExists()

bool CLP::_shortNameExists ( const std::string &  shortName)
private

References _shortSwitchMapping.

Referenced by addSwitch().

§ addSwitch()

void CLP::addSwitch ( std::string  name,
std::string  shortName,
std::string  description,
unsigned  numberOfArguments = 0 
)

References _shortNameExists(), _shortSwitchMapping, and _switches.

Referenced by main().

§ addUsage()

void CLP::addUsage ( const std::string  usage)

§ getArguments()

const std::vector< std::string > & CLP::getArguments ( )

References _arguments.

Referenced by main().

§ getMysqlArguments()

const std::vector< std::string > & CLP::getMysqlArguments ( )

References _mysqlArguments.

§ getNetworkArguments()

const std::vector< std::string > & CLP::getNetworkArguments ( )

References _networkArguments.

§ getSwitchArgument()

std::string CLP::getSwitchArgument ( std::string  name,
unsigned  index 
)

getSwitchArgument: Some of the command line switches require arguments. This method returns the index'th argument specified by the user for a switch.

References _getShortSwitchNameMapping(), and _switches.

§ hasMysqlArguments()

bool CLP::hasMysqlArguments ( )
inline

§ hasSwitchSet()

bool CLP::hasSwitchSet ( std::string  name)

References _getShortSwitchNameMapping(), and _switches.

Referenced by main().

§ parse()

bool CLP::parse ( unsigned int  argc,
const char *  argv[] 
)

parse: Parses the command line arguments. Returns false if there was an error encountered.

References _arguments, _getShortSwitchNameMapping(), _MYSQL_TYPE, _NETWORK_TYPE, _NETWORK_TYPE_SECURE, _networkArguments, _processMysqlArguments(), _setSwitchArguments(), _switches, and printHelp().

Referenced by main().

§ printArguments()

void CLP::printArguments ( void  ) const

References _arguments.

§ printCopyrightNotice()

void CLP::printCopyrightNotice ( ) const

References _copyright, _name, _url, and _version.

Referenced by main(), and printHelp().

§ printHelp()

void CLP::printHelp ( ) const

References _switches, _usage, and printCopyrightNotice().

Referenced by main(), and parse().

Member Data Documentation

§ _arguments

std::vector<std::string> CLP::_arguments
private

Referenced by getArguments(), parse(), and printArguments().

§ _copyright

std::string CLP::_copyright
private

Referenced by CLP(), and printCopyrightNotice().

§ _MYSQL_TYPE

const std::string CLP::_MYSQL_TYPE = "mysql://"
staticprivate

Referenced by parse().

§ _mysqlArguments

std::vector<std::string> CLP::_mysqlArguments
private

§ _name

std::string CLP::_name
private

Referenced by CLP(), CLS::CLS(), and printCopyrightNotice().

§ _NETWORK_TYPE

const std::string CLP::_NETWORK_TYPE = "http://"
staticprivate

Referenced by parse().

§ _NETWORK_TYPE_SECURE

const std::string CLP::_NETWORK_TYPE_SECURE = "https://"
staticprivate

Referenced by parse().

§ _networkArguments

std::vector<std::string> CLP::_networkArguments
private

Referenced by getNetworkArguments(), and parse().

§ _shortSwitchMapping

std::map<std::string,std::string> CLP::_shortSwitchMapping
private

§ _switches

std::map<std::string, CLS> CLP::_switches
private

§ _url

std::string CLP::_url
private

Referenced by CLP(), and printCopyrightNotice().

§ _usage

std::string CLP::_usage
private

Referenced by CLP(), and printHelp().

§ _version

std::string CLP::_version
private

Referenced by CLP(), and printCopyrightNotice().


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