diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-11-15 21:37:08 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-11-15 21:37:08 +0000 |
commit | 893242cff9a2efc3d7d6553a0b96c83c1033b638 (patch) | |
tree | 42a9891910a5920d7aa49d93729160fe0859cd6d /include/configreader.h | |
parent | 235b289194a6345475933612f7c28c993abf5390 (diff) |
All of the void* cast stuff gone!!!
Todo: comment all this stuff...
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5750 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include/configreader.h')
-rw-r--r-- | include/configreader.h | 63 |
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; }; |