Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

HeyParser Class Reference

List of all members.

Detailed Description

A parser for command-line arguments given in the pseudo-English "hey" form.

The syntax for the arguments looks like this:

Where:

For example, to create a 'string' object named 'bar' with a value of 'Hello, World!' in the 'foo' server, you might do:

   $ hey foo create string with name bar value 'Hello, World!'

Then, you can manipulate the server and object with the following commands:

   $ hey foo list
   string
   strings
   $ hey foo list strings
   bar
   $ hey foo get value of string bar
   Hello, World!
   $ hey foo delete string bar
   ok
   $ hey foo list strings
   $

See also:
HeyParserException

HeyPropertyInfo

cbhey.cc

hey_bad.cc

hey_good.cc

Definition at line 145 of file HeyParser.hh.

Public Types

enum  hp_what_t {
  SHUTDOWN, LIST_PROPERTIES, GET_PROPERTY, SET_PROPERTY,
  CREATE_PROPERTY, DELETE_PROPERTY, EXECUTE_PROPERTY, GET_SUITES,
  WHAT_MAX
}

Public Member Functions

 HeyParser (int argc, const char *argv[]) throw (HeyParserException)
 Construct a parser that interprets the given command-line arguments.

virtual ~HeyParser (void)
 Deconstruct a parser object.

int getArgCount (void) const
const char ** getArgValues (void) const
const char * who (void) const
hp_what_t what (void) const
void popProperty (const char *&name_out, const char *&value_out) throw (HeyParserException)
 Pop a pair from the property stack.

const char * to (void) const
void with (const char **&with_out, size_t &count_out) const
 Get the argument array containing the 'with' name/value pairs.

const char * withValue (const char *name, unsigned int instance=0, const char *default_value=NULL) const throw (HeyParserException)
 Get the value for a particular 'with' argument.


Static Public Attributes

const char * hp_what_strings [WHAT_MAX]
 String versions of the hp_what_t enumeration values.


Private Member Functions

const char * consumeArg (void) throw (HeyParserException)
 Consume an argument from the argument list.

void nextProperty (const char *&name_out, const char *&value_out) throw (HeyParserException)
 Find the next name/value pair in the argument list.


Private Attributes

int hp_ArgCount
 The arguments count.

const char ** hp_ArgValue
 The argument values.

hp_what_t hp_What
 The "what" value.

const char * hp_ToValue
 The 'to' value for a SET_PROPERTY request.

int hp_ArgIndex
 The current index in the argument list during processing.

stack< struct Pairhp_PropertyStack
 The stack of property pairs.


Member Enumeration Documentation

enum HeyParser::hp_what_t
 

Enumeration values:
LIST_PROPERTIES  List the properties of an object.
GET_PROPERTY  Get a property from an object.
SET_PROPERTY  Set a property in an object.
CREATE_PROPERTY  Create a property in an object.
DELETE_PROPERTY  Delete a property in an object.
EXECUTE_PROPERTY  Execute a property in an object.
GET_SUITES  Get the description of a property.

Definition at line 154 of file HeyParser.hh.

Referenced by what().


Constructor & Destructor Documentation

HeyParser::HeyParser int  argc,
const char *  argv[]
throw (HeyParserException)
 

Construct a parser that interprets the given command-line arguments.

Most of the parsing will be done here so there are fewer surprises along the way. Note that the object expects all of the arguments, including the command name.

Parameters:
argc The argument count.
argv The argument values.
Exceptions:
HeyParserException if there is a problem with the argument list.

Definition at line 38 of file HeyParser.cc.

References ensure, HeyParser::Pair::p_Name, HeyParser::Pair::p_Value, and require.


Member Function Documentation

const char * HeyParser::consumeArg void   )  throw (HeyParserException) [private]
 

Consume an argument from the argument list.

This method is for internal use when initially processing the argument list.

Side Effects:
hp_ArgIndex is incremented by one if there was an argument available.
Returns:
The next string in the argument list.
Exceptions:
HeyParserException if there are no more arguments to be consumed.

Definition at line 182 of file HeyParser.cc.

int HeyParser::getArgCount void   )  const [inline]
 

Returns:
The argument count.

Definition at line 196 of file HeyParser.hh.

References hp_ArgCount.

Referenced by afFactoryLibraryHey().

const char** HeyParser::getArgValues void   )  const [inline]
 

Returns:
The argument values.

Definition at line 204 of file HeyParser.hh.

References hp_ArgValue.

Referenced by afFactoryLibraryHey().

void HeyParser::nextProperty const char *&  name_out,
const char *&  value_out
throw (HeyParserException) [private]
 

Find the next name/value pair in the argument list.

This method differs from popProperty() in that it translates from the argument list to hp_PropertyStack. Whereas popProperty() interacts only with hp_PropertyStack.

Side Effects:
The top element of hp_PropertyStack is popped off.
Parameters:
name_out The reference where the property name should be stored.
value_out The reference where the property value should be stored.
Exceptions:
HeyParserException if there are insufficient arguments.

Definition at line 198 of file HeyParser.cc.

void HeyParser::popProperty const char *&  name_out,
const char *&  value_out
throw (HeyParserException)
 

Pop a pair from the property stack.

Parameters:
name_out The reference where the property name should be stored.
value_out The reference where the property value should be stored.
Exceptions:
HeyParserException if there are no more values on the stack.

Definition at line 245 of file HeyParser.cc.

References HeyParser::Pair::p_Name, and HeyParser::Pair::p_Value.

Referenced by afAllupHey(), bfHey(), bfManagerHey(), bfRealTimeTaskHey(), dfDelegateHey(), dfHey(), pfHey(), pfStrictPolicyHey(), qfKernelHey(), qfValueSCHey(), and tfHey().

const char* HeyParser::to void   )  const [inline]
 

Returns:
The value that a property should be set to.

Definition at line 240 of file HeyParser.hh.

References hp_ToValue.

Referenced by bfManagerHey(), bfRealTimeTaskHey(), dfDelegateHey(), pfStrictPolicyHey(), and qfValueSCHey().

hp_what_t HeyParser::what void   )  const [inline]
 

Returns:
The action requested by the user (i.e. what to do).

Definition at line 220 of file HeyParser.hh.

References hp_What, and hp_what_t.

Referenced by afAllupHey(), bfHey(), bfManagerHey(), bfRealTimeTaskHey(), dfDelegateHey(), dfHey(), pfHey(), pfStrictPolicyHey(), qfKernelHey(), qfValueSCHey(), and tfHey().

const char* HeyParser::who void   )  const [inline]
 

Returns:
The argument that specifies which server to talk to.

Definition at line 212 of file HeyParser.hh.

References hp_ArgValue.

Referenced by afAllupHey(), afFactoryLibraryHey(), bfManagerHey(), bfRealTimeTaskHey(), dfDelegateHey(), pfStrictPolicyHey(), qfKernelHey(), and qfValueSCHey().

void HeyParser::with const char **&  with_out,
size_t &  count_out
const
 

Get the argument array containing the 'with' name/value pairs.

Parameters:
with_out The reference where the 'with' array should be stored. The elements of the array are ordered as they were on the command line.
count_out The size of the 'with_out' array.

Definition at line 264 of file HeyParser.cc.

References hp_ArgCount, hp_ArgIndex, and hp_ArgValue.

Referenced by bfManagerHey(), and bfRealTimeTaskHey().

const char * HeyParser::withValue const char *  name,
unsigned int  instance = 0,
const char *  default_value = NULL
const throw (HeyParserException)
 

Get the value for a particular 'with' argument.

Parameters:
name The name of the 'with' argument to retrieve.
instance The instance of the argument to retrieve.
default_value The default value to return if the 'with' argument could not be found.
Returns:
The value coupled with the given instance of 'name', or default_value if the instance could not be found.
Exceptions:
HeyParserException if the particular instance of the 'with' argument was not found.

Definition at line 270 of file HeyParser.cc.

References require.

Referenced by afAllupHey(), bfHey(), bfManagerHey(), bfRealTimeTaskHey(), dfDelegateHey(), pfHey(), and qfKernelHey().


Member Data Documentation

hp_what_t HeyParser::hp_What [private]
 

The "what" value.

This will only be set by the constructor when it is initially parsing the arguments.

Definition at line 352 of file HeyParser.hh.

Referenced by what().

const char * HeyParser::hp_what_strings [static]
 

Initial value:

 {
    "shutdown",
    "list",
    "get",
    "set",
    "create",
    "delete",
    "execute",
    "getsuites",
}
String versions of the hp_what_t enumeration values.

Definition at line 27 of file HeyParser.cc.


The documentation for this class was generated from the following files:
Generated on Mon Dec 1 16:30:34 2003 for CPU Broker by doxygen 1.3.4