summaryrefslogtreecommitdiffstats
path: root/heimdall/source/Arguments.h
diff options
context:
space:
mode:
authorBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2013-03-07 14:00:52 +0100
committerBenjamin Dobell <benjamin.dobell+git@glassechidna.com.au>2013-03-07 14:12:27 +0100
commitebbc3e7cd2086a9f62a857dffe9ab0bd1f5da768 (patch)
tree2267ec17efe5435887cb68169a56418acf7a9f05 /heimdall/source/Arguments.h
parentPrevious libusbx fix was a red herring of sorts. Inadvertedly it did fix the (diff)
downloadHeimdall-ebbc3e7cd2086a9f62a857dffe9ab0bd1f5da768.tar
Heimdall-ebbc3e7cd2086a9f62a857dffe9ab0bd1f5da768.tar.gz
Heimdall-ebbc3e7cd2086a9f62a857dffe9ab0bd1f5da768.tar.bz2
Heimdall-ebbc3e7cd2086a9f62a857dffe9ab0bd1f5da768.tar.lz
Heimdall-ebbc3e7cd2086a9f62a857dffe9ab0bd1f5da768.tar.xz
Heimdall-ebbc3e7cd2086a9f62a857dffe9ab0bd1f5da768.tar.zst
Heimdall-ebbc3e7cd2086a9f62a857dffe9ab0bd1f5da768.zip
Diffstat (limited to '')
-rw-r--r--heimdall/source/Arguments.h63
1 files changed, 35 insertions, 28 deletions
diff --git a/heimdall/source/Arguments.h b/heimdall/source/Arguments.h
index 17f31fa..b64028b 100644
--- a/heimdall/source/Arguments.h
+++ b/heimdall/source/Arguments.h
@@ -24,12 +24,11 @@
// C/C++ Standard Library
#include <map>
#include <string>
+#include <vector>
// Heimdall
#include "Heimdall.h"
-using namespace std;
-
namespace Heimdall
{
typedef enum
@@ -37,20 +36,21 @@ namespace Heimdall
kArgumentTypeFlag = 0,
kArgumentTypeString,
kArgumentTypeUnsignedInteger
-
} ArgumentType;
class Argument
{
private:
- ArgumentType argumentType;
+ std::string name;
+ ArgumentType type;
protected:
- Argument(ArgumentType argumentType)
+ Argument(const std::string& name, ArgumentType type)
{
- this->argumentType = argumentType;
+ this->name = name;
+ this->type = type;
}
public:
@@ -59,9 +59,14 @@ namespace Heimdall
{
}
- ArgumentType GetArgumentType(void) const
+ const std::string& GetName(void) const
+ {
+ return name;
+ }
+
+ ArgumentType GetType(void) const
{
- return argumentType;
+ return type;
}
};
@@ -69,31 +74,31 @@ namespace Heimdall
{
private:
- FlagArgument() : Argument(kArgumentTypeFlag)
+ FlagArgument(const std::string& name) : Argument(name, kArgumentTypeFlag)
{
}
public:
- static FlagArgument *ParseArgument(int argc, char **argv, int& argi);
+ static FlagArgument *ParseArgument(const std::string& name, int argc, char **argv, int& argi);
};
class StringArgument : public Argument
{
private:
- string value;
+ std::string value;
- StringArgument(const string& value) : Argument(kArgumentTypeString)
+ StringArgument(const std::string& name, const std::string& value) : Argument(name, kArgumentTypeString)
{
this->value = value;
}
public:
- static StringArgument *ParseArgument(int argc, char **argv, int& argi);
+ static StringArgument *ParseArgument(const std::string& name, int argc, char **argv, int& argi);
- const string& GetValue(void) const
+ const std::string& GetValue(void) const
{
return (value);
}
@@ -105,14 +110,14 @@ namespace Heimdall
unsigned int value;
- UnsignedIntegerArgument(unsigned int value) : Argument(kArgumentTypeUnsignedInteger)
+ UnsignedIntegerArgument(const std::string& name, unsigned int value) : Argument(name, kArgumentTypeUnsignedInteger)
{
this->value = value;
}
public:
- static UnsignedIntegerArgument *ParseArgument(int argc, char **argv, int& argi);
+ static UnsignedIntegerArgument *ParseArgument(const std::string& name, int argc, char **argv, int& argi);
unsigned int GetValue(void) const
{
@@ -124,36 +129,38 @@ namespace Heimdall
{
private:
- const map<string, ArgumentType> argumentTypes;
- const map<string, string> shortArgumentAliases;
- const map<string, string> argumentAliases;
+ const std::map<std::string, ArgumentType> argumentTypes;
+ const std::map<std::string, std::string> shortArgumentAliases;
+ const std::map<std::string, std::string> argumentAliases;
- map<string, Argument *> arguments;
+ std::vector<const Argument *> argumentVector;
+ std::map<std::string, const Argument *> argumentMap;
public:
- Arguments(const map<string, ArgumentType>& argumentTypes, const map<string, string>& shortArgumentAliases = (map<string, string>()),
- const map<string, string>& argumentAliases = (map<string, string>()));
+ Arguments(const std::map<std::string, ArgumentType>& argumentTypes,
+ const std::map<std::string, std::string>& shortArgumentAliases = std::map<std::string, std::string>(),
+ const std::map<std::string, std::string>& argumentAliases = std::map<std::string, std::string>());
~Arguments();
// argi is the index of the first argument to parse.
bool ParseArguments(int argc, char **argv, int argi);
- const Argument *GetArgument(string argumentName) const
+ const Argument *GetArgument(std::string argumentName) const
{
- map<string, Argument *>::const_iterator it = arguments.find(argumentName);
- return (it != arguments.end() ? it->second : nullptr);
+ std::map<std::string, const Argument *>::const_iterator it = argumentMap.find(argumentName);
+ return (it != argumentMap.end() ? it->second : nullptr);
}
- const map<string, ArgumentType>& GetArgumentTypes(void) const
+ const std::map<std::string, ArgumentType>& GetArgumentTypes(void) const
{
return (argumentTypes);
}
- const map<string, Argument *>& GetArguments(void) const
+ const std::vector<const Argument *>& GetArguments(void) const
{
- return (arguments);
+ return (argumentVector);
}
};
}