From 893242cff9a2efc3d7d6553a0b96c83c1033b638 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 15 Nov 2006 21:37:08 +0000 Subject: 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 --- include/configreader.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 5 deletions(-) (limited to 'include') 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 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 ValueContainerBool; +typedef ValueContainer ValueContainerUInt; +typedef ValueContainer ValueContainerChar; +typedef ValueContainer ValueContainerInt; + typedef std::deque 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; }; -- cgit v1.2.3