16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

Replace string_starts_with and string_ends_with with string::starts_with and string::ends_with

This commit is contained in:
docentYT
2026-05-01 13:33:32 +02:00
parent 614a7f51a5
commit bd21b8f49c
5 changed files with 8 additions and 27 deletions

View File

@@ -16,7 +16,7 @@ void scenery_scanner::scan()
if (*(path.filename().string().begin()) == '$')
continue;
if (string_ends_with(path.string(), ".scn"))
if (path.string().ends_with(".scn"))
scan_scn(path);
}
@@ -50,7 +50,7 @@ void scenery_scanner::scan_scn(std::filesystem::path path)
{
line_counter++;
if (line.size() < 6 || !string_starts_with(line, "//$"))
if (line.size() < 6 || !line.starts_with("//$"))
continue;
if (line[3] == 'i')

View File

@@ -111,7 +111,7 @@ node_groups::update_map()
for (basic_node *node : group.nodes) {
std::string postfix { "_sem_mem" };
if (typeid(*node) == typeid(TMemCell) && string_ends_with(node->name(), postfix)) {
if (typeid(*node) == typeid(TMemCell) && node->name().ends_with(postfix)) {
std::string sem_name = node->name().substr(0, node->name().length() - postfix.length());
auto sem_info = std::make_shared<map::semaphore>();
@@ -122,7 +122,7 @@ node_groups::update_map()
sem_info->name = sem_name;
for (basic_event *event : group.events) {
if (string_starts_with(event->name(), sem_name)
if (event->name().starts_with(sem_name)
&& event->name().substr(sem_name.length()).find("sem") == std::string::npos) {
sem_info->events.push_back(event);
}
@@ -130,7 +130,7 @@ node_groups::update_map()
for (basic_node *node : group.nodes)
if (auto *model = dynamic_cast<TAnimModel*>(node))
if (string_starts_with(model->name(), sem_name))
if (model->name().starts_with(sem_name))
sem_info->models.push_back(model);
}

View File

@@ -86,11 +86,11 @@ bool locale::parse_translation(std::istream &stream)
if (line.size() > 0 && line[0] == '#')
continue;
if (string_starts_with(line, "msgid"))
if (line.starts_with("msgid"))
last = 'i';
else if (string_starts_with(line, "msgstr"))
else if (line.starts_with("msgstr"))
last = 's';
else if (string_starts_with(line, "msgctxt"))
else if (line.starts_with("msgctxt"))
last = 'c';
if (line.size() > 1 && last != 'x') {

View File

@@ -215,22 +215,6 @@ std::string to_minutes_str(float const Minutes, bool const Leadingzero, int cons
return (minutes.substr(minutes.size() - width, width) + fractionlabels[static_cast<int>(std::floor(minutesfractional * 10 + 0.1))]);
}
bool string_ends_with(const std::string &string, const std::string &ending)
{
if (string.length() < ending.length())
return false;
return string.compare(string.length() - ending.length(), ending.length(), ending) == 0;
}
bool string_starts_with(const std::string &string, const std::string &begin)
{
if (string.length() < begin.length())
return false;
return string.compare(0, begin.length(), begin) == 0;
}
int stol_def(const std::string &str, const int &DefaultValue)
{

View File

@@ -146,9 +146,6 @@ template <typename Type_, glm::precision Precision_ = glm::defaultp> std::string
return to_string(Value.x, Width) + ", " + to_string(Value.y, Width) + ", " + to_string(Value.z, Width) + ", " + to_string(Value.w, Width);
}
bool string_ends_with(std::string const &string, std::string const &ending);
bool string_starts_with(std::string const &string, std::string const &begin);
int stol_def(const std::string &str, const int &DefaultValue);
std::string ToLower(std::string const &text);