CCAFFEINE
0.8.8
|
#include <CmdParse.h>
Public Member Functions | |
CDELETE | CmdParse (CmdContext *icc) |
void | addAction (CmdAction *c) |
CmdAction * | getAction (char *s) |
CmdContext * | getContext () |
int | addClassArg (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | addInstanceArg (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | addLine (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | addStringArg (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | addDoubleArg (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | addFloatArg (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | addIntegerArg (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | addLongArg (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | addBooleanArg (JCPN(StringTokenizer)*st, JCPN(Vector)*args, JCPN(StringBuffer)*cb) |
int | parse () |
void | setContextVerbose (bool noisyHelp) |
Private Member Functions | |
JCPN (Vector)*alist | |
void | clearArgs (JCPN(Vector)*args) |
Private Attributes | |
CmdContext * | cc |
Simple line parser skeleton and services. The main use is to create a particular parser piecewise by adding CmdActions to it. Stateful parsers are supported by specializing the CmdContext object. The Context is passed into each CmdAction.
CDELETE CmdParse::CmdParse | ( | CmdContext * | icc | ) |
Actions in the constructed parser will be called with icc as their context.
CmdParse::JCPN | ( | Vector | ) | [private] |
CmdActions added to this parser.
void CmdParse::clearArgs | ( | JCPN(Vector)* | args | ) | [private] |
Remove strings from an internally used structure.
void CmdParse::addAction | ( | CmdAction * | c | ) |
Adds a command to the parser. Presently does not check the sanity of the command. This function needs to do some insertion with checking for duplicates if we're paranoid. As it is, this comes out in the wash at getAction. Duplication will make commands useless.
CmdAction* CmdParse::getAction | ( | char * | s | ) |
Returns the nearest match (by leading characters) of commands stored in the list.
Returns the context given in the constructor, so the application destroying the parser can choose to destroy or reuse the context. If you destroy the context, destroy the parser, too.
int CmdParse::addClassArg | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Converts the next token to a class (per app. definition) and adds to arg list.
int CmdParse::addInstanceArg | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Converts the next token to an instance (per app. definition) and adds to arg list.
int CmdParse::addLine | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Converts the remaining tokens to a string and adds to arg list.
int CmdParse::addStringArg | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Adds the next token as a string to the arg list
int CmdParse::addDoubleArg | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Adds the next token as a DoubleJC
int CmdParse::addFloatArg | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Adds the next token as a FloatJC
int CmdParse::addIntegerArg | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Adds the next token as a IntegerJC
int CmdParse::addLongArg | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Adds the next token as a LongJC (long long)
int CmdParse::addBooleanArg | ( | JCPN(StringTokenizer)* | st, |
JCPN(Vector)* | args, | ||
JCPN(StringBuffer)* | cb | ||
) |
Adds the next token as a BooleanJC (int)
int CmdParse::parse | ( | ) |
Main command-line processing loop. Returns 0 if the parser instance is willing to yield, and -1 if the parser instance thinks something fatal happened.
void CmdParse::setContextVerbose | ( | bool | noisyHelp | ) |
adjust the verbosity of the CmdContext inside.
CmdContext* CmdParse::cc [private] |
this parser instance's data, functions, io and others