Cross-Platform C++

ot::auxil
class CommandLineParser

#include "ot/auxil/CommandLineParser.h"




Constructor/Destructor Summary
CommandLineParser()
         Constructs a CommandLineParser.

Method Summary
 void addOption(CommandLineOption* pOption)
        
 StringList getFilenames(int argc, char* argv, int firstArg, int lastArg)
        
 unsigned getFirstPositionalArg() const
        
protected  CommandLineOption& getLongOption(const String& option) const
        
 const String& getProgramName() const
        
protected  CommandLineOption& getShortOption(char option) const
         Locates a CommandLineOption that answers to the short option passed.
 unsigned parse(int argc, char* argv)
         Parses the passed command line parameters, extracting any option names and associated arguments.

Typedefs

StringList

typedef std::list< String > StringList

Constructor/Destructor Detail

CommandLineParser

 CommandLineParser()
Constructs a CommandLineParser.


Method Detail

addOption

void addOption(CommandLineOption* pOption)


getFilenames

StringList getFilenames(int argc,
                        char* argv,
                        int firstArg,
                        int lastArg)


getFirstPositionalArg

unsigned getFirstPositionalArg() const


getLongOption

protected CommandLineOptiongetLongOption(const String& option) const


getProgramName

const StringgetProgramName() const


getShortOption

protected CommandLineOptiongetShortOption(char option) const
Locates a CommandLineOption that answers to the short option passed.

Returns:
The requested CommandLineOption object
Exceptions:
CommandLineException - if the option is unrecognized or ambiguous

parse

unsigned parse(int argc,
               char* argv)
Parses the passed command line parameters, extracting any option names and associated arguments. Parsing is conducted according to POSIX rules. Short option names (defined as a single character) are recognized when prefixed by the short option prefix '-' ('/' is also recognized on Windows platforms).

Parsing stops as soon as a non-option argument is found.

Returns:
the index of the first non-option argument
Exceptions:
CommandLineException - if invalid options have been specified on the command line


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements