User Documentation
RAVL, Recognition And Vision Library
DEVELOP HOME PAGE CLASS LIST CONTENTS
Ravl - Core - Misc - OptionC
 

  PUBLIC
OptionC::OptionC(int,char **,bool,OStreamC)
OptionC::OptionC(int,char **,bool)
OptionC::OptionC(DListC,OStreamC)
OptionC::OfferLoadSave(void)
OptionC::IsOnCommandLine(const char *) const
OptionC::LeftOk(void)
OptionC::Check(bool)
OptionC::Usage(void)
OptionC::Comment(const char *)
OptionC::Comment(const StringC &)
OptionC::Get(const char *,const DataT &,const char *,int)
OptionC::Int(const char *,int,const char *)
OptionC::Index2d(const char *,int,int,const char *)
OptionC::Real(const char *,RealT,const char *)
OptionC::Point2d(const char *,RealT,RealT,const char *)
OptionC::CharArr(const char *,const char *,const char *)
OptionC::String(const char *,const char *,const char *)
OptionC::UnsignedChar(const char *,unsigned char,const char *)
OptionC::Boolean(const char *,bool,const char *)
OptionC::List(const char *,const char *)
OptionC::DependXor(const char *)
OptionC::If(int,const char *,const char *)
OptionC::MultIf(int,const char *,const char *)
OptionC::DependIf(const char *,int,int,const char *)
OptionC::Compulsory(const char *)
OptionC::CompulsoryArgs(int)
OptionC::PrintUsage(void)
OptionC::SaveOptions(StringC)
OptionC::LoadOptions(StringC)

   OptionC   
 
The class OptionC is a simple parser of a command line.
 
include "Ravl/Option.hh"
Created:12/11/1993 
User Level:Basic
Library:RavlCore
Example:exOption.cc
In Scope:RavlN

Comments:
This is a small object.

Variables:
Methods:
OptionC(int argc,char ** argv,bool copy,OStreamC msgout)
Creates the option processing system
'copy' == false ... options and pars. are removed from agrv, argc
'copy' == true ... leave argv, argc untouched, work on a copy

OptionC(int argc,char ** argv,bool copy = false)
Creates the option processing system
'copy' == false ... options and pars. are removed from agrv, argc
'copy' == true ... leave argv, argc untouched, work on a copy

OptionC(DListC<StringC> opts,OStreamC msgout = OStreamC (cerr))
Creates the option processing system.

void OfferLoadSave()
Add optload and optsave to the command line.
This adds the options to both load and save options to the command line. When used this should be called before any other options are processed.

bool IsOnCommandLine(const char * option) const
Returns true if the 'option' was on the command line.

void LeftOk()
Does not consider unprocessed options as an error.

bool Check(bool exitOnFail = true)
Ends command line processing,
if errors are detected their list together with usage/help is printed out.

DListC<StringC> Usage()
Returns complete usage (NULL terminated).

void Comment(const char * commentText)
Puts this line to the usage.

void Comment(const StringC & commentText)
Puts this line to the usage.

DataT Get(const char * name,const DataT & def,const char * comment,int nArgs = 1)
Get option with multipal args

IntT Int(const char * name,int def,const char * comment)
Gets integer.

Index2dC Index2d(const char * name,int def1,int def2,const char * comment)
Gets pair of IndexC types.

RealT Real(const char * name,RealT def,const char * comment)
Gets real value.

Tuple2C<RealT,RealT> Point2d(const char * name,RealT def1,RealT def2,const char * comment)
Gets a pair of real values.

char * CharArr(const char * name,const char * def,const char * comment)
Gets array of chars.
This returns a string allocated with 'new char [xx]' it is the callers responability to free this string after use.

StringC String(const char * name,const char * def,const char * comment)
Gets a string.
N.B.: if "name" is the empty string, the default value is returned

unsigned char UnsignedChar(const char * name,unsigned char def,const char * comment)
Gets a unsigned char.

bool Boolean(const char * name,bool def,const char * comment)
Gets toggle (boolean value).

DListC<StringC> List(const char * name,const char * comment)
Gets a list of strings following the option 'name'.
This function can used only if the header file 'DList.hh' is called before this header file.

Dependency definition functions.


void DependXor(const char * xor_opt)
xor_opt defines a set of mutually exclusive options
options are specified in xor_opt without '-', eg. 'alpha beta x'

void If(int enableCond,const char * depend,const char * comment)
option "depend" can be specified only if a given condition 'enableCond' is met

void MultIf(int enableCond,const char * depend,const char * comment)
options (several of them) in string "depend" can be specified only if a given condition 'enableCond' is met

void DependIf(const char * cond,int enableVal,int val,const char * depend)
option 'depend' can be specified only if option 'cond' has value 'enableVal'. Current value of 'depend' is passed explicitly in val

void Compulsory(const char * name)
Emits error message if 'name' was not found on the command line

void CompulsoryArgs(int num)
Defines the number of compulsory arguments.
It must be used after all options have been called!

void PrintUsage()
Print usage to sout.

bool SaveOptions(StringC filename)
Save options to a file.

bool LoadOptions(StringC filename)
Load options from a file.
This MUST be called before any options are processed for it to have any effect.


Maintainer:Charles Galambos, Radek Marik, George Matas, Created: 12/11/1993, Documentation by CxxDoc: Tue Aug 13 09:59:02 2002