From 047f09dd572b89223ff3798dc25c34fe4c4172b3 Mon Sep 17 00:00:00 2001 From: peavey Date: Tue, 26 Dec 2006 00:51:20 +0000 Subject: Add possibility to define default value for ConfValue in configreader and ReadConf in modules. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6113 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/modules.cpp') diff --git a/src/modules.cpp b/src/modules.cpp index b218c63ee..18b2bf618 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -625,20 +625,24 @@ ConfigReader::ConfigReader(InspIRCd* Instance, const std::string &filename) : Se this->error = CONF_FILE_NOT_FOUND; }; -std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, int index, bool allow_linefeeds) + +std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds) { /* Don't need to strlcpy() tag and name anymore, ReadConf() takes const char* */ std::string result; - if (!ServerInstance->Config->ConfValue(*this->data, tag, name, index, result, allow_linefeeds)) + if (!ServerInstance->Config->ConfValue(*this->data, tag, name, default_value, index, result, allow_linefeeds)) { this->error = CONF_VALUE_NOT_FOUND; - return ""; } - return result; } +std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, int index, bool allow_linefeeds) +{ + return ReadValue(tag, name, "", index, allow_linefeeds); +} + bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int index) { return ServerInstance->Config->ConfValueBool(*this->data, tag, name, index); -- cgit v1.3.1-10-gc9f91