class CmdLine

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

Inheritance:


Public Methods

[more] CmdLine()
[more]int read(int argc_, char** argv_)
Read the command-line.
[more]void help()
Print the help.
[more]void addBCmdOption(const char* name, bool* ptr, bool init_value, const char* help="", bool save_it=false)
[more]void addRCmdOption(const char* name, real* ptr, real init_value, const char* help="", bool save_it=false)
[more]void addSCmdOption(const char* name, char** ptr, const char* init_value, const char* help="", bool save_it=false)
[more]void addBCmdArg(const char* name, bool* ptr, const char* help="", bool save_it=false)
[more]void addRCmdArg(const char* name, real* ptr, const char* help="", bool save_it=false)
[more]void addSCmdArg(const char* name, char** ptr, const char* help="", bool save_it=false)
[more]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)
Add a master switch.
[more]void setWorkingDirectory(const char* dirname)
Set the working directory.
[more]char* getPath(const char* filename)
Get a full path.
[more]DiskXFile* getXFile(const char* filename)
Get a DiskXFile.
[more]virtual void loadXFile(XFile* file)
Load the object from a file pointer (not the options)
[more]virtual void saveXFile(XFile* file)
Save the object to a file pointer (not the options)
[more]void addCmdOption(CmdOption* option)
Add an option to the command line.
[more]void writeLog(XFile* file, bool write_associated_files)
Write a log in file.

Public Members

[more] Functions for adding options.
[more] Functions for adding an argument.


Inherited from Object:

Public Fields

oAllocator* allocator

Public Methods

ovoid addOption(const char* name, int size, void* ptr, const char* help="")
ovoid addIOption(const char* name, int* ptr, int init_value, const char* help="")
ovoid addROption(const char* name, real* ptr, real init_value, const char* help="")
ovoid addBOption(const char* name, bool* ptr, bool init_value, const char* help="")
ovoid addOOption(const char* name, Object** ptr, Object* init_value, const char* help="")
ovoid setOption(const char* name, void* ptr)
ovoid setIOption(const char* name, int option)
ovoid setROption(const char* name, real option)
ovoid setBOption(const char* name, bool option)
ovoid setOOption(const char* name, Object* option)
ovoid load(const char* filename)
ovoid save(const char* filename)
ovoid* operator new(size_t size, Allocator* allocator_=NULL)
ovoid* operator new(size_t size, Allocator* allocator_, void* ptr_)
ovoid operator delete(void* ptr)


Documentation

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:

Options:
"write log" bool Should I output the cmd.log file ? [true]

o CmdLine()

oint 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.

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

o Functions for adding options.
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).

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

ovoid addBCmdOption(const char* name, bool* ptr, bool init_value, const char* help="", bool save_it=false)

ovoid addRCmdOption(const char* name, real* ptr, real init_value, const char* help="", bool save_it=false)

ovoid addSCmdOption(const char* name, char** ptr, const char* init_value, const char* help="", bool save_it=false)

o Functions for adding an argument.
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.

ovoid addBCmdArg(const char* name, bool* ptr, const char* help="", bool save_it=false)

ovoid addRCmdArg(const char* name, real* ptr, const char* help="", bool save_it=false)

ovoid addSCmdArg(const char* name, char** ptr, const char* help="", bool save_it=false)

ovoid addText(const char* text)
Add a text line in the help message

ovoid info(const char* text)
Add a text at the beginnig of the help

ovoid 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.

ovoid setWorkingDirectory(const char* dirname)
Set the working directory. Use it with getPath() and getXFile().

ochar* getPath(const char* filename)
Get a full path. It adds the working_directory before the filename. This path will be deleted by CmdLine.

oDiskXFile* 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.

ovirtual void loadXFile(XFile* file)
Load the object from a file pointer (not the options)

ovirtual void saveXFile(XFile* file)
Save the object to a file pointer (not the options)

ovoid addCmdOption(CmdOption* option)
Add an option to the command line. Use this method if the wrappers that are provided are not sufficient.

ovoid writeLog(XFile* file, bool write_associated_files)
Write a log in file. If desired, the associated files can be printed.


This class has no child classes.
Author:
Ronan Collobert (collober@idiap.ch)
See Also:
CmdOption

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.