mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Add a method to ConfigTag to help with retrieving a single character.
This commit is contained in:
parent
a3864dabc7
commit
79b1c44721
@ -54,6 +54,8 @@ class CoreExport ConfigTag : public refcountbase
|
||||
double getFloat(const std::string& key, double def, double min = DBL_MIN, double max = DBL_MAX);
|
||||
/** Get the value of an option, using def if it does not exist */
|
||||
bool getBool(const std::string& key, bool def = false);
|
||||
/** Get the value of an option, using def if it does not exist */
|
||||
unsigned char getCharacter(const std::string& key, unsigned char def = '\0');
|
||||
|
||||
/** Get the value in seconds of a duration that is in the user-friendly "1h2m3s" format,
|
||||
* using a default value if it does not exist or is out of bounds.
|
||||
|
@ -755,6 +755,16 @@ bool ConfigTag::getBool(const std::string &key, bool def)
|
||||
return def;
|
||||
}
|
||||
|
||||
unsigned char ConfigTag::getCharacter(const std::string &key, unsigned char def)
|
||||
{
|
||||
std::string result;
|
||||
if (!readString(key, result) || result.size() != 1)
|
||||
return def;
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
|
||||
std::string ConfigTag::getTagLocation()
|
||||
{
|
||||
return src_name + ":" + ConvToStr(src_line);
|
||||
|
@ -113,7 +113,7 @@ class ModuleOjoin : public Module
|
||||
public:
|
||||
|
||||
ModuleOjoin()
|
||||
: np(this, ServerInstance->Config->ConfValue("ojoin")->getString("prefix").c_str()[0])
|
||||
: np(this, ServerInstance->Config->ConfValue("ojoin")->getCharacter("prefix"))
|
||||
, mycommand(this, np)
|
||||
{
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class OperPrefixMode : public PrefixMode
|
||||
OperPrefixMode(Module* Creator)
|
||||
: PrefixMode(Creator, "operprefix", 'y', OPERPREFIX_VALUE)
|
||||
{
|
||||
prefix = ServerInstance->Config->ConfValue("operprefix")->getString("prefix", "!", 1, 1)[0];
|
||||
prefix = ServerInstance->Config->ConfValue("operprefix")->getCharacter("prefix", '!');
|
||||
ranktoset = ranktounset = UINT_MAX;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user