Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/home/pauldt/projects/IDEA/IDEA-ALL/IDEA-DEV/Core/Utilities/Includes/CommandLineParser.hh

Go to the documentation of this file.
00001 // -*- Mode: C++ -*-
00002 //      CVS: $Id: CommandLineParser.hh,v 1.2 2005/11/08 18:32:46 rijsman Exp $
00003 //      Tag: $name$
00004 //     Info: $CVSROOT/COPYRIGHT
00005 
00006 #ifndef COMMANDLINE_IMPLEMENTATION_HEADER_
00007 #define COMMANDLINE_IMPLEMENTATION_HEADER_
00008 
00009 #include "Trace.hh"
00010 #include "Utilities.hh"
00011 
00012 #include "ace/Get_Opt.h"
00013 
00014 namespace IDEA
00015 {
00024   class CommandLineParser
00025   {
00026   public:
00030     virtual ~CommandLineParser();
00034     void usage( std::ostream& os ) const;
00039     bool verify();
00040   protected:
00044     CommandLineParser();
00049     bool getOption( int shortOptionChar, std::string& value ) const;
00054     bool getOptions( int shortOptionChar, StringList& value ) const;
00066     bool registerOption( int shortOptionChar, 
00067                          bool hasArgument, 
00068                          bool mandatory,
00069                          const std::string& usage, 
00070                          const StringList& possibleArguments = StringList() );
00071   private:
00077     class Option
00078     {
00079     public:
00080       Option( int shortOptionChar, 
00081               bool hasArgument, 
00082               bool mandatory,
00083               const std::string& usage, 
00084               const StringList& possibleArguments = StringList() ):
00085         m_ShortOption( shortOptionChar ),
00086         m_HasArgument( hasArgument ),
00087         m_Mandatory( mandatory ),
00088         m_Usage( usage ),
00089         m_Arguments( possibleArguments )
00090       {
00091       }
00092       
00093     
00094       int getShortOption() const { return m_ShortOption; }
00095       bool hasArgument() const { return m_HasArgument; }
00096       bool isMandatory() const { return m_Mandatory; }
00097       const std::string& getUsage() const { return m_Usage; }
00098       const StringList& getArguments() const { return m_Arguments; }
00099     private:
00100       int m_ShortOption;
00101       bool m_HasArgument;
00102       bool m_Mandatory;
00103       std::string m_Usage;
00104       StringList m_Arguments;
00105     };
00106 
00107     friend std::ostream& operator<<( std::ostream& os, const CommandLineParser::Option& option );
00108 
00109     typedef std::map< int, Option > OptionList;
00110 
00111     OptionList m_Options;
00112 
00113     ACE_Get_Opt m_GetOptions;
00114   };
00115 
00116   std::ostream& operator<<( std::ostream& os, const CommandLineParser::Option& option );
00117 }
00118 
00119 #endif // COMMANDLINE_IMPLEMENTATION_HEADER_

Contact information
© IDEA
Generated on Fri Feb 3 17:09:41 2006 for IDEA.