BASIS  version 1.2.3 (revision 2104)
CmdLineInterface.h
00001 
00002 /****************************************************************************** 
00003  * 
00004  *  file:  CmdLineInterface.h
00005  * 
00006  *  Copyright (c) 2003, Michael E. Smoot .
00007  *  Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
00008  *  All rights reverved.
00009  *
00010  *  See the file COPYING in the top directory of this distribution for
00011  *  more information.
00012  *  
00013  *  THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 
00014  *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
00015  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
00016  *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
00017  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
00018  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00019  *  DEALINGS IN THE SOFTWARE.  
00020  *  
00021  *****************************************************************************/ 
00022 
00023 #ifndef TCLAP_COMMANDLINE_INTERFACE_H
00024 #define TCLAP_COMMANDLINE_INTERFACE_H
00025 
00026 #include <string>
00027 #include <vector>
00028 #include <list>
00029 #include <iostream>
00030 #include <algorithm>
00031 
00032 
00033 namespace TCLAP {
00034      
00035 class Arg;
00036 class CmdLineOutput;
00037 class XorHandler;
00038 
00039 /**
00040  * The base class that manages the command line definition and passes
00041  * along the parsing to the appropriate Arg classes.
00042  */
00043 class CmdLineInterface
00044 {
00045     public:
00046 
00047         /**
00048          * Destructor
00049          */
00050         virtual ~CmdLineInterface() {}
00051 
00052         /**
00053          * Adds an argument to the list of arguments to be parsed.
00054          * \param a - Argument to be added. 
00055          */
00056         virtual void add( Arg& a )=0;
00057 
00058         /**
00059          * An alternative add.  Functionally identical.
00060          * \param a - Argument to be added. 
00061          */
00062         virtual void add( Arg* a )=0;
00063 
00064         /**
00065          * Add two Args that will be xor'd.  
00066          * If this method is used, add does
00067          * not need to be called.
00068          * \param a - Argument to be added and xor'd. 
00069          * \param b - Argument to be added and xor'd. 
00070          */
00071         virtual void xorAdd( Arg& a, Arg& b )=0;
00072 
00073         /**
00074          * Add a list of Args that will be xor'd.  If this method is used, 
00075          * add does not need to be called.
00076          * \param xors - List of Args to be added and xor'd. 
00077          */
00078         virtual void xorAdd( std::vector<Arg*>& xors )=0;
00079 
00080         /**
00081          * Parses the command line.
00082          * \param argc - Number of arguments.
00083          * \param argv - Array of arguments.
00084          */
00085         virtual void parse(int argc, const char * const * argv)=0;
00086 
00087         /**
00088          * Parses the command line.
00089          * \param args - A vector of strings representing the args. 
00090          * args[0] is still the program name.
00091          */
00092         void parse(std::vector<std::string>& args);
00093 
00094         /**
00095          * Returns the CmdLineOutput object.
00096          */
00097         virtual CmdLineOutput* getOutput()=0;
00098 
00099         /**
00100          * \param co - CmdLineOutput object that we want to use instead. 
00101          */
00102         virtual void setOutput(CmdLineOutput* co)=0;
00103 
00104         /**
00105          * Returns the version string.
00106          */
00107         virtual std::string& getVersion()=0;
00108 
00109         /**
00110          * Returns the program name string.
00111          */
00112         virtual std::string& getProgramName()=0;
00113 
00114         /**
00115          * Returns the argList. 
00116          */
00117         virtual std::list<Arg*>& getArgList()=0;
00118 
00119         /**
00120          * Returns the XorHandler. 
00121          */
00122         virtual XorHandler& getXorHandler()=0;
00123 
00124         /**
00125          * Returns the delimiter string.
00126          */
00127         virtual char getDelimiter()=0;
00128 
00129         /**
00130          * Returns the message string.
00131          */
00132         virtual std::string& getMessage()=0;
00133 
00134         /**
00135          * Indicates whether or not the help and version switches were created
00136          * automatically.
00137          */
00138         virtual bool hasHelpAndVersion()=0;
00139 
00140         /** 
00141          * Resets the instance as if it had just been constructed so that the
00142          * instance can be reused. 
00143          */
00144         virtual void reset()=0;
00145 };
00146 
00147 } //namespace
00148 
00149 
00150 #endif