From 004217daed4e60162bcb3f99c85e2efe41c21a03 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 14 Nov 2006 22:38:43 +0000 Subject: Tons of tweaks to the config stuff for the core git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5744 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/configreader.h | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'include/configreader.h') diff --git a/include/configreader.h b/include/configreader.h index 516c6a6ed..023121ffc 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -31,19 +31,52 @@ class ServerConfig; class InspIRCd; +/** Types of data in the core config + */ +enum ConfigDataType { DT_NOTHING, DT_INTEGER, DT_CHARPTR, DT_BOOLEAN }; + +class ValueItem +{ + std::string v; + public: + ValueItem(int value) + { + std::stringstream n; + n << value; + v = n.str(); + } + + ValueItem(bool value) + { + std::stringstream n; + n << value; + v = n.str(); + } + + ValueItem(char* value) + { + v = value; + } + + int GetInteger() { return atoi(v.c_str()); }; + + const char* GetString() { return v.c_str(); }; + + bool GetBool() { return GetInteger(); }; +}; + +typedef std::deque ValueList; + /** A callback for validating a single value */ typedef bool (*Validator)(ServerConfig* conf, const char*, const char*, void*); /** A callback for validating multiple value entries */ -typedef bool (*MultiValidator)(ServerConfig* conf, const char*, char**, void**, int*); +typedef bool (*MultiValidator)(ServerConfig* conf, const char*, char**, ValueList&, int*); /** A callback indicating the end of a group of entries */ typedef bool (*MultiNotify)(ServerConfig* conf, const char*); -/** Types of data in the core config - */ -enum ConfigDataType { DT_NOTHING, DT_INTEGER, DT_CHARPTR, DT_BOOLEAN }; /** Holds a core configuration item and its callbacks */ @@ -498,4 +531,10 @@ class ServerConfig : public Extensible bool InitializeDisabledCommands(const char* data, InspIRCd* ServerInstance); +bool InitTypes(ServerConfig* conf, const char* tag); +bool InitClasses(ServerConfig* conf, const char* tag); +bool DoType(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); +bool DoClass(ServerConfig* conf, const char* tag, char** entries, ValueList &values, int* types); +bool DoneClassesAndTypes(ServerConfig* conf, const char* tag); + #endif -- cgit v1.2.3