working on the structure

This commit is contained in:
Marcel M. Otte 2015-10-04 17:11:59 +02:00
parent cf03f083c0
commit 30b04c079e
1 changed files with 20 additions and 2 deletions

View File

@ -23,10 +23,11 @@ private:
std::string name;
std::string description;
bool set;
// lists
// lists for attributes of an option
std::unique_ptr<std::list<std::string>> options;
std::unique_ptr<std::list<std::string>> possibleParameters;
std::unique_ptr<std::list<std::string>> defaultParameters;
// values, this list can only be filled by parsing the input data
std::unique_ptr<std::list<std::string>> values;
public:
@ -34,8 +35,20 @@ public:
Option(std::string name);
virtual ~Option();
void setName(std::string name);
// Methods setting configuration attributes
std::shared_ptr<Option> setName(std::string name);
std::shared_ptr<Option> addCommand(std::string cmd);
std::shared_ptr<Option> addPossibleParameter(std::string param);
std::shared_ptr<Option> addDefaultParameter(std::string param);
std::shared_ptr<Option> setStrictChoice(bool strict);
// Methods for retrieving information in different formats
std::shared_ptr<std::list<std::string>> getValues();
std::string getValueAsString(uint index);
uint getValueCount();
int getValueAsInteger(uint index);
double getValueAsDouble(uint index);
float getValueAsFloat(uint index);
};
class CmdLineOptions {
@ -45,8 +58,13 @@ public:
static std::unique_ptr<CmdLineOptions> i();
std::shared_ptr<Option> create(std::string name);
std::shared_ptr<Option> getOption(std::string name);
void setCommandCharacter(char cmdchar);
void parse(char** argv, int argc);
void parse(std::list<std::string> argv);
private:
char cmdchar;
CmdLineOptions();
static std::unique_ptr<CmdLineOptions> instance;
};