Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

CLP.h

Go to the documentation of this file.
00001 
00002 //
00003 // This file is part of the MADELINE 2 program 
00004 // written by Edward H. Trager and Ritu Khanna
00005 // Copyright (c) 2005 by the
00006 // Regents of the University of Michigan.
00007 // All Rights Reserved.
00008 // 
00009 // The latest version of this program is available from:
00010 // 
00011 //   http://eyegene.ophthy.med.umich.edu/madeline/
00012 //   
00013 // Released under the GNU General Public License.
00014 // A copy of the GPL is included in the distribution
00015 // package of this software, or see:
00016 // 
00017 //   http://www.gnu.org/copyleft/
00018 //   
00019 // ... for licensing details.
00020 // 
00022 
00023 #ifndef CLP_INCLUDED
00024 #define CLP_INCLUDED
00025 
00026 #include <iostream>
00027 #include <map>
00028 #include <set>
00029 #include <vector>
00030 
00031 class CLS{
00032 private: 
00033         std::string _name;
00034         std::string _shortName;
00035         std::string _description;
00036         unsigned _numberOfSwitchArguments;
00037         std::vector<std::string> _switchArguments;
00038         bool _isSet;
00039         
00040 public: 
00041         CLS(std::string name, std::string shortName, std::string description, unsigned numberOfSwitchArguments);
00042         void setSwitch(void) { _isSet = true; }
00043         void addSwitchArgument(std::string argument) { _switchArguments.push_back(argument); }
00044         void resetSwitch() { _isSet = false; }
00045         unsigned getNumberOfSwitchArguments(void) { return _numberOfSwitchArguments; }
00046         bool isSet(void){ return _isSet; }
00047         std::string getSwitchArgument(unsigned index){ return _switchArguments[index]; }
00048         const std::string getDescription(void){ return _description; }
00049         const std::string getShortName(void){ return _shortName; }
00050 };
00051 
00052 class CLP{
00053         
00054 private:
00055         std::string _usage;
00056         std::map<std::string,std::string> _shortSwitchMapping;
00057         std::map<std::string, CLS> _switches;
00058         std::vector<std::string> _arguments;
00059         std::vector<std::string> _networkArguments;
00060         std::vector<std::string> _mysqlArguments;
00061         const static std::string _NETWORK_TYPE;
00062         const static std::string _NETWORK_TYPE_SECURE;
00063         const static std::string _MYSQL_TYPE;
00064         void _setSwitchArguments(std::string currentSwitch,int argc,char* argv[],int& currentIndex,CLS& cls);
00065         void _processMysqlArguments(std::string argument);
00066         std::string _getShortSwitchNameMapping(const std::string& shortName);
00067         bool _shortNameExists(const std::string& shortName);
00068         
00069 public:
00070         void addUsage(const std::string usage);
00071         void addSwitch(std::string name,std::string shortName,std::string description,unsigned numberOfArguments=0);
00072         std::string getSwitchArgument(std::string name,unsigned index);
00073         bool parse(int argc,char* argv[]);
00074         bool hasSwitchSet(std::string name);
00075         const std::vector<std::string>& getArguments();
00076         const std::vector<std::string>& getNetworkArguments();
00077         const std::vector<std::string>& getMysqlArguments();
00078         bool hasMysqlArguments(){ if(_mysqlArguments.size()) return true; return false; }
00079         
00080         void printHelp();
00081         void printArguments();
00082         
00083 };
00084 
00085 #endif

Generated on Fri Nov 18 16:24:39 2011 for MADELINE by  doxygen 1.4.4