appkit  1.5.1
RoadNarrows Robotics Application Kit
rnr::cmd::CmdExtArg Class Reference

Command EXTended ARGument class holding parsed command context and the raw and converted argmument values. More...

#include <CmdExtArg.h>

Public Types

enum  CvtType {
  CvtTypeUndef,
  CvtTypeString,
  CvtTypeEnum,
  CvtTypeBoolean,
  CvtTypeInteger,
  CvtTypeFpn
}
 Converted types. More...
 

Public Member Functions

 CmdExtArg ()
 Default constructor.
 
 CmdExtArg (const int &nCmdUid, const int &nFormIndex, const int &nArgIndex, const int &nArgInstance, const std::string &strArg)
 Initialization constructor. More...
 
 CmdExtArg (const CmdExtArg &src)
 Copy constructor. More...
 
virtual ~CmdExtArg ()
 Destructor.
 
CmdExtArgoperator= (const CmdExtArg &rhs)
 Assignment operator. More...
 
int uid () const
 Get the argument's associated parsed command unique id. More...
 
int formIndex () const
 Get the argument's associated parsed form definition index. More...
 
int argIndex () const
 Get the argument's associated parsed argument definition index. More...
 
int argInstance () const
 Get the argument's instance number of (uid, formindex, argindex) parsed argument definition index. More...
 
const std::string & arg () const
 Get raw source argument string (or a pirate grunting). More...
 
bool isValid () const
 Check if converted value is valid. More...
 
CvtType type () const
 Get the converted argument type. More...
 
const std::string & s () const
 Get the converted string value. More...
 
long e () const
 Get the converted enumeration index value. More...
 
bool b () const
 Get the converted boolean value. More...
 
long i () const
 Get the converted integer value. More...
 
double f () const
 Get the converted floating-point number value. More...
 
bool operator== (const CmdExtArg &rval) const
 Comparison operator this == rval. More...
 
bool operator== (const std::string &rval) const
 
bool operator== (const char *const &rval) const
 
bool operator== (const bool &rval) const
 
bool operator== (const long &rval) const
 
bool operator== (const double &rval) const
 
bool operator!= (const CmdExtArg &rval) const
 Comparison operator this != rval. More...
 
bool operator!= (const std::string &rval) const
 
bool operator!= (const char *const &rval) const
 
bool operator!= (const bool &rval) const
 
bool operator!= (const long &rval) const
 
bool operator!= (const double &rval) const
 

Protected Member Functions

void arg (const std::string &strArg)
 Set the argument string value. More...
 
void s (const std::string &strVal)
 Set the converted string value. More...
 
void e (const long eVal)
 Set the converted index into literal enum list value. More...
 
void b (const bool bVal)
 Set the converted boolean value. More...
 
void i (const long lVal)
 Set the converted integer value. More...
 
void f (const double fVal)
 Set the converted floating-point number value. More...
 

Protected Attributes

int m_nCmdUid
 command definition unique id
 
int m_nFormIndex
 form definition index
 
int m_nArgIndex
 argument definition index
 
int m_nArgInstance
 argument instance (FUTURE)
 
std::string m_strArg
 argument unconverted raw value string
 
CvtType m_eCvtType
 converted type
 
std::string m_strCvtVal
 converted string value
 
bool m_bCvtVal
 converted boolean value
 
long m_lCvtVal
 converted integer/index value
 
double m_fCvtVal
 converted float-point number value
 

Friends

class CmdArgDef
 
std::ostream & operator<< (std::ostream &os, const CmdExtArg &arg)
 Insert object into output stream. More...
 
LogBookoperator<< (LogBook &log, const CmdExtArg &arg)
 Insert object into LogBook pending entry. More...
 

Detailed Description

Command EXTended ARGument class holding parsed command context and the raw and converted argmument values.

Extended arguments are an alternative command interface to the standard simple command string arguments.

Definition at line 91 of file CmdExtArg.h.

Member Enumeration Documentation

Converted types.

Enumerator
CvtTypeUndef 

unknown or uninitialized type

CvtTypeString 

string type

CvtTypeEnum 

index into literal enumeration list

CvtTypeBoolean 

boolean type

CvtTypeInteger 

integer type

CvtTypeFpn 

floating-point number type

Definition at line 97 of file CmdExtArg.h.

98  {
99  CvtTypeUndef, ///< unknown or uninitialized type
100  CvtTypeString, ///< string type
101  CvtTypeEnum, ///< index into literal enumeration list
102  CvtTypeBoolean, ///< boolean type
103  CvtTypeInteger, ///< integer type
104  CvtTypeFpn ///< floating-point number type
105  };
unknown or uninitialized type
Definition: CmdExtArg.h:99
floating-point number type
Definition: CmdExtArg.h:104
index into literal enumeration list
Definition: CmdExtArg.h:101

Constructor & Destructor Documentation

rnr::cmd::CmdExtArg::CmdExtArg ( const int &  nCmdUid,
const int &  nFormIndex,
const int &  nArgIndex,
const int &  nArgInstance,
const std::string &  strArg 
)

Initialization constructor.

Parameters
nCmdUidCommand definition unique id.
nFormIndexForm definition index.
nArgIndexArgument definition index.
nArgInstanceArgument instance (FUTURE).
strArgSource argument string.
CmdExtArg::CmdExtArg ( const CmdExtArg src)

Copy constructor.

Parameters
srcSource object.

Definition at line 109 of file CmdExtArg.cxx.

References m_bCvtVal, m_eCvtType, m_fCvtVal, m_lCvtVal, m_nArgIndex, m_nArgInstance, m_nCmdUid, m_nFormIndex, m_strArg, and m_strCvtVal.

110 {
111  m_nCmdUid = src.m_nCmdUid;
113  m_nArgIndex = src.m_nArgIndex;
115  m_strArg = src.m_strArg;
116  m_eCvtType = src.m_eCvtType;
117  m_strCvtVal = src.m_strCvtVal;
118  m_bCvtVal = src.m_bCvtVal;
119  m_lCvtVal = src.m_lCvtVal;
120  m_fCvtVal = src.m_fCvtVal;
121 }
CvtType m_eCvtType
converted type
Definition: CmdExtArg.h:339
std::string m_strArg
argument unconverted raw value string
Definition: CmdExtArg.h:336
int m_nCmdUid
command definition unique id
Definition: CmdExtArg.h:330
int m_nArgIndex
argument definition index
Definition: CmdExtArg.h:332
std::string m_strCvtVal
converted string value
Definition: CmdExtArg.h:340
double m_fCvtVal
converted float-point number value
Definition: CmdExtArg.h:343
int m_nArgInstance
argument instance (FUTURE)
Definition: CmdExtArg.h:333
bool m_bCvtVal
converted boolean value
Definition: CmdExtArg.h:341
int m_nFormIndex
form definition index
Definition: CmdExtArg.h:331
long m_lCvtVal
converted integer/index value
Definition: CmdExtArg.h:342

Member Function Documentation

const std::string& rnr::cmd::CmdExtArg::arg ( ) const
inline

Get raw source argument string (or a pirate grunting).

Returns
String.

Definition at line 194 of file CmdExtArg.h.

References m_strArg.

Referenced by operator!=(), and operator==().

194 { return m_strArg; }
std::string m_strArg
argument unconverted raw value string
Definition: CmdExtArg.h:336
void rnr::cmd::CmdExtArg::arg ( const std::string &  strArg)
inlineprotected

Set the argument string value.

Parameters
strArgSource argument string.

Definition at line 350 of file CmdExtArg.h.

References b(), e(), f(), i(), and s().

351  {
352  m_strArg = strArg;
353  }
std::string m_strArg
argument unconverted raw value string
Definition: CmdExtArg.h:336
int rnr::cmd::CmdExtArg::argIndex ( ) const
inline

Get the argument's associated parsed argument definition index.

Returns
Argument index.

Definition at line 172 of file CmdExtArg.h.

References m_nArgIndex.

Referenced by rnr::cmd::CommandLine::getArgDefType(), and rnr::cmd::CommandLine::getArgName().

172 { return m_nArgIndex; }
int m_nArgIndex
argument definition index
Definition: CmdExtArg.h:332
int rnr::cmd::CmdExtArg::argInstance ( ) const
inline

Get the argument's instance number of (uid, formindex, argindex) parsed argument definition index.

FUTURE

Returns
Argument index.

Definition at line 182 of file CmdExtArg.h.

References m_nArgInstance.

182 { return m_nArgInstance; }
int m_nArgInstance
argument instance (FUTURE)
Definition: CmdExtArg.h:333
bool rnr::cmd::CmdExtArg::b ( ) const
inline

Get the converted boolean value.

Returns
Returns bool.

Definition at line 229 of file CmdExtArg.h.

References m_bCvtVal.

Referenced by arg(), rnr::cmd::CmdArgDef::convert(), and operator==().

229 { return m_bCvtVal; }
bool m_bCvtVal
converted boolean value
Definition: CmdExtArg.h:341
void CmdExtArg::b ( const bool  bVal)
protected

Set the converted boolean value.

Parameters
bValValue to set.

Definition at line 154 of file CmdExtArg.cxx.

155 {
156  m_bCvtVal = bVal;
158 }
CvtType m_eCvtType
converted type
Definition: CmdExtArg.h:339
bool m_bCvtVal
converted boolean value
Definition: CmdExtArg.h:341
long rnr::cmd::CmdExtArg::e ( ) const
inline

Get the converted enumeration index value.

Returns
Returns index.

Definition at line 222 of file CmdExtArg.h.

References m_lCvtVal.

Referenced by arg(), and rnr::cmd::CmdArgDef::convert().

222 { return m_lCvtVal; }
long m_lCvtVal
converted integer/index value
Definition: CmdExtArg.h:342
void CmdExtArg::e ( const long  eVal)
protected

Set the converted index into literal enum list value.

Note
A literal has both a string and integer enumeration. So any relevant operators and methods supports both interface.
Parameters
eValValue to set.

Definition at line 147 of file CmdExtArg.cxx.

148 {
150  m_lCvtVal = eVal;
152 }
CvtType m_eCvtType
converted type
Definition: CmdExtArg.h:339
std::string m_strArg
argument unconverted raw value string
Definition: CmdExtArg.h:336
std::string m_strCvtVal
converted string value
Definition: CmdExtArg.h:340
index into literal enumeration list
Definition: CmdExtArg.h:101
long m_lCvtVal
converted integer/index value
Definition: CmdExtArg.h:342
double rnr::cmd::CmdExtArg::f ( ) const
inline

Get the converted floating-point number value.

Returns
Returns double.

Definition at line 243 of file CmdExtArg.h.

References m_fCvtVal, and operator==().

Referenced by arg(), rnr::cmd::CmdArgDef::convert(), and operator==().

243 { return m_fCvtVal; }
double m_fCvtVal
converted float-point number value
Definition: CmdExtArg.h:343
void CmdExtArg::f ( const double  fVal)
protected

Set the converted floating-point number value.

Parameters
fValValue to set.

Definition at line 166 of file CmdExtArg.cxx.

167 {
168  m_fCvtVal = fVal;
170 }
CvtType m_eCvtType
converted type
Definition: CmdExtArg.h:339
double m_fCvtVal
converted float-point number value
Definition: CmdExtArg.h:343
floating-point number type
Definition: CmdExtArg.h:104
int rnr::cmd::CmdExtArg::formIndex ( ) const
inline

Get the argument's associated parsed form definition index.

Returns
Form index.

Definition at line 165 of file CmdExtArg.h.

References m_nFormIndex.

Referenced by rnr::cmd::CommandLine::getArgDefType(), rnr::cmd::CommandLine::getArgName(), rnr::cmd::CommandLine::numOfArgs(), rnr::cmd::CommandLine::numOfOptionalArgs(), and rnr::cmd::CommandLine::numOfRequiredArgs().

165 { return m_nFormIndex; }
int m_nFormIndex
form definition index
Definition: CmdExtArg.h:331
long rnr::cmd::CmdExtArg::i ( ) const
inline

Get the converted integer value.

Returns
Returns long.

Definition at line 236 of file CmdExtArg.h.

References m_lCvtVal.

Referenced by arg(), rnr::cmd::CmdArgDef::convert(), and operator==().

236 { return m_lCvtVal; }
long m_lCvtVal
converted integer/index value
Definition: CmdExtArg.h:342
void CmdExtArg::i ( const long  lVal)
protected

Set the converted integer value.

Parameters
lValValue to set.

Definition at line 160 of file CmdExtArg.cxx.

161 {
162  m_lCvtVal = lVal;
164 }
CvtType m_eCvtType
converted type
Definition: CmdExtArg.h:339
long m_lCvtVal
converted integer/index value
Definition: CmdExtArg.h:342
bool rnr::cmd::CmdExtArg::isValid ( ) const
inline

Check if converted value is valid.

Returns
Returns true or false.

Definition at line 201 of file CmdExtArg.h.

References CvtTypeUndef, and m_eCvtType.

201 { return m_eCvtType != CvtTypeUndef; }
CvtType m_eCvtType
converted type
Definition: CmdExtArg.h:339
unknown or uninitialized type
Definition: CmdExtArg.h:99
bool rnr::cmd::CmdExtArg::operator!= ( const CmdExtArg rval) const
inline

Comparison operator this != rval.

Parameters
rvalRvalue object.
Returns
Returns true if not equal, false otherwise.

Definition at line 283 of file CmdExtArg.h.

References arg(), and operator<<.

283 { return !(*this == rval); }
CmdExtArg & CmdExtArg::operator= ( const CmdExtArg rhs)

Assignment operator.

Parameters
rhsRight-hand side object.
Returns
*this

Definition at line 127 of file CmdExtArg.cxx.

References m_bCvtVal, m_eCvtType, m_fCvtVal, m_lCvtVal, m_nArgIndex, m_nArgInstance, m_nCmdUid, m_nFormIndex, m_strArg, and m_strCvtVal.

128 {
129  m_nCmdUid = rhs.m_nCmdUid;
131  m_nArgIndex = rhs.m_nArgIndex;
133  m_strArg = rhs.m_strArg;
134  m_eCvtType = rhs.m_eCvtType;
135  m_strCvtVal = rhs.m_strCvtVal;
136  m_bCvtVal = rhs.m_bCvtVal;
137  m_lCvtVal = rhs.m_lCvtVal;
138  m_fCvtVal = rhs.m_fCvtVal;
139 }
CvtType m_eCvtType
converted type
Definition: CmdExtArg.h:339
std::string m_strArg
argument unconverted raw value string
Definition: CmdExtArg.h:336
int m_nCmdUid
command definition unique id
Definition: CmdExtArg.h:330
int m_nArgIndex
argument definition index
Definition: CmdExtArg.h:332
std::string m_strCvtVal
converted string value
Definition: CmdExtArg.h:340
double m_fCvtVal
converted float-point number value
Definition: CmdExtArg.h:343
int m_nArgInstance
argument instance (FUTURE)
Definition: CmdExtArg.h:333
bool m_bCvtVal
converted boolean value
Definition: CmdExtArg.h:341
int m_nFormIndex
form definition index
Definition: CmdExtArg.h:331
long m_lCvtVal
converted integer/index value
Definition: CmdExtArg.h:342
bool CmdExtArg::operator== ( const CmdExtArg rval) const

Comparison operator this == rval.

Parameters
rvalRvalue object.
Returns
Returns true if equal, false otherwise.

Definition at line 172 of file CmdExtArg.cxx.

References arg(), b(), f(), i(), operator<<(), s(), type(), and rnr::cmd::undefstring.

Referenced by f().

173 {
174  return (type() == rval.type()) && (arg() == rval.arg());
175 }
CvtType type() const
Get the converted argument type.
Definition: CmdExtArg.h:208
const std::string & arg() const
Get raw source argument string (or a pirate grunting).
Definition: CmdExtArg.h:194
const std::string& rnr::cmd::CmdExtArg::s ( ) const
inline

Get the converted string value.

Returns
Returns string.

Definition at line 215 of file CmdExtArg.h.

References m_strCvtVal.

Referenced by arg(), rnr::cmd::CmdArgDef::convert(), and operator==().

215 { return m_strCvtVal; }
std::string m_strCvtVal
converted string value
Definition: CmdExtArg.h:340
void rnr::cmd::CmdExtArg::s ( const std::string &  strVal)
protected

Set the converted string value.

Parameters
strValValue to set.
CvtType rnr::cmd::CmdExtArg::type ( ) const
inline

Get the converted argument type.

Returns
CmdExtArg::CvtType value.

Definition at line 208 of file CmdExtArg.h.

References m_eCvtType.

Referenced by operator==().

208 { return m_eCvtType; }
CvtType m_eCvtType
converted type
Definition: CmdExtArg.h:339
int rnr::cmd::CmdExtArg::uid ( ) const
inline

Get the argument's associated parsed command unique id.

Returns
Unique id.

Definition at line 158 of file CmdExtArg.h.

References m_nCmdUid.

Referenced by checkCmd(), rnr::cmd::CommandLine::getArgDefType(), rnr::cmd::CommandLine::getArgName(), rnr::cmd::CommandLine::numOfArgs(), rnr::cmd::CommandLine::numOfOptionalArgs(), and rnr::cmd::CommandLine::numOfRequiredArgs().

158 { return m_nCmdUid; }
int m_nCmdUid
command definition unique id
Definition: CmdExtArg.h:330

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CmdExtArg arg 
)
friend

Insert object into output stream.

Parameters
osOutput stream.
argObject to insert.
Returns
Reference to output stream.

Referenced by operator!=().

LogBook& operator<< ( LogBook log,
const CmdExtArg arg 
)
friend

Insert object into LogBook pending entry.

Parameters
logLogBook stream.
argObject to insert.
Returns
Reference to LogBook.

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