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 { namespace cmdlineoptions {
CmdLineOptions::~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() {} CmdLineOptions::CmdLineOptions() {}
} /* namespace cmdlineoptions */ } /* namespace cmdlineoptions */

View File

@ -10,6 +10,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <list> #include <list>
#include <map>
namespace cmdlineoptions { namespace cmdlineoptions {
@ -55,10 +56,10 @@ class CmdLineOptions {
public: public:
virtual ~CmdLineOptions(); virtual ~CmdLineOptions();
static std::unique_ptr<CmdLineOptions> i(); static const std::unique_ptr<CmdLineOptions> &i();
std::shared_ptr<Option> create(std::string name); std::shared_ptr<Option> create(std::string &name);
std::shared_ptr<Option> getOption(std::string name); std::shared_ptr<Option> getOption(std::string &name);
void setCommandCharacter(char cmdchar); void setCommandCharacter(char &cmdchar);
void parse(char **argv, int argc); void parse(char **argv, int argc);
void parse(std::list<std::string> argv); void parse(std::list<std::string> argv);
@ -67,6 +68,7 @@ private:
char cmdchar; char cmdchar;
CmdLineOptions(); CmdLineOptions();
static std::unique_ptr<CmdLineOptions> instance; static std::unique_ptr<CmdLineOptions> instance;
std::map<std::string, std::shared_ptr<Option>> options;
}; };
} /* namespace cmdlineoptions */ } /* namespace cmdlineoptions */