HPCToolkit
CmdLineParser Class Reference

#include <CmdLineParser.hpp>

Collaboration diagram for CmdLineParser:

Classes

class  Exception
 
class  InternalError
 
struct  OptArgDesc
 
class  ParseError
 
class  SwDesc
 

Public Types

enum  OptKind { ARG_NULL = 0, ARG_NONE, ARG_REQ, ARG_OPT }
 
enum  DupOptKind { DUPOPT_NULL = 0, DUPOPT_ERR, DUPOPT_CLOB, DUPOPT_CAT }
 
typedef bool(* IsOptArg_fn_t) (const char *str)
 

Public Member Functions

 CmdLineParser ()
 
 CmdLineParser (const OptArgDesc *optArgDescs, int argc, const char *const argv[])
 
 ~CmdLineParser ()
 
void parse (const OptArgDesc *optArgDescs, int argc, const char *const argv[])
 
const std::string & getCmd () const
 
bool isOpt (const char swShort) const
 
bool isOpt (const char *swLong) const
 
bool isOpt (const std::string &sw) const
 
bool isOptArg (const char swShort) const
 
bool isOptArg (const char *swLong) const
 
bool isOptArg (const std::string &sw) const
 
const std::string & getOptArg (const char swShort) const
 
const std::string & getOptArg (const char *swLong) const
 
const std::string & getOptArg (const std::string &sw) const
 
unsigned int getNumArgs () const
 
const std::string & getArg (unsigned int i) const
 
void dump (std::ostream &os=std::cerr) const
 
void ddump () const
 

Static Public Member Functions

static long toLong (const std::string &str)
 
static uint64_t toUInt64 (const std::string &str)
 
static double toDbl (const std::string &str)
 
static bool isOptArg_long (const char *option)
 
static bool parseArg_bool (const std::string &value, const char *errTag)
 

Static Public Attributes

static OptArgDesc OptArgDesc_NULL
 

Private Types

typedef std::map< std::string, std::string * > SwitchToArgMap
 
typedef std::vector< std::string > ArgVec
 

Private Member Functions

 CmdLineParser (const CmdLineParser &GCC_ATTR_UNUSED x)
 
CmdLineParseroperator= (const CmdLineParser &GCC_ATTR_UNUSED x)
 
void Ctor ()
 
void reset ()
 
void checkForErrors (const OptArgDesc *optArgDescs)
 
const OptArgDesccreateSortedCopy (const OptArgDesc *optArgDescs)
 
SwDesc makeSwitchDesc (const char *str)
 
const OptArgDescfindOptDesc (const OptArgDesc *optArgDescs, const SwDesc &swdesc, bool errOnMultipleMatches=true)
 
void addOption (const OptArgDesc &odesc, const SwDesc &swdesc)
 
void addOption (const OptArgDesc &odesc, const std::string &sw, const std::string &arg)
 

Private Attributes

std::string command
 
SwitchToArgMap switchToArgMap
 
ArgVec arguments
 

Detailed Description

Definition at line 152 of file CmdLineParser.hpp.

Member Typedef Documentation

◆ ArgVec

typedef std::vector<std::string> CmdLineParser::ArgVec
private

Definition at line 386 of file CmdLineParser.hpp.

◆ IsOptArg_fn_t

typedef bool(* CmdLineParser::IsOptArg_fn_t) (const char *str)

Definition at line 179 of file CmdLineParser.hpp.

◆ SwitchToArgMap

typedef std::map<std::string, std::string*> CmdLineParser::SwitchToArgMap
private

Definition at line 385 of file CmdLineParser.hpp.

Member Enumeration Documentation

◆ DupOptKind

Enumerator
DUPOPT_NULL 
DUPOPT_ERR 
DUPOPT_CLOB 
DUPOPT_CAT 

Definition at line 168 of file CmdLineParser.hpp.

◆ OptKind

Enumerator
ARG_NULL 
ARG_NONE 
ARG_REQ 
ARG_OPT 

Definition at line 160 of file CmdLineParser.hpp.

Constructor & Destructor Documentation

◆ CmdLineParser() [1/3]

CmdLineParser::CmdLineParser ( )

Definition at line 173 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ CmdLineParser() [2/3]

CmdLineParser::CmdLineParser ( const OptArgDesc optArgDescs,
int  argc,
const char *const  argv[] 
)

Definition at line 178 of file CmdLineParser.cpp.

◆ ~CmdLineParser()

CmdLineParser::~CmdLineParser ( )

Definition at line 193 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ CmdLineParser() [3/3]

CmdLineParser::CmdLineParser ( const CmdLineParser &GCC_ATTR_UNUSED  x)
inlineprivate

Definition at line 378 of file CmdLineParser.hpp.

Member Function Documentation

◆ addOption() [1/2]

void CmdLineParser::addOption ( const OptArgDesc odesc,
const SwDesc swdesc 
)
private

Definition at line 711 of file CmdLineParser.cpp.

◆ addOption() [2/2]

void CmdLineParser::addOption ( const OptArgDesc odesc,
const std::string &  sw,
const std::string &  arg 
)
private

◆ checkForErrors()

void CmdLineParser::checkForErrors ( const OptArgDesc optArgDescs)
private

Definition at line 549 of file CmdLineParser.cpp.

◆ createSortedCopy()

const CmdLineParser::OptArgDesc * CmdLineParser::createSortedCopy ( const OptArgDesc optArgDescs)
private

Definition at line 522 of file CmdLineParser.cpp.

Here is the call graph for this function:

◆ Ctor()

void CmdLineParser::Ctor ( )
private

Definition at line 186 of file CmdLineParser.cpp.

◆ ddump()

void CmdLineParser::ddump ( ) const

Definition at line 497 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ dump()

void CmdLineParser::dump ( std::ostream &  os = std::cerr) const

Definition at line 477 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ findOptDesc()

const CmdLineParser::OptArgDesc * CmdLineParser::findOptDesc ( const OptArgDesc optArgDescs,
const SwDesc swdesc,
bool  errOnMultipleMatches = true 
)
private

Definition at line 646 of file CmdLineParser.cpp.

◆ getArg()

const string & CmdLineParser::getArg ( unsigned int  i) const

Definition at line 382 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ getCmd()

const string & CmdLineParser::getCmd ( ) const

Definition at line 290 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ getNumArgs()

unsigned int CmdLineParser::getNumArgs ( ) const

Definition at line 376 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ getOptArg() [1/3]

const string & CmdLineParser::getOptArg ( const char  swShort) const

Definition at line 347 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ getOptArg() [2/3]

const string & CmdLineParser::getOptArg ( const char *  swLong) const

Definition at line 354 of file CmdLineParser.cpp.

Here is the call graph for this function:

◆ getOptArg() [3/3]

const std::string& CmdLineParser::getOptArg ( const std::string &  sw) const

◆ isOpt() [1/3]

bool CmdLineParser::isOpt ( const char  swShort) const

Definition at line 298 of file CmdLineParser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isOpt() [2/3]

bool CmdLineParser::isOpt ( const char *  swLong) const

Definition at line 305 of file CmdLineParser.cpp.

Here is the call graph for this function:

◆ isOpt() [3/3]

bool CmdLineParser::isOpt ( const std::string &  sw) const

◆ isOptArg() [1/3]

bool CmdLineParser::isOptArg ( const char  swShort) const

Definition at line 321 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ isOptArg() [2/3]

bool CmdLineParser::isOptArg ( const char *  swLong) const

Definition at line 328 of file CmdLineParser.cpp.

Here is the call graph for this function:

◆ isOptArg() [3/3]

bool CmdLineParser::isOptArg ( const std::string &  sw) const

◆ isOptArg_long()

bool CmdLineParser::isOptArg_long ( const char *  option)
static

Definition at line 441 of file CmdLineParser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeSwitchDesc()

CmdLineParser::SwDesc CmdLineParser::makeSwitchDesc ( const char *  str)
private

Definition at line 596 of file CmdLineParser.cpp.

Here is the call graph for this function:

◆ operator=()

CmdLineParser& CmdLineParser::operator= ( const CmdLineParser &GCC_ATTR_UNUSED  x)
inlineprivate

Definition at line 382 of file CmdLineParser.hpp.

◆ parse()

void CmdLineParser::parse ( const OptArgDesc optArgDescs,
int  argc,
const char *const  argv[] 
)

Definition at line 200 of file CmdLineParser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseArg_bool()

bool CmdLineParser::parseArg_bool ( const std::string &  value,
const char *  errTag 
)
static

Definition at line 455 of file CmdLineParser.cpp.

Here is the caller graph for this function:

◆ reset()

void CmdLineParser::reset ( )
private

Definition at line 507 of file CmdLineParser.cpp.

◆ toDbl()

double CmdLineParser::toDbl ( const std::string &  str)
static

Definition at line 423 of file CmdLineParser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toLong()

long CmdLineParser::toLong ( const std::string &  str)
static

Definition at line 391 of file CmdLineParser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toUInt64()

uint64_t CmdLineParser::toUInt64 ( const std::string &  str)
static

Definition at line 407 of file CmdLineParser.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ arguments

ArgVec CmdLineParser::arguments
private

Definition at line 444 of file CmdLineParser.hpp.

◆ command

std::string CmdLineParser::command
private

Definition at line 442 of file CmdLineParser.hpp.

◆ OptArgDesc_NULL

CmdLineParser::OptArgDesc CmdLineParser::OptArgDesc_NULL
static
Initial value:

Definition at line 206 of file CmdLineParser.hpp.

◆ switchToArgMap

SwitchToArgMap CmdLineParser::switchToArgMap
private

Definition at line 443 of file CmdLineParser.hpp.


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