mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Introduce std::string_view
into wider use (#14368)
This commit is contained in:
parent
fa47af737f
commit
6ca214fefc
74 changed files with 501 additions and 456 deletions
|
@ -97,7 +97,7 @@ void SettingsHierarchy::onLayerRemoved(int layer)
|
|||
|
||||
/* Settings implementation */
|
||||
|
||||
Settings *Settings::createLayer(SettingsLayer sl, const std::string &end_tag)
|
||||
Settings *Settings::createLayer(SettingsLayer sl, std::string_view end_tag)
|
||||
{
|
||||
return new Settings(end_tag, &g_hierarchy, (int)sl);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ Settings *Settings::getLayer(SettingsLayer sl)
|
|||
}
|
||||
|
||||
|
||||
Settings::Settings(const std::string &end_tag, SettingsHierarchy *h,
|
||||
Settings::Settings(std::string_view end_tag, SettingsHierarchy *h,
|
||||
int settings_layer) :
|
||||
m_end_tag(end_tag),
|
||||
m_hierarchy(h),
|
||||
|
@ -131,7 +131,7 @@ Settings::~Settings()
|
|||
}
|
||||
|
||||
|
||||
Settings & Settings::operator = (const Settings &other)
|
||||
Settings & Settings::operator=(const Settings &other)
|
||||
{
|
||||
if (&other == this)
|
||||
return *this;
|
||||
|
@ -151,7 +151,7 @@ Settings & Settings::operator = (const Settings &other)
|
|||
}
|
||||
|
||||
|
||||
bool Settings::checkNameValid(const std::string &name)
|
||||
bool Settings::checkNameValid(std::string_view name)
|
||||
{
|
||||
bool valid = name.find_first_of("=\"{}#") == std::string::npos;
|
||||
if (valid)
|
||||
|
@ -166,7 +166,7 @@ bool Settings::checkNameValid(const std::string &name)
|
|||
}
|
||||
|
||||
|
||||
bool Settings::checkValueValid(const std::string &value)
|
||||
bool Settings::checkValueValid(std::string_view value)
|
||||
{
|
||||
if (value.substr(0, 3) == "\"\"\"" ||
|
||||
value.find("\n\"\"\"") != std::string::npos) {
|
||||
|
@ -407,13 +407,13 @@ bool Settings::parseCommandLine(int argc, char *argv[],
|
|||
{
|
||||
int nonopt_index = 0;
|
||||
for (int i = 1; i < argc; i++) {
|
||||
std::string arg_name = argv[i];
|
||||
std::string_view arg_name(argv[i]);
|
||||
if (arg_name.substr(0, 2) != "--") {
|
||||
// If option doesn't start with -, read it in as nonoptX
|
||||
if (arg_name[0] != '-'){
|
||||
if (arg_name[0] != '-') {
|
||||
std::string name = "nonopt";
|
||||
name += itos(nonopt_index);
|
||||
set(name, arg_name);
|
||||
set(name, std::string(arg_name));
|
||||
nonopt_index++;
|
||||
continue;
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ bool Settings::parseCommandLine(int argc, char *argv[],
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string name = arg_name.substr(2);
|
||||
std::string name(arg_name.substr(2));
|
||||
|
||||
auto n = allowed_options.find(name);
|
||||
if (n == allowed_options.end()) {
|
||||
|
@ -997,7 +997,7 @@ bool Settings::remove(const std::string &name)
|
|||
SettingsParseEvent Settings::parseConfigObject(const std::string &line,
|
||||
std::string &name, std::string &value)
|
||||
{
|
||||
std::string trimmed_line = trim(line);
|
||||
auto trimmed_line = trim(line);
|
||||
|
||||
if (trimmed_line.empty())
|
||||
return SPE_NONE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue