mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Rename ConfigTag::tag to ConfigTag::name.
This commit is contained in:
parent
373bc208ff
commit
e21af089ba
@ -50,16 +50,17 @@ public:
|
||||
Items items;
|
||||
|
||||
public:
|
||||
const std::string tag;
|
||||
/** The name of the configuration tag (e.g. "foo" for \<foo bar="baz">). */
|
||||
const std::string name;
|
||||
|
||||
/** The position within the source file that this tag was read from. */
|
||||
const FilePosition source;
|
||||
|
||||
/** Creates a new ConfigTag instance with the specified tag name, file, and line.
|
||||
* @param Tag The name of this config tag (e.g. "foo" for \<foo>).
|
||||
* @param Name The name of this config tag (e.g. "foo" for \<foo bar="baz">).
|
||||
* @param Source The source of this config tag.
|
||||
*/
|
||||
ConfigTag(const std::string& Tag, const FilePosition& Source);
|
||||
ConfigTag(const std::string& Name, const FilePosition& Source);
|
||||
|
||||
/** Get the value of an option, using def if it does not exist */
|
||||
std::string getString(const std::string& key, const std::string& def, const std::function<bool(const std::string&)>& validator) const;
|
||||
@ -97,7 +98,7 @@ public:
|
||||
|
||||
std::vector<const char*> enumkeys;
|
||||
std::transform(enumvals.begin(), enumvals.end(), std::back_inserter(enumkeys), [](const std::pair<const char*, TReturn>& ev) { return ev.first; });
|
||||
throw ModuleException(val + " is an invalid value for <" + tag + ":" + key + ">; acceptable values are " +
|
||||
throw ModuleException(val + " is an invalid value for <" + name + ":" + key + ">; acceptable values are " +
|
||||
stdalgo::string::join(enumkeys, ' ') + ", at " + source.str());
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ struct Parser
|
||||
ch = next();
|
||||
if (ch != '"')
|
||||
{
|
||||
throw CoreException("Invalid character in value of <" + tag->tag + ":" + key + ">");
|
||||
throw CoreException("Invalid character in value of <" + tag->name + ":" + key + ">");
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
@ -195,7 +195,7 @@ struct Parser
|
||||
break;
|
||||
else
|
||||
{
|
||||
stack.errstr << "Invalid XML entity name in value of <" + tag->tag + ":" + key + ">\n"
|
||||
stack.errstr << "Invalid XML entity name in value of <" + tag->name + ":" + key + ">\n"
|
||||
<< "To include an ampersand or quote, use & or "\n";
|
||||
throw CoreException("Parse error");
|
||||
}
|
||||
@ -342,7 +342,7 @@ struct Parser
|
||||
{
|
||||
stack.errstr << err.GetReason() << " at " << current.str();
|
||||
if (tag)
|
||||
stack.errstr << " (inside tag " << tag->tag << " at line " << tag->source.line << ")\n";
|
||||
stack.errstr << " (inside tag " << tag->name << " at line " << tag->source.line << ")\n";
|
||||
else
|
||||
stack.errstr << " (last tag was on line " << last_tag.line << ")\n";
|
||||
}
|
||||
@ -471,7 +471,7 @@ bool ConfigTag::readString(const std::string& key, std::string& value, bool allo
|
||||
value = ivalue;
|
||||
if (!allow_lf && (value.find('\n') != std::string::npos))
|
||||
{
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Value of <" + tag + ":" + key + "> at " + source.str() +
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Value of <" + name + ":" + key + "> at " + source.str() +
|
||||
" contains a linefeed, and linefeeds in this value are not permitted -- stripped to spaces.");
|
||||
for (std::string::iterator n = value.begin(); n != value.end(); n++)
|
||||
if (*n == '\n')
|
||||
@ -491,7 +491,7 @@ std::string ConfigTag::getString(const std::string& key, const std::string& def,
|
||||
if (!validator(res))
|
||||
{
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "WARNING: The value of <%s:%s> is not valid; value set to %s.",
|
||||
tag.c_str(), key.c_str(), def.c_str());
|
||||
name.c_str(), key.c_str(), def.c_str());
|
||||
return def;
|
||||
}
|
||||
return res;
|
||||
@ -506,7 +506,7 @@ std::string ConfigTag::getString(const std::string& key, const std::string& def,
|
||||
if (res.length() < minlen || res.length() > maxlen)
|
||||
{
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "WARNING: The length of <%s:%s> is not between %ld and %ld; value set to %s.",
|
||||
tag.c_str(), key.c_str(), minlen, maxlen, def.c_str());
|
||||
name.c_str(), key.c_str(), minlen, maxlen, def.c_str());
|
||||
return def;
|
||||
}
|
||||
return res;
|
||||
@ -586,8 +586,8 @@ long ConfigTag::getInt(const std::string& key, long def, long min, long max) con
|
||||
if (res_tail == res_cstr)
|
||||
return def;
|
||||
|
||||
CheckMagnitude(tag, key, result, res, def, res_tail);
|
||||
CheckRange(tag, key, res, def, min, max);
|
||||
CheckMagnitude(key, key, result, res, def, res_tail);
|
||||
CheckRange(key, key, res, def, min, max);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -603,8 +603,8 @@ unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsi
|
||||
if (res_tail == res_cstr)
|
||||
return def;
|
||||
|
||||
CheckMagnitude(tag, key, result, res, def, res_tail);
|
||||
CheckRange(tag, key, res, def, min, max);
|
||||
CheckMagnitude(key, key, result, res, def, res_tail);
|
||||
CheckRange(key, key, res, def, min, max);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -617,12 +617,12 @@ unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def,
|
||||
unsigned long ret;
|
||||
if (!InspIRCd::Duration(duration, ret))
|
||||
{
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Value of <" + tag + ":" + key + "> at " + source.str() +
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Value of <" + name + ":" + key + "> at " + source.str() +
|
||||
" is not a duration; value set to " + ConvToStr(def) + ".");
|
||||
return def;
|
||||
}
|
||||
|
||||
CheckRange(tag, key, ret, def, min, max);
|
||||
CheckRange(name, key, ret, def, min, max);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -633,7 +633,7 @@ double ConfigTag::getFloat(const std::string& key, double def, double min, doubl
|
||||
return def;
|
||||
|
||||
double res = strtod(result.c_str(), NULL);
|
||||
CheckRange(tag, key, res, def, min, max);
|
||||
CheckRange(name, key, res, def, min, max);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -649,13 +649,13 @@ bool ConfigTag::getBool(const std::string& key, bool def) const
|
||||
if (stdalgo::string::equalsci(result, "no") || stdalgo::string::equalsci(result, "false") || stdalgo::string::equalsci(result, "off"))
|
||||
return false;
|
||||
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Value of <" + tag + ":" + key + "> at " + source.str() +
|
||||
ServerInstance->Logs.Log("CONFIG", LOG_DEFAULT, "Value of <" + name + ":" + key + "> at " + source.str() +
|
||||
" is not valid, ignoring");
|
||||
return def;
|
||||
}
|
||||
|
||||
ConfigTag::ConfigTag(const std::string& Tag, const FilePosition& Source)
|
||||
: tag(Tag)
|
||||
ConfigTag::ConfigTag(const std::string& Name, const FilePosition& Source)
|
||||
: name(Name)
|
||||
, source(Source)
|
||||
{
|
||||
}
|
||||
|
@ -51,10 +51,10 @@ class ModuleHttpConfig : public Module, public HTTPRequestEventListener
|
||||
{
|
||||
// Show the location of the tag in a comment.
|
||||
buffer << "# " << tag->source.str() << std::endl
|
||||
<< '<' << tag->tag << ' ';
|
||||
<< '<' << tag->name << ' ';
|
||||
|
||||
// Print out the tag with all keys aligned vertically.
|
||||
const std::string indent(tag->tag.length() + 2, ' ');
|
||||
const std::string indent(tag->name.length() + 2, ' ');
|
||||
const ConfigTag::Items& items = tag->GetItems();
|
||||
for (ConfigTag::Items::const_iterator kiter = items.begin(); kiter != items.end(); )
|
||||
{
|
||||
|
@ -1239,7 +1239,7 @@ ConnectClass::ConnectClass(std::shared_ptr<ConfigTag> tag, char t, const std::st
|
||||
// Connect classes can inherit from each other but this is problematic for modules which can't use
|
||||
// ConnectClass::Update so we build a hybrid tag containing all of the values set on this class as
|
||||
// well as the parent class.
|
||||
config = std::make_shared<ConfigTag>(tag->tag, tag->source);
|
||||
config = std::make_shared<ConfigTag>(tag->name, tag->source);
|
||||
for (const auto& [key, value] : parent->config->GetItems())
|
||||
{
|
||||
// The class name and parent name are not inherited
|
||||
|
Loading…
x
Reference in New Issue
Block a user