Main Page   Class Hierarchy   Compound List   File List   Compound Members  

GetOptions.h

00001 #ifndef GETOPTIONS_H
00002 #define GETOPTIONS_H
00003 
00004 #include <map>
00005 #include <string>
00006 #include <vector>
00007 
00008 namespace MFUtil
00009 {
00013   class GetOptions
00014   {
00015   public:
00016     
00020     GetOptions( void );
00021 
00026     GetOptions( const std::string& p_command_line );
00027 
00031     inline void setCommandLine( const std::string& p_command ){ m_command_line = p_command; }
00032 
00036     inline void setSeparator( const std::string& p_sep ){ m_separator = p_sep; }
00037 
00041     inline std::string getCommandLine( void ) const { return m_command_line; }
00042 
00046     inline std::string getSeparator( void ) const { return m_separator; }
00047 
00054     void addOption( const std::string& p_option, const bool p_has_argument = false, const bool p_is_optional = true );
00055 
00059     bool hasOption( const std::string& p_option ) const;
00060 
00064     bool parse( void );
00065 
00069     bool hasArgument( const std::string& p_option ) const;
00070 
00076     bool hasArgument( const std::string& p_option, std::vector<std::string>& p_arguments ) const;
00077     
00078   protected:
00079 
00083     class Option
00084     {      
00085     public:
00086       
00087       Option( void ) : m_is_found(false) {}
00088       std::string getOption( void ) const { return m_option; }
00089       void setOption( const std::string& p_option ){ m_option = p_option; }
00090       std::vector< std::string > arguments;
00091       bool getHasArgument( void ) const { return m_has_argument; }
00092       void setHasArgument( bool p_has_arg ){ m_has_argument = p_has_arg; }
00093       bool getIsOptional( void ) const { return m_is_optional; }
00094       void setIsOptional( bool p_is_opt ){ m_is_optional = p_is_opt; }
00095       bool getIsFound( void ) const { return m_is_found; }
00096       void setIsFound( void ) { m_is_found = true; }
00097 
00098     private:
00099       
00100       std::string m_option;
00101       bool m_has_argument;
00102       bool m_is_optional;
00103       bool m_is_found;
00104     };
00105     GetOptions::Option& getOptions( const std::string& p_option );
00106 //    bool hasOption( const std::string& p_option, std::map< std::string, GetOptions::Option >::const_iterator& pi_option ) const;
00107     
00108   private:
00109     
00110     std::map<std::string, Option > m_option_dictionnary;
00111     std::string m_command_line;
00112     std::string m_separator;
00113   };
00114 } 
00115 #endif
00116 , Option > m_option_dictionnary;
00117     std::string m_command_line;
00118     std::string m_separator;
00119   };
00120 } 
00121 #endif

Generated on Sat Nov 4 15:58:59 2006 for GLARE by doxygen1.2.18