Qualia  0.2
Public Member Functions | Public Attributes | List of all members
CmdLine Class Reference

#include <CmdLine.h>

Collaboration diagram for CmdLine:
Collaboration graph
[legend]

Public Member Functions

 CmdLine ()
 
int read (int argc_, char **argv_)
 
void help ()
 
void addICmdOption (const char *name, int *ptr, int init_value, const char *help="", bool save_it=false)
 
void addBCmdOption (const char *name, bool *ptr, bool init_value, const char *help="", bool save_it=false)
 
void addRCmdOption (const char *name, real *ptr, real init_value, const char *help="", bool save_it=false)
 
void addSCmdOption (const char *name, char **ptr, const char *init_value, const char *help="", bool save_it=false)
 
void addICmdArg (const char *name, int *ptr, const char *help="", bool save_it=false)
 
void addBCmdArg (const char *name, bool *ptr, const char *help="", bool save_it=false)
 
void addRCmdArg (const char *name, real *ptr, const char *help="", bool save_it=false)
 
void addSCmdArg (const char *name, char **ptr, const char *help="", bool save_it=false)
 
void addText (const char *text)
 Add a text line in the help message. More...
 
void info (const char *text)
 Add a text at the beginnig of the help. More...
 
void addMasterSwitch (const char *text)
 
void setWorkingDirectory (const char *dirname)
 
char * getPath (const char *filename)
 
DiskXFilegetXFile (const char *filename)
 
virtual void load (DiskXFile *file)
 Load the object from a file pointer ({not the options}) More...
 
virtual void save (DiskXFile *file)
 Save the object to a file pointer ({not the options}) More...
 
void addCmdOption (CmdOption *option)
 
void writeLog (DiskXFile *file, bool write_associated_files)
 
virtual ~CmdLine ()
 

Public Attributes

char * program_name
 
bool write_log
 
int n_master_switches
 
int * n_cmd_options
 
CmdOption *** cmd_options
 
char * text_info
 
char * working_directory
 
char ** associated_files
 
int n_associated_files
 
int master_switch
 
char ** argv
 
int argc
 

Detailed Description

This class provides a useful interface for the user, to easily read some arguments/options from the command-line.

Note that here, we make a difference between: {itemize} { options} which are not required. { arguments} which are required. {itemize}

Options: {tabular}{lcll} "write log" & bool & Should I output the cmd.log file ? & [true] {tabular}

Author
Ronan Collobert (collo.nosp@m.ber@.nosp@m.idiap.nosp@m..ch)
See Also
CmdOption

Constructor & Destructor Documentation

CmdLine::CmdLine ( )
CmdLine::~CmdLine ( )
virtual

Member Function Documentation

void CmdLine::addBCmdArg ( const char *  name,
bool *  ptr,
const char *  help = "",
bool  save_it = false 
)
void CmdLine::addBCmdOption ( const char *  name,
bool *  ptr,
bool  init_value,
const char *  help = "",
bool  save_it = false 
)
void CmdLine::addCmdOption ( CmdOption option)

Add an option to the command line. Use this method if the wrappers that are provided are not sufficient.

void CmdLine::addICmdArg ( const char *  name,
int *  ptr,
const char *  help = "",
bool  save_it = false 
)

Functions for adding an argument. The argument will be setted to #value# in the command-line by writting "#value#" { after} all the options. If there are N arguments, you have to write "#value1# #value2# #value3# ... #valueN#" to set them in the command-line.

void CmdLine::addICmdOption ( const char *  name,
int *  ptr,
int  init_value,
const char *  help = "",
bool  save_it = false 
)

Functions for adding options. The calling order of the following functions will define the text order associated when you will call help()#.

Add an option (Int, Bool, Real, String). {itemize} #name# the name of the option (must be unique). #ptr# is the pointer on the optional variable. #init_value# is the initialization value. help# is the help text for this option. {itemize}

The option will be setted to #value# in the command-line by printing "#name# #value#"

void CmdLine::addMasterSwitch ( const char *  text)

Add a master switch. It creates an another type of command line. If the #text# is the first argument of the user command line, only the options corresponding to this new command line will be considered.

void CmdLine::addRCmdArg ( const char *  name,
real ptr,
const char *  help = "",
bool  save_it = false 
)
void CmdLine::addRCmdOption ( const char *  name,
real ptr,
real  init_value,
const char *  help = "",
bool  save_it = false 
)
void CmdLine::addSCmdArg ( const char *  name,
char **  ptr,
const char *  help = "",
bool  save_it = false 
)
void CmdLine::addSCmdOption ( const char *  name,
char **  ptr,
const char *  init_value,
const char *  help = "",
bool  save_it = false 
)
void CmdLine::addText ( const char *  text)

Add a text line in the help message.

char * CmdLine::getPath ( const char *  filename)

Get a full path. It adds the working_directory# before the #filename#. This path will be deleted by CmdLine.

DiskXFile * CmdLine::getXFile ( const char *  filename)

Get a DiskXFile. It adds the working_directory# before the #filename# and opens the file. This XFile will be deleted by CmdLine.

void CmdLine::help ( )

Print the help. Call this function { after} adding options/arguments that you need, with the help of the following functions.

void CmdLine::info ( const char *  text)

Add a text at the beginnig of the help.

void CmdLine::load ( DiskXFile file)
virtual

Load the object from a file pointer ({not the options})

int CmdLine::read ( int  argc_,
char **  argv_ 
)

Read the command-line. Call this function { after} adding options/arguments that you need, with the help of the following functions.

void CmdLine::save ( DiskXFile file)
virtual

Save the object to a file pointer ({not the options})

void CmdLine::setWorkingDirectory ( const char *  dirname)

Set the working directory. Use it with getPath()# and getXFile()#.

void CmdLine::writeLog ( DiskXFile file,
bool  write_associated_files 
)

Write a log in #file#. If desired, the associated files can be printed.

Member Data Documentation

int CmdLine::argc
char** CmdLine::argv
char** CmdLine::associated_files
CmdOption*** CmdLine::cmd_options
int CmdLine::master_switch
int CmdLine::n_associated_files
int* CmdLine::n_cmd_options
int CmdLine::n_master_switches
char* CmdLine::program_name
char* CmdLine::text_info
char* CmdLine::working_directory
bool CmdLine::write_log

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