Merge branch 'master' into jgrpp
# Conflicts: # src/crashlog.cpp # src/gfx.cpp # src/network/network_client.cpp # src/openttd.cpp # src/openttd.h # src/saveload/saveload.cpp # src/survey.cpp
This commit is contained in:
@@ -387,30 +387,6 @@ bool StrValid(const char *str, const char *last)
|
||||
return *str == '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim the spaces from the begin of given string in place, i.e. the string buffer
|
||||
* that is passed will be modified whenever spaces exist in the given string.
|
||||
* When there are spaces at the begin, the whole string is moved forward.
|
||||
* @param str The string to perform the in place left trimming on.
|
||||
*/
|
||||
static void StrLeftTrimInPlace(std::string &str)
|
||||
{
|
||||
size_t pos = str.find_first_not_of(' ');
|
||||
str.erase(0, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim the spaces from the end of given string in place, i.e. the string buffer
|
||||
* that is passed will be modified whenever spaces exist in the given string.
|
||||
* When there are spaces at the end, the '\0' will be moved forward.
|
||||
* @param str The string to perform the in place left trimming on.
|
||||
*/
|
||||
static void StrRightTrimInPlace(std::string &str)
|
||||
{
|
||||
size_t pos = str.find_last_not_of(' ');
|
||||
if (pos != std::string::npos) str.erase(pos + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim the spaces from given string in place, i.e. the string buffer that
|
||||
* is passed will be modified whenever spaces exist in the given string.
|
||||
@@ -420,8 +396,17 @@ static void StrRightTrimInPlace(std::string &str)
|
||||
*/
|
||||
void StrTrimInPlace(std::string &str)
|
||||
{
|
||||
StrLeftTrimInPlace(str);
|
||||
StrRightTrimInPlace(str);
|
||||
str = StrTrimView(str);
|
||||
}
|
||||
|
||||
std::string_view StrTrimView(std::string_view str)
|
||||
{
|
||||
size_t first_pos = str.find_first_not_of(' ');
|
||||
if (first_pos == std::string::npos) {
|
||||
return std::string_view{};
|
||||
}
|
||||
size_t last_pos = str.find_last_not_of(' ');
|
||||
return str.substr(first_pos, last_pos - first_pos + 1);
|
||||
}
|
||||
|
||||
const char *StrLastPathSegment(const char *path)
|
||||
|
Reference in New Issue
Block a user