appkit  1.5.1
RoadNarrows Robotics Application Kit
rnr::cmd Namespace Reference

Commands. More...

Namespaces

 addons
 Add-Ons.
 

Classes

class  CmdArgDef
 Command argument compiled definition class. More...
 
class  CmdDef
 Compiled command definition class. More...
 
struct  CmdDesc
 User available command description structure. More...
 
struct  CmdExec
 Helper class to hold a command line execution function. More...
 
class  CmdExtArg
 Command EXTended ARGument class holding parsed command context and the raw and converted argmument values. More...
 
class  CmdFormDef
 Compiled command form defintion class. More...
 
class  CommandLine
 CommandLine class. More...
 
class  DataSect
 Command line interface data section class. More...
 
struct  DataSectCore
 Core data section type. More...
 
struct  NameValuePair
 Handy Dandy Name-Value Pair entry structure. More...
 
class  ReadLine
 ReadLine class provides a C++ wrapper around the readline C library. More...
 
class  Token
 Parsed token container class. More...
 

Typedefs

typedef std::vector< CmdArgDefArgDefVec
 vector of argument defs
 
typedef std::vector< CmdExtArgCmdExtArgVec
 vector of ext args type
 
typedef std::vector< CmdFormDefCmdFormDefVec
 vector of command forms
 
typedef int(* CmdExec1Func) (const str::StringVec &argv)
 Command execution function type, variant 1. More...
 
typedef int(* CmdExec2Func) (const CmdExtArgVec &argv)
 Command execution function type, variant 2. More...
 
typedef int(* CmdExec3Func) (CommandLine &cli, const CmdExtArgVec &argv)
 Command execution function type, variant 3. More...
 
typedef std::map< unsigned, CmdDefCmdDefMap
 command map type
 
typedef CmdDefMap::iterator CmdDefIter
 cmd iterator type
 
typedef CmdDefMap::const_iterator CmdDefCIter
 cmd const iter type
 
typedef std::map< unsigned, CmdExecCmdExecMap
 exec map type
 
typedef CmdExecMap::iterator CmdExecIter
 exec iterator type
 
typedef CmdExecMap::const_iterator CmdExecCIter
 exec const iter type
 
typedef std::map< std::string, DataSectDataSectMap
 section map type
 
typedef DataSectMap::iterator DataSectIter
 iterator type
 
typedef DataSectMap::const_iterator DataSectCIter
 const iter type
 
typedef str::StringVec PromptStack
 prompt stack type
 
typedef std::vector< TokenTokenVec
 vector of tokens type
 

Functions

bool isIdentifier (const std::string &str)
 Test if string is a valid identifier. More...
 
const string undefstring ("undef")
 empty string
 
bool isIdentifier (const string &str)
 
static bool isspecial (int c)
 Command usage syntax special characters. More...
 
static bool isdquote (int c)
 Test if c is a double quote character.
 
static bool isoparen (int c)
 Test if c is a open parenthesis character.
 
static bool iscparen (int c)
 Test if c is a close parenthesis character.
 
static bool isesc (int c)
 Testif c is an escape character.
 
static char tohex (int c)
 Convert ascii character to binary character value. More...
 

Variables

const int AOk = OK
 (0) A-Ok, no error, success, good
 
const int EError = -1
 general, unspecified error
 
const int EEoF = -2
 end of file
 
const int ERead = -3
 read error
 
const int EAmbigCmd = -4
 ambiguous command
 
const int EUnknownCmd = -5
 unknown, unmatched command
 
const int EBadSyntax = -6
 bad syntax
 
const int ENoExec = -7
 cannot execute
 
const int EArgv0 = -8
 not this command argv0
 
const int ENoOp = -9
 no operation
 
const int EBadVal = -10
 bad value
 
const int NumOfECodes = 10
 number of error codes.
 
const int NoUid = -1
 Special values. More...
 
const int NoIndex = -1
 no index
 
const char *const ArgSymLiteral = "literal"
 Variable argument symbol names. More...
 
const char *const ArgSymWord = "word"
 non-whitespace seq
 
const char *const ArgSymMultiWord = "multiword"
 any sequence
 
const char *const ArgSymIdentifier = "identifier"
 identifier
 
const char *const ArgSymBoolean = "bool"
 boolean (bool)
 
const char *const ArgSymInteger = "int"
 integer (long)
 
const char *const ArgSymFpn = "fpn"
 fpn (double)
 
const char *const ArgSymFile = "file"
 file path
 
const char *const ArgSymRegEx = "re"
 regular expression
 
const std::string emptystring
 "" empty string More...
 
const std::string undefstring
 "undef" string
 
const char *const DataSectNsCore = "core"
 Reserved command line data section namespaces. More...
 
const char *const DataSectNsOS = "os"
 OS data section ns.
 
const char *const DataSectNsNet = "net"
 network data section ns
 
static const char * RlTabEnd = ""
 no more matches value (empty string)
 
static const string noliteral
 no literal string
 
static NameValuePair ArgTypeLookupTbl []
 Argument type - string symbol lookup table. More...
 
static NameValuePair ArgFlagLookupTbl []
 Argument flag modifiers - name lookup table. More...
 
static CmdFormDef noformdef
 constant "no form def" form definition
 
static CmdArgDef noargdef
 constant "no arg def" argument definition
 
static CmdDef nocmddef
 "no cmd def" command definition
 
static const string noprompt
 "no prompt" prompt value
 

Detailed Description

Commands.

Typedef Documentation

typedef int(* rnr::cmd::CmdExec1Func) (const str::StringVec &argv)

Command execution function type, variant 1.

With this variant, a vector of command line strings argument are provided to the function.

The arguments have been validated against the associated extended syntax.

This function type is provided as a convenience for application development. It is external to the core CommandLine functionality.

Parameters
[in]argvVector of string arguments produced from a successful return from the relevant readCommand() call. The argv[0] argument is the command name.
Returns
User defined return code.

Definition at line 119 of file CommandLine.h.

typedef int(* rnr::cmd::CmdExec2Func) (const CmdExtArgVec &argv)

Command execution function type, variant 2.

With this variant, a vector of command line extended arguments are provided to the function. Each extended argument provide matched command context. Moreover, each argument has been converted to its basic type.

The arguments have been validated against the associated extended syntax.

This function type is provided as a convenience for application development. It is external to the core CommandLine functionality.

Parameters
[in]argvVector of extended arguments produced from a successful return from the relevant readCommand() call. The argv[0] argument is the command name.
Returns
User defined return code.

Definition at line 139 of file CommandLine.h.

typedef int(* rnr::cmd::CmdExec3Func) (CommandLine &cli, const CmdExtArgVec &argv)

Command execution function type, variant 3.

This is identical to variant 2, but with the additional parameter referencing the common-line interface specification.

Parameters
[in]cliCommand-line interface.
[in]argvVector of extended arguments produced from a successful return from the relevant readCommand() call. The argv[0] argument is the command name.
Returns
User defined return code.

Definition at line 154 of file CommandLine.h.

Function Documentation

bool rnr::cmd::isIdentifier ( const std::string &  str)

Test if string is a valid identifier.

Identifiers adhere to the C syntax.

Parameters
[in]strString to test.
Returns
Returns true or false.

Referenced by rnr::cmd::DataSectCore::dealloc(), rnr::cmd::CmdArgDef::match(), and rnr::cmd::CommandLine::tokIdentifier().

static bool rnr::cmd::isspecial ( int  c)
inlinestatic

Command usage syntax special characters.

Parameters
cCharacter to test.
Returns
Returns true if c is special, false otherwise.

Definition at line 190 of file CommandLine.cxx.

Referenced by rnr::cmd::CommandLine::lexSyntaxWord(), and rnr::cmd::CommandLine::tokenizeSyntax().

191  {
192  return( (c == '<') || (c == ':') || (c == '>') ||
193  (c == '{') || (c == '|') || (c == '}') ||
194  (c == '[') || (c == ']') ||
195  (c == '(') || (c == ')') );
196  }
static char rnr::cmd::tohex ( int  c)
static

Convert ascii character to binary character value.

Parameters
cASCII character.
Returns
Binary character.

Definition at line 237 of file CommandLine.cxx.

Referenced by rnr::cmd::CommandLine::lexQuotedString().

238  {
239  if( (c >= '0') && (c <= '9') )
240  {
241  return (char)(c - '0');
242  }
243  else if( (c >= 'a') && (c <= 'f') )
244  {
245  return (char)(c - 'a');
246  }
247  else if( (c >= 'A') && (c <= 'F') )
248  {
249  return (char)(c - 'A');
250  }
251  else
252  {
253  return (char)0;
254  }
255  }

Variable Documentation

NameValuePair rnr::cmd::ArgFlagLookupTbl[]
static
Initial value:
=
{
{"FlagCommand", CmdArgDef::FlagCommand},
{"FlagOptional", CmdArgDef::FlagOptional},
{"FlagXorList", CmdArgDef::FlagXorList},
{NULL, 0}
}

Argument flag modifiers - name lookup table.

Definition at line 117 of file CmdArgDef.cxx.

Referenced by rnr::cmd::CmdArgDef::lookupFlagNames().

const char* const rnr::cmd::ArgSymLiteral = "literal"

Variable argument symbol names.

literal constant

Definition at line 122 of file CmdCore.h.

NameValuePair rnr::cmd::ArgTypeLookupTbl[]
static
Initial value:
=
{
{ArgSymLiteral, CmdArgDef::ArgTypeLiteral},
{ArgSymWord, CmdArgDef::ArgTypeWord},
{ArgSymMultiWord, CmdArgDef::ArgTypeMultiWord},
{ArgSymIdentifier, CmdArgDef::ArgTypeIdentifier},
{ArgSymBoolean, CmdArgDef::ArgTypeBoolean},
{ArgSymInteger, CmdArgDef::ArgTypeInteger},
{ArgSymFpn, CmdArgDef::ArgTypeFpn},
{ArgSymFile, CmdArgDef::ArgTypeFile},
{ArgSymRegEx, CmdArgDef::ArgTypeRegEx},
{NULL, CmdArgDef::ArgTypeUndef}
}
const char *const ArgSymFpn
fpn (double)
Definition: CmdCore.h:128
const char *const ArgSymLiteral
Variable argument symbol names.
Definition: CmdCore.h:122
const char *const ArgSymFile
file path
Definition: CmdCore.h:129
const char *const ArgSymMultiWord
any sequence
Definition: CmdCore.h:124
const char *const ArgSymIdentifier
identifier
Definition: CmdCore.h:125
const char *const ArgSymRegEx
regular expression
Definition: CmdCore.h:130
const char *const ArgSymWord
non-whitespace seq
Definition: CmdCore.h:123
const char *const ArgSymBoolean
boolean (bool)
Definition: CmdCore.h:126
const char *const ArgSymInteger
integer (long)
Definition: CmdCore.h:127

Argument type - string symbol lookup table.

Definition at line 100 of file CmdArgDef.cxx.

Referenced by rnr::cmd::CmdArgDef::lookupArgSymbol(), and rnr::cmd::CmdArgDef::lookupArgType().

const char* const rnr::cmd::DataSectNsCore = "core"
const string rnr::cmd::emptystring

"" empty string

empty string

Definition at line 82 of file CmdCore.cxx.

Referenced by rnr::cmd::CommandLine::rlGeneratorWrapper().