00001 #ifndef OPTIONHH 00002 #define OPTION_HH 00003 00004 #include <map> 00005 #include <string> 00006 00007 00008 /*! \class Arguments 00009 * \brief generic class to manage command arguments 00010 * 00011 * Distinguish command, arguments and options 00012 * 00013 * Command name is not include in arguments list but can be accessed via getCommand() method 00014 * 00015 * Options: words after a "-string": 00016 * Examples 00017 * : command -f option. 00018 * : command -option1 option1. 00019 * Option are not mandatory, and order in which they arrive does not matter. 00020 * Access option with getOption("-string") method 00021 * 00022 * Arguments are mandatory, and order in which they arrive is take in account 00023 * Access argument with getArgument(order) method 00024 * 00025 */ 00026 00027 class Arguments 00028 { 00029 public: 00030 00031 Arguments(int argc, char** argv,std::string usage = ""); 00032 ~Arguments() ; 00033 00034 std::string getCommand() { return command; } 00035 std::string getOption( const std::string) const ; 00036 std::string getArgument( const unsigned int) const ; 00037 unsigned int getNbOfArgs() { return orderKeyMap.size(); } 00038 unsigned int getNbOfOptions() { return stringKeyMap.size(); } 00039 void usage(void); 00040 00041 private: 00042 00043 std::string command; 00044 std::map<const std::string , std::string> stringKeyMap; 00045 std::map< const unsigned int , std::string> orderKeyMap; 00046 std::string pUsage; 00047 }; 00048 00049 #endif