working on some methods...

This commit is contained in:
Marcel M. Otte 2015-10-04 20:10:52 +02:00
parent 30b04c079e
commit e4d053e134
2 changed files with 33 additions and 5 deletions

View File

@ -10,6 +10,32 @@
namespace cmdlineoptions {
CmdLineOptions::~CmdLineOptions() {}
const std::unique_ptr<CmdLineOptions> &CmdLineOptions::i() {
if (!instance) {
instance = std::unique_ptr<CmdLineOptions>(new CmdLineOptions());
}
return instance;
}
std::shared_ptr<Option> CmdLineOptions::create(std::string &name) {
std::shared_ptr<Option> option = std::make_shared<Option>(name);
this->options.insert(std::make_pair(name, option));
return option;
}
std::shared_ptr<Option> CmdLineOptions::getOption(std::string &name) {
return this->options.at(name);
}
void CmdLineOptions::setCommandCharacter(char &cmdchar) {
this->cmdchar = cmdchar;
}
void CmdLineOptions::parse(char **argv, int argc) {}
void CmdLineOptions::parse(std::list<std::string> argv) {}
CmdLineOptions::CmdLineOptions() {}
} /* namespace cmdlineoptions */

View File

@ -10,6 +10,7 @@
#include <memory>
#include <string>
#include <list>
#include <map>
namespace cmdlineoptions {
@ -55,18 +56,19 @@ class CmdLineOptions {
public:
virtual ~CmdLineOptions();
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);
static const 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(char **argv, int argc);
void parse(std::list<std::string> argv);
private:
char cmdchar;
CmdLineOptions();
static std::unique_ptr<CmdLineOptions> instance;
std::map<std::string, std::shared_ptr<Option>> options;
};
} /* namespace cmdlineoptions */