#include <fsStrUt.h>
Collaboration diagram for fs::ut::str::CmdLn_t:
The class parses the given command line and manages tokens and key / value pairs. The expected command line format is: 'foo -key1 value1 -switch -key2 "complex value2" ...'. Later, it is possible to query the value of a key using GetVal (both are strings). The keys are prefixed with '-' symbol. Note that all consecutive keys except for the one just before the value are discarded. Similarly, if there are consecutive values after the key, only the first value is employed. Quotes can be used to form more complex values.
Definition at line 138 of file fsStrUt.h.
Public Member Functions | |
CmdLn_t (const char *pszCmdLn) | |
Parses the given command line string. | |
CmdLn_t (int argc, char *argv[]) | |
Parses the standard command line. | |
~CmdLn_t () | |
const char * | GetVal (const char *pszKey) const |
Returns a value for the given key (0 if not found). | |
int | GetNumToks () const |
Returns the total number of tokens. | |
const char * | GetTok (int nIdx) const |
Returns a token at the given index (0 if out of range). | |
int | FindTok (const char *pszTok) const |
Finds the index of the token (-1 if not found). | |
Private Member Functions | |
CmdLn_t () | |
No def ctor. | |
CmdLn_t (const CmdLn_t &) | |
No copy. | |
CmdLn_t & | operator= (const CmdLn_t &) |
No assignment. | |
Private Attributes | |
void * | m_pImpl |
The PIPML idiom is used. |
CmdLn_t::CmdLn_t | ( | const char * | pszCmdLn | ) | [explicit] |
Parses the given command line string.
Definition at line 390 of file fsStrUt.cpp.
References FS_ASSERT_MSG, and m_pImpl.
CmdLn_t::CmdLn_t | ( | int | argc, | |
char * | argv[] | |||
) |
Parses the standard command line.
Definition at line 396 of file fsStrUt.cpp.
References FS_ASSERT_MSG, and m_pImpl.
CmdLn_t::~CmdLn_t | ( | ) |
fs::ut::str::CmdLn_t::CmdLn_t | ( | ) | [private] |
No def ctor.
fs::ut::str::CmdLn_t::CmdLn_t | ( | const CmdLn_t & | ) | [private] |
No copy.
int CmdLn_t::FindTok | ( | const char * | pszTok | ) | const |
Finds the index of the token (-1 if not found).
Definition at line 426 of file fsStrUt.cpp.
References FS_ASSERT_MSG, and m_pImpl.
int CmdLn_t::GetNumToks | ( | ) | const |
Returns the total number of tokens.
Definition at line 414 of file fsStrUt.cpp.
References FS_ASSERT_MSG, and m_pImpl.
const char * CmdLn_t::GetTok | ( | int | nIdx | ) | const |
Returns a token at the given index (0 if out of range).
Definition at line 420 of file fsStrUt.cpp.
References FS_ASSERT_MSG, and m_pImpl.
const char * CmdLn_t::GetVal | ( | const char * | pszKey | ) | const |
Returns a value for the given key (0 if not found).
Definition at line 408 of file fsStrUt.cpp.
References FS_ASSERT_MSG, and m_pImpl.
void* fs::ut::str::CmdLn_t::m_pImpl [private] |