0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hypertable::InteractiveCommand Class Referenceabstract

Abstract base class for simple interactive shell commands. More...

#include <InteractiveCommand.h>

Collaboration diagram for Hypertable::InteractiveCommand:
Collaboration graph
[legend]

Public Member Functions

virtual ~InteractiveCommand ()
 Virtual destructor can be overwritten in subclasses. More...
 
void parse_command_line (const char *line)
 Parses a command line and stores the arguments in m_args. More...
 
bool matches (const char *line)
 Returns true if the command_text() matches the command line. More...
 
virtual const char * command_text ()=0
 Returns the command text (i.e. More...
 
virtual const char ** usage ()=0
 Returns the usage string. More...
 
virtual void run ()=0
 Runs the command; can access the command line arguments in m_args. More...
 
void clear_args ()
 Clears all arguments. More...
 
void push_arg (std::string key, std::string value)
 Append another key/value pair to the argument list. More...
 

Protected Member Functions

bool parse_string_literal (const char *str, std::string &text, const char **endptr)
 Helper function to parse a string literal. More...
 

Protected Attributes

std::vector< std::pair
< std::string, std::string > > 
m_args
 The vector with key/value pairs for this command. More...
 

Detailed Description

Abstract base class for simple interactive shell commands.

The base class parses the command and runs it. For a usage example see the FsBroker client shell: src/cc/Tools/fsclient/fsclient.cc.

Definition at line 45 of file InteractiveCommand.h.

Constructor & Destructor Documentation

virtual Hypertable::InteractiveCommand::~InteractiveCommand ( )
inlinevirtual

Virtual destructor can be overwritten in subclasses.

Definition at line 48 of file InteractiveCommand.h.

Member Function Documentation

void Hypertable::InteractiveCommand::clear_args ( )
inline

Clears all arguments.

Definition at line 79 of file InteractiveCommand.h.

virtual const char* Hypertable::InteractiveCommand::command_text ( )
pure virtual

Returns the command text (i.e.

"length")

Abstract function; needs to be overwritten in a subclass!

bool Hypertable::InteractiveCommand::matches ( const char *  line)
inline

Returns true if the command_text() matches the command line.

Definition at line 59 of file InteractiveCommand.h.

void InteractiveCommand::parse_command_line ( const char *  line)

Parses a command line and stores the arguments in m_args.

This function will exit() if the command line cannot be parsed.

Parameters
lineA command line; can contain quoted strings

Definition at line 40 of file InteractiveCommand.cc.

bool InteractiveCommand::parse_string_literal ( const char *  str,
std::string &  text,
const char **  endptr 
)
protected

Helper function to parse a string literal.

Definition at line 96 of file InteractiveCommand.cc.

void Hypertable::InteractiveCommand::push_arg ( std::string  key,
std::string  value 
)
inline

Append another key/value pair to the argument list.

Definition at line 82 of file InteractiveCommand.h.

virtual void Hypertable::InteractiveCommand::run ( )
pure virtual

Runs the command; can access the command line arguments in m_args.

virtual const char** Hypertable::InteractiveCommand::usage ( )
pure virtual

Returns the usage string.

Abstract function; needs to be overwritten in a subclass!

Member Data Documentation

std::vector< std::pair<std::string, std::string> > Hypertable::InteractiveCommand::m_args
protected

The vector with key/value pairs for this command.

Definition at line 88 of file InteractiveCommand.h.


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