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

Tools::CommandLineArgument Class Reference

Inheritance diagram for Tools::CommandLineArgument:

Inheritance graph
[legend]
Collaboration diagram for Tools::CommandLineArgument:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CommandLineArgument (String *longArg, Character *shortArg, bool mandatory, Callback< void > *callback, Object *userData=nil)
virtual void printGetOptShortOn (Stream *stream)
virtual void performCallback (void)
virtual void performCallbackWith (String *param)
virtual bool acceptsParameter (void)
virtual bool matchShortArgument (int character)
virtual bool isMandatory (void)
virtual bool wasEvaluated (void)
virtual void fillGetOptLongOption (struct option *longopt)

Protected Attributes

Stringlong_argument
Charactershort_argument
bool _mandatory
Callback< void > * _callback
Objectuser_data
bool _evaluated

Constructor & Destructor Documentation

Tools::CommandLineArgument::CommandLineArgument String longArg,
Character shortArg,
bool  mandatory,
Callback< void > *  callback,
Object userData = nil
[inline]
 

Definition at line 55 of file CmdLineParser.cc.

References _callback, _evaluated, _mandatory, long_argument, short_argument, and user_data.

00057     {
00058         long_argument = longArg;
00059         short_argument = shortArg;
00060         _mandatory = mandatory;
00061         _callback = callback;
00062         user_data = userData;
00063         _evaluated = false;
00064     }


Member Function Documentation

virtual bool Tools::CommandLineArgument::acceptsParameter void   )  [inline, virtual]
 

Definition at line 90 of file CmdLineParser.cc.

References _callback, Core::Callback< void >::argumentsNumber(), nil, and user_data.

Referenced by fillGetOptLongOption(), printGetOptShortOn(), and Tools::CommandLineParser::process().

00091     {
00092         return _callback->argumentsNumber() > 0 && user_data == nil;
00093     }

virtual void Tools::CommandLineArgument::fillGetOptLongOption struct option *  longopt  )  [inline, virtual]
 

Definition at line 111 of file CmdLineParser.cc.

References acceptsParameter(), Core::String::asCString(), Core::Character::asInteger(), long_argument, nil, and short_argument.

Referenced by Tools::CommandLineParser::collectLongOptions().

00112     {
00113         longopt->name = long_argument->asCString();
00114         longopt->has_arg = acceptsParameter() ? 1 : 0;
00115         longopt->flag = NULL;
00116         if (short_argument == nil) longopt->val = 0;
00117         else
00118             longopt->val = short_argument->asInteger();
00119     }

virtual bool Tools::CommandLineArgument::isMandatory void   )  [inline, virtual]
 

Definition at line 100 of file CmdLineParser.cc.

References _mandatory.

Referenced by Tools::CommandLineParser::checkMissingArguments().

00101     {
00102         return _mandatory;
00103     }

virtual bool Tools::CommandLineArgument::matchShortArgument int  character  )  [inline, virtual]
 

Definition at line 95 of file CmdLineParser.cc.

References Core::Character::isEqual(), and short_argument.

Referenced by Tools::CommandLineParser::process().

00096     {
00097         return short_argument->isEqual((char) character);
00098     }

virtual void Tools::CommandLineArgument::performCallback void   )  [inline, virtual]
 

Definition at line 77 of file CmdLineParser.cc.

References _callback, _evaluated, Core::Callback< void >::executeWith(), and user_data.

Referenced by Tools::CommandLineParser::process().

00078     {
00079         _callback->executeWith(user_data);
00080         _evaluated = true;
00081     }

virtual void Tools::CommandLineArgument::performCallbackWith String param  )  [inline, virtual]
 

Definition at line 83 of file CmdLineParser.cc.

References _callback, _evaluated, and Core::Callback< void >::executeWith().

Referenced by Tools::CommandLineParser::process().

00084     {
00085         _callback->executeWith(param);
00086         _evaluated = true;
00087     }

virtual void Tools::CommandLineArgument::printGetOptShortOn Stream stream  )  [inline, virtual]
 

Definition at line 67 of file CmdLineParser.cc.

References acceptsParameter(), Core::Stream::nextPut(), nil, and short_argument.

00068     {
00069         if (short_argument == nil) return;
00070 
00071         stream->nextPut(short_argument);
00072         if (acceptsParameter())
00073             stream->nextPut(':');
00074     }

virtual bool Tools::CommandLineArgument::wasEvaluated void   )  [inline, virtual]
 

Definition at line 105 of file CmdLineParser.cc.

References _evaluated.

Referenced by Tools::CommandLineParser::checkMissingArguments().

00106     {
00107         return _evaluated;
00108     }


Member Data Documentation

Callback<void>* Tools::CommandLineArgument::_callback [protected]
 

Definition at line 50 of file CmdLineParser.cc.

Referenced by acceptsParameter(), CommandLineArgument(), performCallback(), and performCallbackWith().

bool Tools::CommandLineArgument::_evaluated [protected]
 

Definition at line 52 of file CmdLineParser.cc.

Referenced by CommandLineArgument(), performCallback(), performCallbackWith(), and wasEvaluated().

bool Tools::CommandLineArgument::_mandatory [protected]
 

Definition at line 49 of file CmdLineParser.cc.

Referenced by CommandLineArgument(), and isMandatory().

String* Tools::CommandLineArgument::long_argument [protected]
 

Definition at line 47 of file CmdLineParser.cc.

Referenced by CommandLineArgument(), and fillGetOptLongOption().

Character* Tools::CommandLineArgument::short_argument [protected]
 

Definition at line 48 of file CmdLineParser.cc.

Referenced by CommandLineArgument(), fillGetOptLongOption(), matchShortArgument(), and printGetOptShortOn().

Object* Tools::CommandLineArgument::user_data [protected]
 

Definition at line 51 of file CmdLineParser.cc.

Referenced by acceptsParameter(), CommandLineArgument(), and performCallback().


The documentation for this class was generated from the following file:
Generated on Mon Nov 27 09:52:40 2006 for Smalltalk like C++ Class Library by  doxygen 1.4.2