summaryrefslogtreecommitdiff
path: root/include/configreader.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/configreader.h')
-rw-r--r--include/configreader.h63
1 files changed, 58 insertions, 5 deletions
diff --git a/include/configreader.h b/include/configreader.h
index 179827eed..069e6321d 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -58,7 +58,12 @@ class ValueItem
v = value;
}
- void Set(const std::string &value)
+ void Set(char* value)
+ {
+ v = value;
+ }
+
+ void Set(const char* value)
{
v = value;
}
@@ -70,13 +75,61 @@ class ValueItem
v = n.str();
}
- int GetInteger() { return atoi(v.c_str()); };
+ int GetInteger()
+ {
+ return atoi(v.c_str());
+ }
+
+ char* GetString()
+ {
+ return (char*)v.c_str();
+ }
+
+ bool GetBool()
+ {
+ return (GetInteger() || v == "yes" || v == "true");
+ }
+};
+
+class ValueContainerBase
+{
+ public:
+ ValueContainerBase()
+ {
+ }
+
+ virtual ~ValueContainerBase()
+ {
+ }
+};
- const char* GetString() { return v.c_str(); };
+template<typename T> class ValueContainer : public ValueContainerBase
+{
+ T val;
+
+ public:
- bool GetBool() { return GetInteger(); };
+ ValueContainer()
+ {
+ val = NULL;
+ }
+
+ ValueContainer(T Val)
+ {
+ val = Val;
+ }
+
+ void Set(T newval, size_t s)
+ {
+ memcpy(val, newval, s);
+ }
};
+typedef ValueContainer<bool*> ValueContainerBool;
+typedef ValueContainer<unsigned int*> ValueContainerUInt;
+typedef ValueContainer<char*> ValueContainerChar;
+typedef ValueContainer<int*> ValueContainerInt;
+
typedef std::deque<ValueItem> ValueList;
/** A callback for validating a single value
@@ -96,7 +149,7 @@ struct InitialConfig
{
char* tag;
char* value;
- void* val;
+ ValueContainerBase* val;
ConfigDataType datatype;
Validator validation_function;
};