Points&Forces (core)
Software tools facilitating the task of surveying architecture
|
Implementation of the SimpleOpt class. More...
#include <SimpleOpt.h>
Classes | |
struct | SOption |
Structure used to define all known options. More... | |
Public Member Functions | |
CSimpleOptTempl () | |
Initialize the class. Init() must be called later. More... | |
CSimpleOptTempl (int argc, SOCHAR *argv[], const SOption *a_rgOptions, int a_nFlags=0) | |
Initialize the class in preparation for use. More... | |
~CSimpleOptTempl () | |
Deallocate any allocated memory. More... | |
bool | Init (int a_argc, SOCHAR *a_argv[], const SOption *a_rgOptions, int a_nFlags=0) |
Initialize the class in preparation for calling Next. More... | |
void | SetOptions (const SOption *a_rgOptions) |
Change the current options table during option parsing. More... | |
void | SetFlags (int a_nFlags) |
Change the current flags during option parsing. More... | |
bool | HasFlag (int a_nFlag) const |
Query if a particular flag is set. More... | |
bool | Next () |
Advance to the next option if available. More... | |
void | Stop () |
ESOError | LastError () const |
Return the last error that occurred. More... | |
int | OptionId () const |
Return the nId value from the options array for the current option. More... | |
const SOCHAR * | OptionText () const |
Return the pszArg from the options array for the current option. More... | |
SOCHAR * | OptionArg () const |
Return the argument for the current option where one exists. More... | |
SOCHAR ** | MultiArg (int n) |
Validate and return the desired number of arguments. More... | |
int | FileCount () const |
Returned the number of entries in the Files() array. More... | |
SOCHAR * | File (int n) const |
Return the specified file argument. More... | |
SOCHAR ** | Files () const |
Return the array of files. More... | |
Implementation of the SimpleOpt class.
Definition at line 327 of file SimpleOpt.h.
|
inline |
Initialize the class. Init() must be called later.
Definition at line 345 of file SimpleOpt.h.
|
inline |
Initialize the class in preparation for use.
Definition at line 352 of file SimpleOpt.h.
|
inline |
Deallocate any allocated memory.
Definition at line 365 of file SimpleOpt.h.
|
inline |
Return the specified file argument.
n | Index of the file to return. This must be between 0 and FileCount() - 1; |
Definition at line 495 of file SimpleOpt.h.
|
inline |
Returned the number of entries in the Files() array.
After Next() has returned false, this will be the list of files (or otherwise unprocessed arguments).
Definition at line 488 of file SimpleOpt.h.
|
inline |
Return the array of files.
Definition at line 501 of file SimpleOpt.h.
|
inline |
Query if a particular flag is set.
Definition at line 414 of file SimpleOpt.h.
bool CSimpleOptTempl< SOCHAR >::Init | ( | int | a_argc, |
SOCHAR * | a_argv[], | ||
const SOption * | a_rgOptions, | ||
int | a_nFlags = 0 |
||
) |
Initialize the class in preparation for calling Next.
The table of options pointed to by a_rgOptions does not need to be valid at the time that Init() is called. However on every call to Next() the table pointed to must be a valid options table with the last valid entry set to SO_END_OF_OPTIONS.
NOTE: the array pointed to by a_argv will be modified by this class and must not be used or modified outside of member calls to this class.
a_argc | Argument array size |
a_argv | Argument array |
a_rgOptions | Valid option array |
a_nFlags | Optional flags to modify the processing of the arguments |
Definition at line 552 of file SimpleOpt.h.
|
inline |
Return the last error that occurred.
This function must always be called before processing the current option. This function is available only when Next() has returned true.
Definition at line 446 of file SimpleOpt.h.
SOCHAR ** CSimpleOptTempl< SOCHAR >::MultiArg | ( | int | n | ) |
Validate and return the desired number of arguments.
This is only valid when OptionId() has return the ID of an option that is registered as SO_MULTI. It may be called multiple times each time returning the desired number of arguments. Previously returned argument pointers are remain valid.
If an error occurs during processing, NULL will be returned and the error will be available via LastError().
n | Number of arguments to return. |
Definition at line 1000 of file SimpleOpt.h.
bool CSimpleOptTempl< SOCHAR >::Next |
Advance to the next option if available.
When all options have been processed it will return false. When true has been returned, you must check for an invalid or unrecognized option using the LastError() method. This will be return an error value other than SO_SUCCESS on an error. All standard data (e.g. OptionText(), OptionArg(), OptionId(), etc) will be available depending on the error.
After all options have been processed, the remaining files from the command line can be processed in same order as they were passed to the program.
Definition at line 597 of file SimpleOpt.h.
|
inline |
Return the argument for the current option where one exists.
If there is no argument for the option, this will return NULL. This function is available only when Next() has returned true.
Definition at line 467 of file SimpleOpt.h.
|
inline |
Return the nId value from the options array for the current option.
This function is available only when Next() has returned true.
Definition at line 453 of file SimpleOpt.h.
|
inline |
Return the pszArg from the options array for the current option.
This function is available only when Next() has returned true.
Definition at line 460 of file SimpleOpt.h.
|
inline |
Change the current flags during option parsing.
Note that changing the SO_O_USEALL flag here will have no affect. It must be set using Init() or the constructor.
a_nFlags | Flags to modify the processing of the arguments |
Definition at line 411 of file SimpleOpt.h.
|
inline |
Change the current options table during option parsing.
a_rgOptions | Valid option array |
Definition at line 400 of file SimpleOpt.h.
void CSimpleOptTempl< SOCHAR >::Stop |
Stops processing of the command line and returns all remaining arguments as files. The next call to Next() will return false.
Definition at line 777 of file SimpleOpt.h.