fs::ut::str::CmdLn_t Class Reference

#include <fsStrUt.h>

Collaboration diagram for fs::ut::str::CmdLn_t:

Collaboration graph
[legend]
List of all members.

Detailed Description

Command line parser.

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.

Examples:

_tests/fsStrUt/main.cpp.

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_toperator= (const CmdLn_t &)
 No assignment.

Private Attributes

void * m_pImpl
 The PIPML idiom is used.


Constructor & Destructor Documentation

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 (  ) 

Definition at line 402 of file fsStrUt.cpp.

References FS_ASSERT_MSG, and m_pImpl.

fs::ut::str::CmdLn_t::CmdLn_t (  )  [private]

No def ctor.

fs::ut::str::CmdLn_t::CmdLn_t ( const CmdLn_t  )  [private]

No copy.


Member Function Documentation

int CmdLn_t::FindTok ( const char *  pszTok  )  const

Finds the index of the token (-1 if not found).

Examples:
_tests/fsStrUt/main.cpp.

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.

Examples:
_tests/fsStrUt/main.cpp.

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).

Examples:
_tests/fsStrUt/main.cpp.

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).

Examples:
_tests/fsStrUt/main.cpp.

Definition at line 408 of file fsStrUt.cpp.

References FS_ASSERT_MSG, and m_pImpl.

CmdLn_t& fs::ut::str::CmdLn_t::operator= ( const CmdLn_t  )  [private]

No assignment.


Member Data Documentation

void* fs::ut::str::CmdLn_t::m_pImpl [private]

The PIPML idiom is used.

Definition at line 164 of file fsStrUt.h.


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

FipS' Code (Thu Feb 15 22:43:56 2007) - (c) Filip STOKLAS (FipS) - [ www ] [ Guest Book ]