Rename String methods to use lowerCamelCase

This commit is contained in:
Aaron van Geffen committed 2024-12-11 22:49:37 +01:00
1 parent a24dc2e60a
commit 35e117aca2
102 files changed
+587 -589

No files matched your search

+3 -3
View File
@@ -62,10 +62,10 @@ void TextComposition::HandleMessage(const SDL_Event* e)
{
case SDL_TEXTEDITING:
// When inputting Korean characters, `edit.length` is always zero
String::Set(_imeBuffer, sizeof(_imeBuffer), e->edit.text);
String::set(_imeBuffer, sizeof(_imeBuffer), e->edit.text);
_imeStart = e->edit.start;
_imeLength = e->edit.length;
_imeActive = ((e->edit.length != 0 || String::SizeOf(e->edit.text) != 0) && _imeBuffer[0] != '\0');
_imeActive = ((e->edit.length != 0 || String::sizeOf(e->edit.text) != 0) && _imeBuffer[0] != '\0');
break;
case SDL_TEXTINPUT:
// will receive an `SDL_TEXTINPUT` event when a composition is committed
@@ -446,5 +446,5 @@ void TextComposition::Delete()
void TextComposition::RecalculateLength()
{
_session.Length = String::LengthOf(_session.Buffer->c_str());
_session.Length = String::lengthOf(_session.Buffer->c_str());
}
+16 -16
View File
@@ -103,14 +103,14 @@ namespace OpenRCT2::Ui
{
case DIALOG_TYPE::KDIALOG:
{
std::string cmd = String::StdFormat(
std::string cmd = String::stdFormat(
"%s --title \"OpenRCT2\" --msgbox \"%s\"", executablePath.c_str(), message.c_str());
Platform::Execute(cmd);
break;
}
case DIALOG_TYPE::ZENITY:
{
std::string cmd = String::StdFormat(
std::string cmd = String::stdFormat(
"%s --title=\"OpenRCT2\" --info --text=\"%s\"", executablePath.c_str(), message.c_str());
Platform::Execute(cmd);
break;
@@ -123,13 +123,13 @@ namespace OpenRCT2::Ui
void OpenFolder(const std::string& path) override
{
std::string cmd = String::StdFormat("xdg-open %s", EscapePathForShell(path).c_str());
std::string cmd = String::stdFormat("xdg-open %s", EscapePathForShell(path).c_str());
Platform::Execute(cmd);
}
void OpenURL(const std::string& url) override
{
std::string cmd = String::StdFormat("xdg-open %s", url.c_str());
std::string cmd = String::stdFormat("xdg-open %s", url.c_str());
Platform::Execute(cmd);
}
@@ -145,7 +145,7 @@ namespace OpenRCT2::Ui
{
std::string action = (desc.Type == FileDialogType::Open) ? "--getopenfilename" : "--getsavefilename";
std::string filter = GetKDialogFilterString(desc.Filters);
std::string cmd = String::StdFormat(
std::string cmd = String::stdFormat(
"%s --title '%s' %s %s '%s'", executablePath.c_str(), desc.Title.c_str(), action.c_str(),
directory.c_str(), filter.c_str());
std::string output;
@@ -164,7 +164,7 @@ namespace OpenRCT2::Ui
flags = "--confirm-overwrite --save";
}
std::string filters = GetZenityFilterString(desc.Filters);
std::string cmd = String::StdFormat(
std::string cmd = String::stdFormat(
"%s %s --filename=%s %s --title='%s' / %s", executablePath.c_str(), action.c_str(), directory.c_str(),
flags.c_str(), desc.Title.c_str(), filters.c_str());
std::string output;
@@ -204,14 +204,14 @@ namespace OpenRCT2::Ui
{
if (desc.Type == FileDialogType::Open && access(result.c_str(), F_OK) == -1)
{
std::string msg = String::StdFormat(
std::string msg = String::stdFormat(
"\"%s\" not found: %s, please choose another file\n", result.c_str(), strerror(errno));
ShowMessageBox(window, msg);
return ShowFileDialog(window, desc);
}
if (desc.Type == FileDialogType::Save && access(result.c_str(), F_OK) != -1 && dtype == DIALOG_TYPE::KDIALOG)
{
std::string cmd = String::StdFormat("%s --yesno \"Overwrite %s?\"", executablePath.c_str(), result.c_str());
std::string cmd = String::stdFormat("%s --yesno \"Overwrite %s?\"", executablePath.c_str(), result.c_str());
if (Platform::Execute(cmd) != 0)
{
result = std::string();
@@ -231,7 +231,7 @@ namespace OpenRCT2::Ui
case DIALOG_TYPE::KDIALOG:
{
std::string output;
std::string cmd = String::StdFormat(
std::string cmd = String::stdFormat(
"%s --title '%s' --getexistingdirectory /", executablePath.c_str(), title.c_str());
if (Platform::Execute(cmd, &output) == 0)
{
@@ -242,7 +242,7 @@ namespace OpenRCT2::Ui
case DIALOG_TYPE::ZENITY:
{
std::string output;
std::string cmd = String::StdFormat(
std::string cmd = String::stdFormat(
"%s --title='%s' --file-selection --directory /", executablePath.c_str(), title.c_str());
if (Platform::Execute(cmd, &output) == 0)
{
@@ -299,12 +299,12 @@ namespace OpenRCT2::Ui
case DIALOG_TYPE::ZENITY:
{
auto sb = StringBuilder();
sb.Append(String::StdFormat("zenity --list --column '' --width=%d --height=%d", width, height));
sb.Append(String::stdFormat("zenity --list --column '' --width=%d --height=%d", width, height));
for (const auto& option : options)
{
sb.Append(String::StdFormat(" '%s'", option.c_str()));
sb.Append(String::stdFormat(" '%s'", option.c_str()));
}
sb.Append(String::StdFormat(" --title '%s' --text '%s'", title.c_str(), text.c_str()));
sb.Append(String::stdFormat(" --title '%s' --text '%s'", title.c_str(), text.c_str()));
std::string buff;
Platform::Execute(sb.GetBuffer(), &buff);
@@ -313,11 +313,11 @@ namespace OpenRCT2::Ui
case DIALOG_TYPE::KDIALOG:
{
auto sb = StringBuilder();
sb.Append(String::StdFormat("kdialog --geometry %dx%d --title '%s' --menu ", width, height, title.c_str()));
sb.Append(String::StdFormat(" '%s'", text.c_str()));
sb.Append(String::stdFormat("kdialog --geometry %dx%d --title '%s' --menu ", width, height, title.c_str()));
sb.Append(String::stdFormat(" '%s'", text.c_str()));
for (const auto& option : options)
{
sb.Append(String::StdFormat(" '%s' '%s'", option.c_str(), option.c_str()));
sb.Append(String::stdFormat(" '%s' '%s'", option.c_str(), option.c_str()));
}
std::string buff;
+9 -9
View File
@@ -98,7 +98,7 @@ namespace OpenRCT2::Ui
void ShowMessageBox(SDL_Window* window, const std::string& message) override
{
HWND hwnd = GetHWND(window);
std::wstring messageW = String::ToWideChar(message);
std::wstring messageW = String::toWideChar(message);
MessageBoxW(hwnd, messageW.c_str(), L"OpenRCT2", MB_OK);
}
@@ -115,13 +115,13 @@ namespace OpenRCT2::Ui
void OpenFolder(const std::string& path) override
{
std::wstring pathW = String::ToWideChar(path);
std::wstring pathW = String::toWideChar(path);
ShellExecuteW(NULL, L"open", pathW.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
void OpenURL(const std::string& url) override
{
std::wstring urlW = String::ToWideChar(url);
std::wstring urlW = String::toWideChar(url);
ShellExecuteW(NULL, L"open", urlW.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
@@ -151,13 +151,13 @@ namespace OpenRCT2::Ui
DWORD flags;
if (SUCCEEDED(fileDialog->GetOptions(&flags)) && SUCCEEDED(fileDialog->SetOptions(flags | flagsToSet)))
{
fileDialog->SetTitle(String::ToWideChar(desc.Title).c_str());
fileDialog->SetFileName(String::ToWideChar(Path::GetFileName(desc.DefaultFilename)).c_str());
fileDialog->SetTitle(String::toWideChar(desc.Title).c_str());
fileDialog->SetFileName(String::toWideChar(Path::GetFileName(desc.DefaultFilename)).c_str());
// Set default directory (optional, don't fail the operation if it fails to set)
ComPtr<IShellItem> defaultDirectory;
if (SUCCEEDED(SHCreateItemFromParsingName(
String::ToWideChar(desc.InitialDirectory).c_str(), nullptr,
String::toWideChar(desc.InitialDirectory).c_str(), nullptr,
IID_PPV_ARGS(defaultDirectory.GetAddressOf()))))
{
fileDialog->SetFolder(defaultDirectory.Get());
@@ -185,7 +185,7 @@ namespace OpenRCT2::Ui
PWSTR filePath = nullptr;
if (SUCCEEDED(resultItem->GetDisplayName(SIGDN_FILESYSPATH, &filePath)))
{
resultFilename = String::ToUtf8(filePath);
resultFilename = String::toUtf8(filePath);
CoTaskMemFree(filePath);
}
}
@@ -238,8 +238,8 @@ namespace OpenRCT2::Ui
std::vector<COMDLG_FILTERSPEC> result;
for (const auto& filter : filters)
{
outFiltersStorage.emplace_back(String::ToWideChar(filter.Name));
outFiltersStorage.emplace_back(String::ToWideChar(filter.Pattern));
outFiltersStorage.emplace_back(String::toWideChar(filter.Name));
outFiltersStorage.emplace_back(String::toWideChar(filter.Pattern));
}
for (auto it = outFiltersStorage.begin(); it != outFiltersStorage.end();)
+1 -1
View File
@@ -55,7 +55,7 @@ namespace OpenRCT2::Audio
int32_t numDevices = SDL_GetNumAudioDevices(SDL_FALSE);
for (int32_t i = 0; i < numDevices; i++)
{
devices.emplace_back(String::ToStd(SDL_GetAudioDeviceName(i, SDL_FALSE)));
devices.emplace_back(String::toStd(SDL_GetAudioDeviceName(i, SDL_FALSE)));
}
return devices;
}
+20 -20
View File
@@ -24,51 +24,51 @@ constexpr uint32_t UsefulModifiers = KMOD_SHIFT | KMOD_CTRL | KMOD_ALT | KMOD_GU
static uint32_t ParseModifier(std::string_view text)
{
if (String::IEquals(text, "CTRL"))
if (String::iequals(text, "CTRL"))
{
return KMOD_CTRL;
}
if (String::IEquals(text, "LCTRL"))
if (String::iequals(text, "LCTRL"))
{
return KMOD_LCTRL;
}
if (String::IEquals(text, "RCTRL"))
if (String::iequals(text, "RCTRL"))
{
return KMOD_RCTRL;
}
if (String::IEquals(text, "SHIFT"))
if (String::iequals(text, "SHIFT"))
{
return KMOD_SHIFT;
}
if (String::IEquals(text, "LSHIFT"))
if (String::iequals(text, "LSHIFT"))
{
return KMOD_LSHIFT;
}
if (String::IEquals(text, "RSHIFT"))
if (String::iequals(text, "RSHIFT"))
{
return KMOD_RSHIFT;
}
if (String::IEquals(text, "ALT"))
if (String::iequals(text, "ALT"))
{
return KMOD_ALT;
}
if (String::IEquals(text, "LALT"))
if (String::iequals(text, "LALT"))
{
return KMOD_LALT;
}
if (String::IEquals(text, "RALT"))
if (String::iequals(text, "RALT"))
{
return KMOD_RALT;
}
if (String::IEquals(text, "GUI"))
if (String::iequals(text, "GUI"))
{
return KMOD_GUI;
}
if (String::IEquals(text, "LCTRL"))
if (String::iequals(text, "LCTRL"))
{
return KMOD_LGUI;
}
if (String::IEquals(text, "RGUI"))
if (String::iequals(text, "RGUI"))
{
return KMOD_RGUI;
}
@@ -119,28 +119,28 @@ ShortcutInput::ShortcutInput(std::string_view value)
}
auto rem = value.substr(index);
if (String::StartsWith(rem, "JOY ", true))
if (String::startsWith(rem, "JOY ", true))
{
rem = rem.substr(4);
if (String::Equals(rem, "LEFT"))
if (String::equals(rem, "LEFT"))
{
Kind = InputDeviceKind::JoyHat;
Modifiers = modifiers;
Button = SDL_HAT_LEFT;
}
else if (String::Equals(rem, "RIGHT"))
else if (String::equals(rem, "RIGHT"))
{
Kind = InputDeviceKind::JoyHat;
Modifiers = modifiers;
Button = SDL_HAT_RIGHT;
}
else if (String::Equals(rem, "UP"))
else if (String::equals(rem, "UP"))
{
Kind = InputDeviceKind::JoyHat;
Modifiers = modifiers;
Button = SDL_HAT_UP;
}
else if (String::Equals(rem, "DOWN"))
else if (String::equals(rem, "DOWN"))
{
Kind = InputDeviceKind::JoyHat;
Modifiers = modifiers;
@@ -157,7 +157,7 @@ ShortcutInput::ShortcutInput(std::string_view value)
}
}
}
else if (String::StartsWith(rem, "MOUSE ", true))
else if (String::startsWith(rem, "MOUSE ", true))
{
rem = rem.substr(6);
auto number = String::Parse<int32_t>(rem);
@@ -168,13 +168,13 @@ ShortcutInput::ShortcutInput(std::string_view value)
Button = *number - 1;
}
}
else if (String::IEquals(rem, "LMB"))
else if (String::iequals(rem, "LMB"))
{
Kind = InputDeviceKind::Mouse;
Modifiers = modifiers;
Button = 0;
}
else if (String::IEquals(rem, "RMB"))
else if (String::iequals(rem, "RMB"))
{
Kind = InputDeviceKind::Mouse;
Modifiers = modifiers;
+3 -3
View File
@@ -273,7 +273,7 @@ static constexpr UIThemeWindowEntry PredefinedThemeRCT1_Entries[] =
{
for (const auto& desc : WindowThemeDescriptors)
{
if (String::Equals(desc.WindowClassSZ, windowClassSZ))
if (String::equals(desc.WindowClassSZ, windowClassSZ))
{
return &desc;
}
@@ -625,7 +625,7 @@ static constexpr UIThemeWindowEntry PredefinedThemeRCT1_Entries[] =
for (size_t i = 0; i < ThemeManager::AvailableThemes.size(); i++)
{
const auto& theme = ThemeManager::AvailableThemes[i];
if (String::Equals(name, theme.Name))
if (String::equals(name, theme.Name))
{
if (theme.Path.empty())
{
@@ -752,7 +752,7 @@ static constexpr UIThemeWindowEntry PredefinedThemeRCT1_Entries[] =
for (size_t i = 0; i < count; i++)
{
const utf8* tn = ThemeManagerGetAvailableThemeName(i);
if (String::IEquals(tn, name))
if (String::iequals(tn, name))
{
return i;
}
+1 -1
View File
@@ -305,7 +305,7 @@ bool CustomListView::SortItem(size_t indexA, size_t indexB, int32_t column)
{
const auto& cellA = Items[indexA].Cells[column];
const auto& cellB = Items[indexB].Cells[column];
return String::StrLogicalCmp(cellA.c_str(), cellB.c_str()) < 0;
return String::logicalCmp(cellA.c_str(), cellB.c_str()) < 0;
}
void CustomListView::SortItems(int32_t column)
@@ -110,7 +110,7 @@ namespace OpenRCT2::Scripting
}
else if constexpr (std::is_same_v<T, LoadScenarioCommand>)
{
obj.Set("scenario", String::ToStringView(command.Scenario, sizeof(command.Scenario)));
obj.Set("scenario", String::toStringView(command.Scenario, sizeof(command.Scenario)));
}
},
value);
@@ -170,7 +170,7 @@ namespace OpenRCT2::Scripting
case TitleScript::LoadSc:
{
auto loadScenarioCommand = LoadScenarioCommand{};
String::Set(
String::set(
loadScenarioCommand.Scenario, sizeof(loadScenarioCommand.Scenario), value["scenario"].as_c_string());
command = loadScenarioCommand;
break;
+1 -1
View File
@@ -163,7 +163,7 @@ namespace OpenRCT2::Ui::Windows
switch (widgetIndex)
{
case WIDX_SYMBOL_TEXT:
String::SafeStrCpy(
String::safeUtf8Copy(
CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, std::string(text).c_str(),
kCurrencySymbolMaxSize);
@@ -775,7 +775,7 @@ namespace OpenRCT2::Ui::Windows
width_limit /= 2;
// Draw ride type
StringId rideTypeStringId = GetRideTypeStringId(listItem.repositoryItem);
String::SafeStrCpy(buffer, LanguageGetString(rideTypeStringId), 256 - (buffer - bufferWithColour));
String::safeUtf8Copy(buffer, LanguageGetString(rideTypeStringId), 256 - (buffer - bufferWithColour));
auto ft = Formatter();
ft.Add<const char*>(itemBuffer);
DrawTextEllipsised(
@@ -784,7 +784,7 @@ namespace OpenRCT2::Ui::Windows
}
// Draw text
String::SafeStrCpy(buffer, listItem.repositoryItem->Name.c_str(), 256 - (buffer - bufferWithColour));
String::safeUtf8Copy(buffer, listItem.repositoryItem->Name.c_str(), 256 - (buffer - bufferWithColour));
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
{
while (*buffer != 0 && *buffer != 9)
@@ -826,7 +826,7 @@ namespace OpenRCT2::Ui::Windows
if (strcmp(_filter_string, c) == 0)
return;
String::SafeStrCpy(_filter_string, c, sizeof(_filter_string));
String::safeUtf8Copy(_filter_string, c, sizeof(_filter_string));
FilterUpdateCounts();
@@ -1410,7 +1410,7 @@ namespace OpenRCT2::Ui::Windows
static bool IsFilterInName(const ObjectRepositoryItem& item, std::string_view filter)
{
return String::Contains(item.Name, filter, true);
return String::contains(item.Name, filter, true);
}
static bool IsFilterInRideType(const ObjectRepositoryItem& item, std::string_view filter)
@@ -1418,7 +1418,7 @@ namespace OpenRCT2::Ui::Windows
if (item.Type == ObjectType::Ride)
{
auto rideTypeName = LanguageGetString(GetRideTypeStringId(&item));
if (String::Contains(rideTypeName, filter, true))
if (String::contains(rideTypeName, filter, true))
return true;
}
return false;
@@ -1426,14 +1426,14 @@ namespace OpenRCT2::Ui::Windows
static bool IsFilterInFilename(const ObjectRepositoryItem& item, std::string_view filter)
{
return String::Contains(item.Path, filter, true);
return String::contains(item.Path, filter, true);
}
static bool IsFilterInAuthor(const ObjectRepositoryItem& item, std::string_view filter)
{
for (auto& author : item.Authors)
{
if (String::Contains(author, filter, true))
if (String::contains(author, filter, true))
{
return true;
}
@@ -1622,7 +1622,7 @@ namespace OpenRCT2::Ui::Windows
{
auto rideTypeA = LanguageGetString(GetRideTypeStringId(a.repositoryItem));
auto rideTypeB = LanguageGetString(GetRideTypeStringId(b.repositoryItem));
int32_t result = String::Compare(rideTypeA, rideTypeB);
int32_t result = String::compare(rideTypeA, rideTypeB);
return result != 0 ? result < 0 : VisibleListSortRideName(a, b);
}
+2 -2
View File
@@ -1832,14 +1832,14 @@ namespace OpenRCT2::Ui::Windows
if (peep->GetNextIsSurface())
{
OpenRCT2::FormatStringLegacy(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SURFACE, nullptr);
String::SafeStrCat(buffer, buffer2, sizeof(buffer));
String::safeConcat(buffer, buffer2, sizeof(buffer));
}
if (peep->GetNextIsSloped())
{
auto ft2 = Formatter();
ft2.Add<int32_t>(peep->GetNextDirection());
OpenRCT2::FormatStringLegacy(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SLOPE, ft2.Data());
String::SafeStrCat(buffer, buffer2, sizeof(buffer));
String::safeConcat(buffer, buffer2, sizeof(buffer));
}
DrawText(dpi, screenCoords, {}, buffer);
}
+2 -2
View File
@@ -794,7 +794,7 @@ namespace OpenRCT2::Ui::Windows
Formatter ft;
peep.FormatNameTo(ft);
OpenRCT2::FormatStringLegacy(name, sizeof(name), STR_STRINGID, ft.Data());
if (!String::Contains(name, _filterName.c_str(), true))
if (!String::contains(name, _filterName.c_str(), true))
{
return false;
}
@@ -957,7 +957,7 @@ namespace OpenRCT2::Ui::Windows
}
}
}
return String::StrLogicalCmp(a.Name, b.Name) < 0;
return String::logicalCmp(a.Name, b.Name) < 0;
}
static GuestItem::CompareFunc GetGuestCompareFunc()
+12 -12
View File
@@ -121,15 +121,15 @@ namespace OpenRCT2::Ui::Windows
switch (Config::Get().general.LoadSaveSort)
{
case Sort::NameAscending:
return String::StrLogicalCmp(a.name.c_str(), b.name.c_str()) < 0;
return String::logicalCmp(a.name.c_str(), b.name.c_str()) < 0;
case Sort::NameDescending:
return -String::StrLogicalCmp(a.name.c_str(), b.name.c_str()) < 0;
return -String::logicalCmp(a.name.c_str(), b.name.c_str()) < 0;
case Sort::DateDescending:
return -difftime(a.date_modified, b.date_modified) < 0;
case Sort::DateAscending:
return difftime(a.date_modified, b.date_modified) < 0;
}
return String::StrLogicalCmp(a.name.c_str(), b.name.c_str()) < 0;
return String::logicalCmp(a.name.c_str(), b.name.c_str()) < 0;
}
static void SetAndSaveConfigPath(u8string& config_str, u8string_view path)
@@ -264,7 +264,7 @@ namespace OpenRCT2::Ui::Windows
}
char pathBuffer[MAX_PATH];
String::SafeStrCpy(pathBuffer, path, sizeof(pathBuffer));
String::safeUtf8Copy(pathBuffer, path, sizeof(pathBuffer));
// Closing this will cause a Ride window to pop up, so we have to do this to ensure that
// no windows are open (besides the toolbars and LoadSave window).
@@ -330,7 +330,7 @@ namespace OpenRCT2::Ui::Windows
case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE):
SetAndSaveConfigPath(Config::Get().general.LastSaveLandscapeDirectory, pathBuffer);
gameState.ScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
gameState.ScenarioFileName = std::string(String::toStringView(pathBuffer, std::size(pathBuffer)));
if (ScenarioSave(gameState, pathBuffer, Config::Get().general.SavePluginData ? 3 : 2))
{
gCurrentLoadedPath = pathBuffer;
@@ -351,7 +351,7 @@ namespace OpenRCT2::Ui::Windows
int32_t parkFlagsBackup = gameState.Park.Flags;
gameState.Park.Flags &= ~PARK_FLAGS_SPRITES_INITIALISED;
gameState.EditorStep = EditorStep::Invalid;
gameState.ScenarioFileName = std::string(String::ToStringView(pathBuffer, std::size(pathBuffer)));
gameState.ScenarioFileName = std::string(String::toStringView(pathBuffer, std::size(pathBuffer)));
int32_t success = ScenarioSave(gameState, pathBuffer, Config::Get().general.SavePluginData ? 3 : 2);
gameState.Park.Flags = parkFlagsBackup;
@@ -388,7 +388,7 @@ namespace OpenRCT2::Ui::Windows
SetAndSaveConfigPath(Config::Get().general.LastSaveTrackDirectory, pathBuffer);
const auto withExtension = Path::WithExtension(pathBuffer, ".td6");
String::Set(pathBuffer, sizeof(pathBuffer), withExtension.c_str());
String::set(pathBuffer, sizeof(pathBuffer), withExtension.c_str());
RCT2::T6Exporter t6Export{ *_trackDesign };
@@ -501,7 +501,7 @@ namespace OpenRCT2::Ui::Windows
void PopulateList(int32_t includeNewItem, const u8string& directory, std::string_view extensionPattern)
{
const auto absoluteDirectory = Path::GetAbsolute(directory);
String::SafeStrCpy(_directory, absoluteDirectory.c_str(), std::size(_directory));
String::safeUtf8Copy(_directory, absoluteDirectory.c_str(), std::size(_directory));
// Note: This compares the pointers, not values
_extensionPattern = extensionPattern;
@@ -534,7 +534,7 @@ namespace OpenRCT2::Ui::Windows
else
{
// Remove the separator at the end of the path, if present
String::SafeStrCpy(_parentDirectory, absoluteDirectory.c_str(), std::size(_parentDirectory));
String::safeUtf8Copy(_parentDirectory, absoluteDirectory.c_str(), std::size(_parentDirectory));
if (_parentDirectory[strlen(_parentDirectory) - 1] == *PATH_SEPARATOR
|| _parentDirectory[strlen(_parentDirectory) - 1] == '/')
_parentDirectory[strlen(_parentDirectory) - 1] = '\0';
@@ -559,7 +559,7 @@ namespace OpenRCT2::Ui::Windows
}
// Disable the Up button if the current directory is the root directory
if (String::IsNullOrEmpty(_parentDirectory) && !drives)
if (String::isNullOrEmpty(_parentDirectory) && !drives)
disabled_widgets |= (1uLL << WIDX_UP);
else
disabled_widgets &= ~(1uLL << WIDX_UP);
@@ -585,7 +585,7 @@ namespace OpenRCT2::Ui::Windows
// List all files with the wanted extensions
bool showExtension = false;
for (const u8string& extToken : String::Split(extensionPattern, ";"))
for (const u8string& extToken : String::split(extensionPattern, ";"))
{
const u8string filter = Path::Combine(directory, extToken);
auto scanner = Path::ScanDirectory(filter, false);
@@ -960,7 +960,7 @@ namespace OpenRCT2::Ui::Windows
includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
char directory[MAX_PATH];
String::SafeStrCpy(directory, _listItems[selectedItem].path.c_str(), sizeof(directory));
String::safeUtf8Copy(directory, _listItems[selectedItem].path.c_str(), sizeof(directory));
PopulateList(includeNewItem, directory, _extensionPattern);
InitScrollWidgets();
+1 -1
View File
@@ -102,7 +102,7 @@ namespace OpenRCT2::Ui::Windows
if (rideB != nullptr)
rideBName = rideB->GetName();
return String::StrLogicalCmp(rideAName.c_str(), rideBName.c_str()) < 0;
return String::logicalCmp(rideAName.c_str(), rideBName.c_str()) < 0;
}
/**
+5 -5
View File
@@ -756,13 +756,13 @@ namespace OpenRCT2::Ui::Windows
bool IsFilterInRideType(const RideObjectEntry& rideEntry)
{
auto rideTypeName = GetRideNaming(rideEntry.ride_type[0], rideEntry).Name;
return String::Contains(u8string_view(LanguageGetString(rideTypeName)), _filter, true);
return String::contains(u8string_view(LanguageGetString(rideTypeName)), _filter, true);
}
bool IsFilterInRideName(const RideObjectEntry& rideEntry)
{
auto rideName = rideEntry.naming.Name;
return String::Contains(u8string_view(LanguageGetString(rideName)), _filter, true);
return String::contains(u8string_view(LanguageGetString(rideName)), _filter, true);
}
bool IsFilterInAuthors(const RideObject& rideObject)
@@ -770,7 +770,7 @@ namespace OpenRCT2::Ui::Windows
auto& authors = rideObject.GetAuthors();
for (auto& author : authors)
if (String::Contains(author, _filter, true))
if (String::contains(author, _filter, true))
return true;
return false;
@@ -780,14 +780,14 @@ namespace OpenRCT2::Ui::Windows
{
auto objectName = rideObject.GetObjectEntry().GetName();
return String::Contains(objectName, _filter, true);
return String::contains(objectName, _filter, true);
}
bool IsFilterInFilename(const RideObject& rideObject)
{
auto repoItem = ObjectRepositoryFindObjectByEntry(&(rideObject.GetObjectEntry()));
return String::Contains(repoItem->Path, _filter, true);
return String::contains(repoItem->Path, _filter, true);
}
void SetPressedTab()
+2 -2
View File
@@ -208,7 +208,7 @@ namespace OpenRCT2::Ui::Windows
}
auto& entry = _entries[_currentDownloadIndex];
auto name = String::Trim(std::string(entry.GetName()));
auto name = String::trim(std::string(entry.GetName()));
LOG_VERBOSE("Downloading object: [%s]:", name.c_str());
_currentDownloadIndex++;
UpdateProgress({ name, _lastDownloadSource, _currentDownloadIndex, _entries.size() });
@@ -541,7 +541,7 @@ namespace OpenRCT2::Ui::Windows
auto name = entry.GetName();
char buffer[256];
String::Set(buffer, sizeof(buffer), name.data(), name.size());
String::set(buffer, sizeof(buffer), name.data(), name.size());
DrawText(dpi, screenCoords, { COLOUR_DARK_GREEN }, buffer);
if (entry.Generation == ObjectGeneration::DAT)
+1 -1
View File
@@ -5117,7 +5117,7 @@ namespace OpenRCT2::Ui::Windows
// Sort available music by the alphabetical order
std::stable_sort(musicOrder.begin(), musicOrder.end(), [](const ObjectEntryIndex& a, const ObjectEntryIndex& b) {
return String::Compare(GetMusicString(b), GetMusicString(a), false) > 0;
return String::compare(GetMusicString(b), GetMusicString(a), false) > 0;
});
// Setup dropdown list
+1 -1
View File
@@ -809,7 +809,7 @@ namespace OpenRCT2::Ui::Windows
void SortListByName()
{
std::sort(_rideList.begin(), _rideList.end(), [](const auto& lhs, const auto& rhs) {
return !(0 <= String::StrLogicalCmp(lhs.Name.c_str(), rhs.Name.c_str()));
return !(0 <= String::logicalCmp(lhs.Name.c_str(), rhs.Name.c_str()));
});
}
+1 -1
View File
@@ -445,7 +445,7 @@ namespace OpenRCT2::Ui::Windows
// Draw scenario name
char buffer[64];
String::SafeStrCpy(buffer, scenario->Name, sizeof(buffer));
String::safeUtf8Copy(buffer, scenario->Name, sizeof(buffer));
StringId format = isDisabled ? static_cast<StringId>(STR_STRINGID)
: (isHighlighted ? highlighted_format : unhighlighted_format);
auto ft = Formatter();
+4 -4
View File
@@ -1301,13 +1301,13 @@ namespace OpenRCT2::Ui::Windows
bool IsFilterInName(const Object& object)
{
return String::Contains(object.GetName(), _filteredSceneryTab.Filter, true);
return String::contains(object.GetName(), _filteredSceneryTab.Filter, true);
}
bool IsFilterInAuthors(const Object& object)
{
for (auto author : object.GetAuthors())
if (String::Contains(author, _filteredSceneryTab.Filter, true))
if (String::contains(author, _filteredSceneryTab.Filter, true))
return true;
return false;
@@ -1315,13 +1315,13 @@ namespace OpenRCT2::Ui::Windows
bool IsFilterInIdentifier(const Object& object)
{
return String::Contains(object.GetIdentifier(), _filteredSceneryTab.Filter, true);
return String::contains(object.GetIdentifier(), _filteredSceneryTab.Filter, true);
}
bool IsFilterInFilename(const Object& object)
{
auto repoItem = ObjectRepositoryFindObjectByEntry(&(object.GetObjectEntry()));
return String::Contains(repoItem->Path, _filteredSceneryTab.Filter, true);
return String::contains(repoItem->Path, _filteredSceneryTab.Filter, true);
}
void SortTabs()
+8 -8
View File
@@ -84,9 +84,9 @@ namespace OpenRCT2::Ui::Windows
list_information_type = 0;
snprintf(_port, 7, "%u", Config::Get().network.DefaultPort);
String::SafeStrCpy(_name, Config::Get().network.ServerName.c_str(), sizeof(_name));
String::SafeStrCpy(_description, Config::Get().network.ServerDescription.c_str(), sizeof(_description));
String::SafeStrCpy(_greeting, Config::Get().network.ServerGreeting.c_str(), sizeof(_greeting));
String::safeUtf8Copy(_name, Config::Get().network.ServerName.c_str(), sizeof(_name));
String::safeUtf8Copy(_description, Config::Get().network.ServerDescription.c_str(), sizeof(_description));
String::safeUtf8Copy(_greeting, Config::Get().network.ServerGreeting.c_str(), sizeof(_greeting));
}
void OnMouseUp(WidgetIndex widgetIndex) override
{
@@ -175,7 +175,7 @@ namespace OpenRCT2::Ui::Windows
if (strcmp(_port, temp.c_str()) == 0)
return;
String::SafeStrCpy(_port, temp.c_str(), sizeof(_port));
String::safeUtf8Copy(_port, temp.c_str(), sizeof(_port));
// Don't allow negative/zero for port number
tempPort = atoi(_port);
@@ -191,7 +191,7 @@ namespace OpenRCT2::Ui::Windows
if (strcmp(_name, temp.c_str()) == 0)
return;
String::SafeStrCpy(_name, temp.c_str(), sizeof(_name));
String::safeUtf8Copy(_name, temp.c_str(), sizeof(_name));
// Don't allow empty server names
if (_name[0] != '\0')
@@ -206,7 +206,7 @@ namespace OpenRCT2::Ui::Windows
if (strcmp(_description, temp.c_str()) == 0)
return;
String::SafeStrCpy(_description, temp.c_str(), sizeof(_description));
String::safeUtf8Copy(_description, temp.c_str(), sizeof(_description));
Config::Get().network.ServerDescription = _description;
Config::Save();
@@ -216,7 +216,7 @@ namespace OpenRCT2::Ui::Windows
if (strcmp(_greeting, temp.c_str()) == 0)
return;
String::SafeStrCpy(_greeting, temp.c_str(), sizeof(_greeting));
String::safeUtf8Copy(_greeting, temp.c_str(), sizeof(_greeting));
Config::Get().network.ServerGreeting = _greeting;
Config::Save();
@@ -226,7 +226,7 @@ namespace OpenRCT2::Ui::Windows
if (strcmp(_password, temp.c_str()) == 0)
return;
String::SafeStrCpy(_password, temp.c_str(), sizeof(_password));
String::safeUtf8Copy(_password, temp.c_str(), sizeof(_password));
WidgetInvalidate(*this, WIDX_PASSWORD_INPUT);
break;
+1 -1
View File
@@ -517,7 +517,7 @@ namespace OpenRCT2::Ui::Windows
}
std::sort(_staffList.begin(), _staffList.end(), [](const auto& a, const auto& b) {
return String::StrLogicalCmp(a.Name.c_str(), b.Name.c_str()) < 0;
return String::logicalCmp(a.Name.c_str(), b.Name.c_str()) < 0;
});
}
+2 -2
View File
@@ -109,7 +109,7 @@ namespace OpenRCT2::Ui::Windows
void SetText(std::string_view text, size_t maxLength)
{
text = String::UTF8TruncateCodePoints(text, maxLength);
text = String::utf8TruncateCodePoints(text, maxLength);
_buffer = u8string{ text };
_maxInputLength = maxLength;
SetTexboxSession(ContextStartTextInput(_buffer, maxLength));
@@ -291,7 +291,7 @@ namespace OpenRCT2::Ui::Windows
}
// IME composition
if (!String::IsNullOrEmpty(textInput->ImeBuffer))
if (!String::isNullOrEmpty(textInput->ImeBuffer))
{
IMEComposition(cursorX, cursorY);
}
+1 -1
View File
@@ -492,7 +492,7 @@ namespace OpenRCT2::Ui::Windows
std::string url = "https://github.com/OpenRCT2/OpenRCT2/issues/new?"
"assignees=&labels=bug&template=bug_report.yaml";
// Automatically fill the "OpenRCT2 build" input
auto versionStr = String::URLEncode(gVersionInfoFull);
auto versionStr = String::urlEncode(gVersionInfoFull);
url.append("&f299dd2a20432827d99b648f73eb4649b23f8ec98d158d6f82b81e43196ee36b=" + versionStr);
OpenRCT2::GetContext()->GetUiContext()->OpenURL(url);
}
+7 -7
View File
@@ -87,7 +87,7 @@ namespace OpenRCT2::Ui::Windows
_filteredTrackIds.clear();
// Nothing to filter, so fill the list with all indices
if (String::LengthOf(_filterString) == 0)
if (String::lengthOf(_filterString) == 0)
{
for (uint16_t i = 0; i < _trackDesigns.size(); i++)
_filteredTrackIds.push_back(i);
@@ -96,12 +96,12 @@ namespace OpenRCT2::Ui::Windows
}
// Convert filter to uppercase
const auto filterStringUpper = String::ToUpper(_filterString);
const auto filterStringUpper = String::toUpper(_filterString);
// Fill the set with indices for tracks that match the filter
for (uint16_t i = 0; i < _trackDesigns.size(); i++)
{
const auto trackNameUpper = String::ToUpper(_trackDesigns[i].name);
const auto trackNameUpper = String::toUpper(_trackDesigns[i].name);
if (trackNameUpper.find(filterStringUpper) != std::string::npos)
{
_filteredTrackIds.push_back(i);
@@ -215,7 +215,7 @@ namespace OpenRCT2::Ui::Windows
void OnOpen() override
{
String::Set(_filterString, sizeof(_filterString), "");
String::set(_filterString, sizeof(_filterString), "");
_trackListWidgets[WIDX_FILTER_STRING].string = _filterString;
widgets = _trackListWidgets;
@@ -313,7 +313,7 @@ namespace OpenRCT2::Ui::Windows
selected_list_item = _filteredTrackIds[selected_list_item - 1] + 1;
}
String::Set(_filterString, sizeof(_filterString), "");
String::set(_filterString, sizeof(_filterString), "");
FilterList();
Invalidate();
break;
@@ -363,10 +363,10 @@ namespace OpenRCT2::Ui::Windows
if (widgetIndex != WIDX_FILTER_STRING)
return;
if (String::Equals(_filterString, std::string(text).c_str()))
if (String::equals(_filterString, std::string(text).c_str()))
return;
String::Set(_filterString, sizeof(_filterString), std::string(text).c_str());
String::set(_filterString, sizeof(_filterString), std::string(text).c_str());
FilterList();
+1 -1
View File
@@ -54,7 +54,7 @@ static std::vector<std::string> GetCommandLineArgs(int argc, wchar_t** argvW)
std::vector<std::string> argv;
for (int i = 0; i < argc; i++)
{
argv.push_back(String::ToUtf8(argvW[i]));
argv.push_back(String::toUtf8(argvW[i]));
}
return argv;
}
+1 -1
View File
@@ -87,7 +87,7 @@ void AssetPackManager::Scan(const fs::path& directory)
if (!entry.is_directory())
{
auto path = entry.path().u8string();
if (String::EndsWith(path, ".parkap", true))
if (String::endsWith(path, ".parkap", true))
{
AddAssetPack(path);
}
+8 -8
View File
@@ -263,7 +263,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
if (argc == 0)
return -1;
if (String::IEquals(argv[0], "details"))
if (String::iequals(argv[0], "details"))
{
if (argc < 2)
{
@@ -310,7 +310,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
return 1;
}
if (String::IEquals(argv[0], "export"))
if (String::iequals(argv[0], "export"))
{
if (argc < 4)
{
@@ -344,7 +344,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
return 1;
}
if (String::IEquals(argv[0], "exportall"))
if (String::iequals(argv[0], "exportall"))
{
if (argc < 3)
{
@@ -389,7 +389,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
return 1;
}
if (String::IEquals(argv[0], "exportalldat"))
if (String::iequals(argv[0], "exportalldat"))
{
if (argc < 3)
{
@@ -450,7 +450,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
return 1;
}
if (String::IEquals(argv[0], "create"))
if (String::iequals(argv[0], "create"))
{
if (argc < 2)
{
@@ -465,7 +465,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
return 1;
}
if (String::IEquals(argv[0], "append"))
if (String::iequals(argv[0], "append"))
{
if (argc != 3 && argc != 5)
{
@@ -518,7 +518,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
return 1;
}
if (String::IEquals(argv[0], "build"))
if (String::iequals(argv[0], "build"))
{
if (argc < 3)
{
@@ -600,7 +600,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc)
return 1;
}
if (String::IEquals(argv[0], "combine"))
if (String::iequals(argv[0], "combine"))
{
return CommandLineForSpriteCombine(argv, argc);
}
+4 -4
View File
@@ -413,7 +413,7 @@ namespace OpenRCT2
CrashInit();
if (String::Equals(Config::Get().general.LastRunVersion, OPENRCT2_VERSION))
if (String::equals(Config::Get().general.LastRunVersion, OPENRCT2_VERSION))
{
gOpenRCT2ShowChangelog = false;
}
@@ -717,7 +717,7 @@ namespace OpenRCT2
try
{
if (String::IEquals(Path::GetExtension(path), ".sea"))
if (String::iequals(Path::GetExtension(path), ".sea"))
{
auto data = DecryptSea(fs::u8path(path));
auto ms = MemoryStream(data.data(), data.size(), MEMORY_ACCESS::READ);
@@ -1104,7 +1104,7 @@ namespace OpenRCT2
case StartupAction::Edit:
{
if (String::SizeOf(gOpenRCT2StartupActionPath) == 0)
if (String::sizeOf(gOpenRCT2StartupActionPath) == 0)
{
Editor::Load();
nextScene = GetGameScene();
@@ -1186,7 +1186,7 @@ namespace OpenRCT2
{
_versionCheckFuture = std::async(std::launch::async, [this] {
_newVersionInfo = GetLatestVersion();
if (!String::StartsWith(gVersionInfoTag, _newVersionInfo.tag))
if (!String::startsWith(gVersionInfoTag, _newVersionInfo.tag))
{
_hasNewVersionInfo = true;
}
+5 -5
View File
@@ -94,11 +94,11 @@ void DiagnosticLog(DiagnosticLevel diagnosticLevel, const char* format, ...)
if (_log_levels[EnumValue(diagnosticLevel)])
{
// Level
auto prefix = String::StdFormat("%s: ", _level_strings[EnumValue(diagnosticLevel)]);
auto prefix = String::stdFormat("%s: ", _level_strings[EnumValue(diagnosticLevel)]);
// Message
va_start(args, format);
auto msg = String::Format_VA(format, args);
auto msg = String::formatVA(format, args);
va_end(args);
DiagnosticPrint(diagnosticLevel, prefix, msg);
@@ -115,16 +115,16 @@ void DiagnosticLogWithLocation(
std::string prefix;
if (_log_location_enabled)
{
prefix = String::StdFormat("%s[%s:%d (%s)]: ", _level_strings[EnumValue(diagnosticLevel)], file, line, function);
prefix = String::stdFormat("%s[%s:%d (%s)]: ", _level_strings[EnumValue(diagnosticLevel)], file, line, function);
}
else
{
prefix = String::StdFormat("%s: ", _level_strings[EnumValue(diagnosticLevel)]);
prefix = String::stdFormat("%s: ", _level_strings[EnumValue(diagnosticLevel)]);
}
// Message
va_start(args, format);
auto msg = String::Format_VA(format, args);
auto msg = String::formatVA(format, args);
va_end(args);
DiagnosticPrint(diagnosticLevel, prefix, msg);
+10 -10
View File
@@ -201,25 +201,25 @@ static bool TryClassifyAsTD4_TD6(OpenRCT2::IStream* stream, ClassifiedFileInfo*
FileExtension GetFileExtensionType(u8string_view path)
{
auto extension = Path::GetExtension(path);
if (String::IEquals(extension, ".dat") || String::IEquals(extension, ".pob"))
if (String::iequals(extension, ".dat") || String::iequals(extension, ".pob"))
return FileExtension::DAT;
if (String::IEquals(extension, ".sc4"))
if (String::iequals(extension, ".sc4"))
return FileExtension::SC4;
if (String::IEquals(extension, ".sv4"))
if (String::iequals(extension, ".sv4"))
return FileExtension::SV4;
if (String::IEquals(extension, ".td4"))
if (String::iequals(extension, ".td4"))
return FileExtension::TD4;
if (String::IEquals(extension, ".sc6"))
if (String::iequals(extension, ".sc6"))
return FileExtension::SC6;
if (String::IEquals(extension, ".sea"))
if (String::iequals(extension, ".sea"))
return FileExtension::SC6;
if (String::IEquals(extension, ".sv6"))
if (String::iequals(extension, ".sv6"))
return FileExtension::SV6;
if (String::IEquals(extension, ".sv7"))
if (String::iequals(extension, ".sv7"))
return FileExtension::SV6;
if (String::IEquals(extension, ".td6"))
if (String::iequals(extension, ".td6"))
return FileExtension::TD6;
if (String::IEquals(extension, ".park"))
if (String::iequals(extension, ".park"))
return FileExtension::PARK;
return FileExtension::Unknown;
}
+1 -1
View File
@@ -173,7 +173,7 @@ void RCT2StringToUTF8Self(char* buffer, size_t length)
if (length > 0)
{
auto temp = RCT2StringToUTF8(buffer, RCT2LanguageId::EnglishUK);
String::SafeStrCpy(buffer, temp.data(), length);
String::safeUtf8Copy(buffer, temp.data(), length);
}
}
+3 -3
View File
@@ -41,16 +41,16 @@ namespace OpenRCT2::ParkImporter
bool ExtensionIsOpenRCT2ParkFile(std::string_view extension)
{
return String::IEquals(extension, ".park");
return String::iequals(extension, ".park");
}
bool ExtensionIsRCT1(std::string_view extension)
{
return String::IEquals(extension, ".sc4") || String::IEquals(extension, ".sv4");
return String::iequals(extension, ".sc4") || String::iequals(extension, ".sv4");
}
bool ExtensionIsScenario(std::string_view extension)
{
return String::IEquals(extension, ".sc4") || String::IEquals(extension, ".sc6") || String::IEquals(extension, ".sea");
return String::iequals(extension, ".sc4") || String::iequals(extension, ".sc6") || String::iequals(extension, ".sea");
}
} // namespace OpenRCT2::ParkImporter
+1 -1
View File
@@ -139,7 +139,7 @@ public:
if (_usingRCTClassic && base == DIRBASE::RCT2 && did == DIRID::DATA)
{
// Special case, handle RCT Classic css ogg files
if (String::StartsWith(fileName, "css", true) && String::EndsWith(fileName, ".dat", true))
if (String::startsWith(fileName, "css", true) && String::endsWith(fileName, ".dat", true))
{
alternativeFilename = fileName.substr(0, fileName.size() - 3);
alternativeFilename.append("ogg");
+1 -1
View File
@@ -33,6 +33,6 @@ namespace OpenRCT2::TrackImporter
bool ExtensionIsRCT1(const std::string& extension)
{
return String::IEquals(extension, ".td4");
return String::iequals(extension, ".td4");
}
} // namespace OpenRCT2::TrackImporter
+20 -20
View File
@@ -125,7 +125,7 @@ namespace OpenRCT2::CommandLine
{
if (command->SubCommands != nullptr)
{
size_t commandNameLength = String::LengthOf(command->Name);
size_t commandNameLength = String::lengthOf(command->Name);
for (size_t i = 0; i < commandNameLength; i++)
{
Console::Write("-");
@@ -151,7 +151,7 @@ namespace OpenRCT2::CommandLine
{
// Print usage
const char* usageString = "usage: openrct2 ";
const size_t usageStringLength = String::LengthOf(usageString);
const size_t usageStringLength = String::lengthOf(usageString);
Console::Write(usageString);
// Get the largest command name length and parameter length
@@ -160,8 +160,8 @@ namespace OpenRCT2::CommandLine
const CommandLineCommand* command;
for (command = commands; command->Name != nullptr; command++)
{
maxNameLength = std::max(maxNameLength, String::LengthOf(command->Name));
maxParamsLength = std::max(maxParamsLength, String::LengthOf(command->Parameters));
maxNameLength = std::max(maxNameLength, String::lengthOf(command->Name));
maxParamsLength = std::max(maxParamsLength, String::lengthOf(command->Parameters));
}
for (command = commands; command->Name != nullptr; command++)
@@ -172,12 +172,12 @@ namespace OpenRCT2::CommandLine
}
Console::Write(command->Name);
Console::WriteSpace(maxNameLength - String::LengthOf(command->Name) + 1);
Console::WriteSpace(maxNameLength - String::lengthOf(command->Name) + 1);
if (command->SubCommands == nullptr)
{
Console::Write(command->Parameters);
Console::WriteSpace(maxParamsLength - String::LengthOf(command->Parameters));
Console::WriteSpace(maxParamsLength - String::lengthOf(command->Parameters));
if (command->Options != nullptr)
{
@@ -207,7 +207,7 @@ namespace OpenRCT2::CommandLine
{
char buffer[128];
GetOptionCaption(buffer, sizeof(buffer), option);
size_t optionCaptionLength = String::LengthOf(buffer);
size_t optionCaptionLength = String::lengthOf(buffer);
maxOptionLength = std::max(maxOptionLength, optionCaptionLength);
}
@@ -218,7 +218,7 @@ namespace OpenRCT2::CommandLine
char buffer[128];
GetOptionCaption(buffer, sizeof(buffer), option);
size_t optionCaptionLength = String::LengthOf(buffer);
size_t optionCaptionLength = String::lengthOf(buffer);
Console::Write(buffer);
Console::WriteSpace(maxOptionLength - optionCaptionLength + 4);
@@ -235,7 +235,7 @@ namespace OpenRCT2::CommandLine
const CommandLineExample* example;
for (example = examples; example->Arguments != nullptr; example++)
{
size_t argumentsLength = String::LengthOf(example->Arguments);
size_t argumentsLength = String::lengthOf(example->Arguments);
maxArgumentsLength = std::max(maxArgumentsLength, argumentsLength);
}
@@ -245,7 +245,7 @@ namespace OpenRCT2::CommandLine
Console::Write(" openrct2 ");
Console::Write(example->Arguments);
size_t argumentsLength = String::LengthOf(example->Arguments);
size_t argumentsLength = String::lengthOf(example->Arguments);
Console::WriteSpace(maxArgumentsLength - argumentsLength + 4);
Console::Write(example->Description);
Console::WriteLine();
@@ -260,22 +260,22 @@ namespace OpenRCT2::CommandLine
if (option->ShortName != '\0')
{
String::AppendFormat(buffer, bufferSize, "-%c, ", option->ShortName);
String::appendFormat(buffer, bufferSize, "-%c, ", option->ShortName);
}
String::Append(buffer, bufferSize, "--");
String::Append(buffer, bufferSize, option->LongName);
String::append(buffer, bufferSize, "--");
String::append(buffer, bufferSize, option->LongName);
switch (option->Type)
{
case CMDLINE_TYPE_INTEGER:
String::Append(buffer, bufferSize, "=<int>");
String::append(buffer, bufferSize, "=<int>");
break;
case CMDLINE_TYPE_REAL:
String::Append(buffer, bufferSize, "=<real>");
String::append(buffer, bufferSize, "=<real>");
break;
case CMDLINE_TYPE_STRING:
String::Append(buffer, bufferSize, "=<str>");
String::append(buffer, bufferSize, "=<str>");
break;
}
@@ -306,7 +306,7 @@ namespace OpenRCT2::CommandLine
// If we don't find a command, this should be used
fallback = command;
}
else if (String::Equals(command->Name, firstArgument))
else if (String::equals(command->Name, firstArgument))
{
if (command->SubCommands == nullptr)
{
@@ -373,11 +373,11 @@ namespace OpenRCT2::CommandLine
const char* equalsCh = strchr(argument, '=');
if (equalsCh != nullptr)
{
String::Set(optionName, sizeof(optionName), argument, equalsCh - argument);
String::set(optionName, sizeof(optionName), argument, equalsCh - argument);
}
else
{
String::Set(optionName, sizeof(optionName), argument);
String::set(optionName, sizeof(optionName), argument);
}
// Find a matching option definition
@@ -517,7 +517,7 @@ namespace OpenRCT2::CommandLine
{
for (const CommandLineOptionDefinition* option = options; option->Type != 255; option++)
{
if (String::Equals(option->LongName, longName))
if (String::equals(option->LongName, longName))
{
return option;
}
+4 -4
View File
@@ -245,7 +245,7 @@ exitcode_t HandleNoCommand(CommandLineArgEnumerator* enumerator)
const char* parkUri;
if (enumerator->TryPopString(&parkUri) && parkUri[0] != '-')
{
String::Set(gOpenRCT2StartupActionPath, sizeof(gOpenRCT2StartupActionPath), parkUri);
String::set(gOpenRCT2StartupActionPath, sizeof(gOpenRCT2StartupActionPath), parkUri);
gOpenRCT2StartupAction = StartupAction::Open;
}
@@ -266,7 +266,7 @@ exitcode_t HandleCommandEdit(CommandLineArgEnumerator* enumerator)
Console::Error::WriteLine("Expected path or URL to a saved park.");
return EXITCODE_FAIL;
}
String::Set(gOpenRCT2StartupActionPath, sizeof(gOpenRCT2StartupActionPath), parkUri);
String::set(gOpenRCT2StartupActionPath, sizeof(gOpenRCT2StartupActionPath), parkUri);
gOpenRCT2StartupAction = StartupAction::Edit;
return EXITCODE_CONTINUE;
@@ -302,11 +302,11 @@ exitcode_t HandleCommandHost(CommandLineArgEnumerator* enumerator)
}
gOpenRCT2StartupAction = StartupAction::Open;
String::Set(gOpenRCT2StartupActionPath, sizeof(gOpenRCT2StartupActionPath), parkUri);
String::set(gOpenRCT2StartupActionPath, sizeof(gOpenRCT2StartupActionPath), parkUri);
gNetworkStart = NETWORK_MODE_SERVER;
gNetworkStartPort = _port;
gNetworkStartAddress = String::ToStd(_address);
gNetworkStartAddress = String::toStd(_address);
return EXITCODE_CONTINUE;
}
+2 -2
View File
@@ -51,9 +51,9 @@ const CommandLineCommand CommandLine::SpriteCommands[]
static exitcode_t HandleSprite(CommandLineArgEnumerator* argEnumerator)
{
if (String::IEquals(_mode, SZ_CLOSEST))
if (String::iequals(_mode, SZ_CLOSEST))
gSpriteMode = ImportMode::Closest;
else if (String::IEquals(_mode, SZ_DITHERING))
else if (String::iequals(_mode, SZ_DITHERING))
gSpriteMode = ImportMode::Dithering;
Memory::Free(_mode);
+2 -2
View File
@@ -28,7 +28,7 @@ exitcode_t CommandLine::HandleCommandUri(CommandLineArgEnumerator* enumerator)
const utf8* uri;
if (enumerator->TryPopString(&uri))
{
if (String::StartsWith(uri, "openrct2://"))
if (String::startsWith(uri, "openrct2://"))
{
const utf8* uriCommand = uri + 11;
return HandleUri(uriCommand);
@@ -42,7 +42,7 @@ exitcode_t CommandLine::HandleCommandUri(CommandLineArgEnumerator* enumerator)
static exitcode_t HandleUri(const std::string& uri)
{
exitcode_t result = EXITCODE_CONTINUE;
auto args = String::Split(uri, "/");
auto args = String::split(uri, "/");
if (!args.empty())
{
#ifndef DISABLE_NETWORK
+3 -3
View File
@@ -140,7 +140,7 @@ namespace OpenRCT2::Config
int32_t i = 0;
for (const auto& langDesc : LanguagesDescriptors)
{
if (String::Equals(key.c_str(), langDesc.locale))
if (String::equals(key.c_str(), langDesc.locale))
{
return i;
}
@@ -441,7 +441,7 @@ namespace OpenRCT2::Config
// Trim any whitespace before or after the player's name,
// to avoid people pretending to be someone else
playerName = String::Trim(playerName);
playerName = String::trim(playerName);
auto model = &_config.network;
model->PlayerName = std::move(playerName);
@@ -774,7 +774,7 @@ namespace OpenRCT2::Config
return false;
}
int32_t exit_status = Platform::Execute(
String::StdFormat(
String::stdFormat(
"%s '%s' --exclude-temp --output-dir '%s'", path.c_str(), installerPath.c_str(), targetPath.c_str()),
&output);
LOG_INFO("Exit status %d", exit_status);
+1 -1
View File
@@ -64,7 +64,7 @@ public:
{
for (const auto& entry : _entries)
{
if (OpenRCT2::String::IEquals(entry.Key, key))
if (OpenRCT2::String::iequals(entry.Key, key))
{
return entry.Value;
}
+5 -5
View File
@@ -134,7 +134,7 @@ public:
std::string value;
if (TryGetString(name, &value))
{
result = String::IEquals(value, "true");
result = String::iequals(value, "true");
}
return result;
}
@@ -220,7 +220,7 @@ private:
return;
}
utf8* file = reinterpret_cast<utf8*>(_buffer.data());
utf8* content = String::SkipBOM(file);
utf8* content = String::skipBOM(file);
if (file != content)
{
size_t skipLength = content - file;
@@ -260,7 +260,7 @@ private:
for (size_t i = 0; i < _lines.size(); i++)
{
std::string line = GetLine(i);
line = String::Trim(line);
line = String::trim(line);
if (line.size() > 3 && line[0] == '[')
{
size_t endIndex = line.find_first_of(']');
@@ -309,8 +309,8 @@ private:
}
// Get the key and value
std::string key = String::Trim(line.substr(0, equalsIndex));
std::string value = String::Trim(line.substr(equalsIndex + 1));
std::string key = String::trim(line.substr(0, equalsIndex));
std::string value = String::trim(line.substr(equalsIndex + 1));
value = UnquoteValue(value);
value = UnescapeValue(value);
+2 -2
View File
@@ -90,7 +90,7 @@ private:
void WriteLine()
{
_stream->Write(PLATFORM_NEWLINE, String::SizeOf(PLATFORM_NEWLINE));
_stream->Write(PLATFORM_NEWLINE, String::sizeOf(PLATFORM_NEWLINE));
}
void WriteLine(const std::string& line)
@@ -102,7 +102,7 @@ private:
void IIniWriter::WriteString(const std::string& name, const utf8* value)
{
WriteString(name, String::ToStd(value));
WriteString(name, String::toStd(value));
}
std::unique_ptr<IIniWriter> CreateIniWriter(OpenRCT2::IStream* stream)
+1 -1
View File
@@ -79,7 +79,7 @@ namespace OpenRCT2
};
CodepointView(std::string_view str)
: _str(String::UTF8Truncate(str, str.size()))
: _str(String::utf8Truncate(str, str.size()))
{
}
+2 -2
View File
@@ -70,14 +70,14 @@ namespace OpenRCT2::Collections
static bool Contains(TCollection& collection, const char* item, bool ignoreCase = false)
{
return Contains(
collection, item, [ignoreCase](const char* a, const char* b) { return String::Equals(a, b, ignoreCase); });
collection, item, [ignoreCase](const char* a, const char* b) { return String::equals(a, b, ignoreCase); });
}
template<typename TCollection>
static size_t IndexOf(TCollection& collection, const char* item, bool ignoreCase = false)
{
return IndexOf(
collection, item, [ignoreCase](const char* a, const char* b) { return String::Equals(a, b, ignoreCase); });
collection, item, [ignoreCase](const char* a, const char* b) { return String::equals(a, b, ignoreCase); });
}
#pragma endregion
+1 -1
View File
@@ -71,7 +71,7 @@ namespace OpenRCT2::File
auto fsize = Platform::GetFileSize(path);
if (fsize > SIZE_MAX)
{
u8string message = String::StdFormat(
u8string message = String::stdFormat(
"'%s' exceeds maximum length of %lld bytes.", u8string(path).c_str(), SIZE_MAX);
throw IOException(message);
}
+3 -3
View File
@@ -213,7 +213,7 @@ public:
void GetDirectoryChildren(std::vector<DirectoryChild>& children, const std::string& path) override
{
auto pattern = path + "\\*";
auto wPattern = String::ToWideChar(pattern.c_str());
auto wPattern = String::toWideChar(pattern.c_str());
WIN32_FIND_DATAW findData;
HANDLE hFile = FindFirstFileW(wPattern.c_str(), &findData);
@@ -235,7 +235,7 @@ private:
{
DirectoryChild result;
result.Name = String::ToUtf8(child->cFileName);
result.Name = String::toUtf8(child->cFileName);
if (child->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
result.Type = DIRECTORY_CHILD_TYPE::DC_DIRECTORY;
@@ -272,7 +272,7 @@ public:
for (int32_t i = 0; i < count; i++)
{
const struct dirent* node = namelist[i];
if (!String::Equals(node->d_name, ".") && !String::Equals(node->d_name, ".."))
if (!String::equals(node->d_name, ".") && !String::equals(node->d_name, ".."))
{
children.push_back(CreateChild(path.c_str(), node));
}
+3 -3
View File
@@ -77,8 +77,8 @@ namespace OpenRCT2
}
#ifdef _WIN32
auto pathW = String::ToWideChar(path);
auto modeW = String::ToWideChar(mode);
auto pathW = String::toWideChar(path);
auto modeW = String::toWideChar(mode);
_file = _wfopen(pathW.c_str(), modeW.c_str());
#else
if (fileMode == FILE_MODE_OPEN)
@@ -97,7 +97,7 @@ namespace OpenRCT2
#endif
if (_file == nullptr)
{
throw IOException(String::StdFormat("Unable to open '%s'", path));
throw IOException(String::stdFormat("Unable to open '%s'", path));
}
#ifdef _WIN32
+1 -1
View File
@@ -128,7 +128,7 @@ FileWatcher::FileWatcher(u8string_view directoryPath)
#ifdef _WIN32
_path = fs::u8path(directoryPath);
_directoryHandle = CreateFileW(
String::ToWideChar(directoryPath).c_str(), FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
String::toWideChar(directoryPath).c_str(), FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (_directoryHandle == INVALID_HANDLE_VALUE)
{
+2 -2
View File
@@ -74,7 +74,7 @@ namespace OpenRCT2::Guard
std::string formattedMessage;
if (message != nullptr)
{
formattedMessage = String::Format_VA(message, args);
formattedMessage = String::formatVA(message, args);
Console::Error::WriteLine(formattedMessage.c_str());
_lastAssertMessage = std::make_optional(formattedMessage);
}
@@ -139,7 +139,7 @@ namespace OpenRCT2::Guard
sb.Append("\n");
sb.Append(formattedMessage);
}
return String::ToWideChar({ sb.GetBuffer(), sb.GetLength() });
return String::toWideChar({ sb.GetBuffer(), sb.GetLength() });
}
static void ForceCrash()
+6 -6
View File
@@ -27,7 +27,7 @@ namespace OpenRCT2::Http
static void ThrowWin32Exception(const char* methodName)
{
auto errorCode = GetLastError();
auto msg = String::StdFormat("%s failed, error: %d.", methodName, errorCode);
auto msg = String::stdFormat("%s failed, error: %d.", methodName, errorCode);
throw std::runtime_error(msg);
}
@@ -88,8 +88,8 @@ namespace OpenRCT2::Http
// we don't really count as a header.
if (index != 0 && wKey.size() != 0)
{
auto key = String::ToUtf8(wKey);
auto value = String::ToUtf8(wValue);
auto key = String::toUtf8(wKey);
auto value = String::toUtf8(wValue);
headers[key] = std::move(value);
}
wKey.clear();
@@ -162,11 +162,11 @@ namespace OpenRCT2::Http
url.dwUrlPathLength = static_cast<DWORD>(-1);
url.dwExtraInfoLength = static_cast<DWORD>(-1);
auto wUrl = String::ToWideChar(req.url);
auto wUrl = String::toWideChar(req.url);
if (!WinHttpCrackUrl(wUrl.c_str(), 0, 0, &url))
throw std::invalid_argument("Unable to parse URI.");
auto userAgent = String::ToWideChar(OPENRCT2_USER_AGENT);
auto userAgent = String::toWideChar(OPENRCT2_USER_AGENT);
hSession = WinHttpOpen(
userAgent.c_str(), WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
if (hSession == nullptr)
@@ -192,7 +192,7 @@ namespace OpenRCT2::Http
for (auto header : req.header)
{
auto fullHeader = String::ToWideChar(header.first) + L": " + String::ToWideChar(header.second);
auto fullHeader = String::toWideChar(header.first) + L": " + String::toWideChar(header.second);
if (!WinHttpAddRequestHeaders(hRequest, fullHeader.c_str(), static_cast<ULONG>(-1L), WINHTTP_ADDREQ_FLAG_ADD))
ThrowWin32Exception("WinHttpAddRequestHeaders");
}
+1 -1
View File
@@ -34,7 +34,7 @@ namespace OpenRCT2
}
else
{
size_t numBytes = String::SizeOf(str) + 1;
size_t numBytes = String::sizeOf(str) + 1;
Write(str, numBytes);
}
}
+2 -2
View File
@@ -255,12 +255,12 @@ namespace OpenRCT2::Imaging
IMAGE_FORMAT GetImageFormatFromPath(std::string_view path)
{
if (String::EndsWith(path, ".png", true))
if (String::endsWith(path, ".png", true))
{
return IMAGE_FORMAT::PNG;
}
if (String::EndsWith(path, ".bmp", true))
if (String::endsWith(path, ".bmp", true))
{
return IMAGE_FORMAT::BITMAP;
}
+1 -1
View File
@@ -37,7 +37,7 @@ namespace OpenRCT2::Json
}
catch (const json_t::exception& e)
{
throw JsonException(String::StdFormat(
throw JsonException(String::stdFormat(
"Unable to parse JSON file (%.*s)\n\t%s", static_cast<int>(path.length()), path.data(), e.what()));
}
+1 -1
View File
@@ -120,7 +120,7 @@ namespace OpenRCT2::Path
bool Equals(u8string_view a, u8string_view b)
{
return Platform::ShouldIgnoreCase() ? String::IEquals(a, b) : String::Equals(a, b);
return Platform::ShouldIgnoreCase() ? String::iequals(a, b) : String::equals(a, b);
}
u8string ResolveCasing(u8string_view path)
+77 -77
View File
@@ -40,7 +40,7 @@
namespace OpenRCT2::String
{
std::string ToStd(const utf8* str)
std::string toStd(const utf8* str)
{
if (str == nullptr)
return std::string();
@@ -48,7 +48,7 @@ namespace OpenRCT2::String
return std::string(str);
}
std::string ToUtf8(std::wstring_view src)
std::string toUtf8(std::wstring_view src)
{
#ifdef _WIN32
int srcLen = static_cast<int>(src.size());
@@ -76,7 +76,7 @@ namespace OpenRCT2::String
#endif
}
std::wstring ToWideChar(std::string_view src)
std::wstring toWideChar(std::string_view src)
{
#ifdef _WIN32
int srcLen = static_cast<int>(src.size());
@@ -109,7 +109,7 @@ namespace OpenRCT2::String
#endif
}
std::string_view ToStringView(const char* ch, size_t maxLen)
std::string_view toStringView(const char* ch, size_t maxLen)
{
size_t len{};
for (size_t i = 0; i < maxLen; i++)
@@ -124,17 +124,17 @@ namespace OpenRCT2::String
return std::string_view(ch, len);
}
bool IsNullOrEmpty(const utf8* str)
bool isNullOrEmpty(const utf8* str)
{
return str == nullptr || str[0] == '\0';
}
int32_t Compare(const std::string& a, const std::string& b, bool ignoreCase)
int32_t compare(const std::string& a, const std::string& b, bool ignoreCase)
{
return Compare(a.c_str(), b.c_str(), ignoreCase);
return compare(a.c_str(), b.c_str(), ignoreCase);
}
int32_t Compare(const utf8* a, const utf8* b, bool ignoreCase)
int32_t compare(const utf8* a, const utf8* b, bool ignoreCase)
{
if (a == b)
return 0;
@@ -151,7 +151,7 @@ namespace OpenRCT2::String
}
template<typename TString>
static bool EqualsImpl(TString&& lhs, TString&& rhs, bool ignoreCase)
static bool equalsImpl(TString&& lhs, TString&& rhs, bool ignoreCase)
{
return std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), [ignoreCase](auto a, auto b) {
const auto first = static_cast<unsigned char>(a);
@@ -165,17 +165,17 @@ namespace OpenRCT2::String
});
}
bool Equals(u8string_view a, u8string_view b)
bool equals(u8string_view a, u8string_view b)
{
return EqualsImpl(a, b, false);
return equalsImpl(a, b, false);
}
bool Equals(const u8string& a, const u8string& b)
bool equals(const u8string& a, const u8string& b)
{
return EqualsImpl(a, b, false);
return equalsImpl(a, b, false);
}
bool Equals(const utf8* a, const utf8* b, bool ignoreCase)
bool equals(const utf8* a, const utf8* b, bool ignoreCase)
{
if (a == b)
return true;
@@ -190,17 +190,17 @@ namespace OpenRCT2::String
return strcmp(a, b) == 0;
}
bool IEquals(u8string_view a, u8string_view b)
bool iequals(u8string_view a, u8string_view b)
{
return EqualsImpl(a, b, true);
return equalsImpl(a, b, true);
}
bool IEquals(const u8string& a, const u8string& b)
bool iequals(const u8string& a, const u8string& b)
{
return EqualsImpl(a, b, true);
return equalsImpl(a, b, true);
}
bool IEquals(const utf8* a, const utf8* b)
bool iequals(const utf8* a, const utf8* b)
{
if (a == b)
return true;
@@ -209,27 +209,27 @@ namespace OpenRCT2::String
return _stricmp(a, b) == 0;
}
bool StartsWith(std::string_view str, std::string_view match, bool ignoreCase)
bool startsWith(std::string_view str, std::string_view match, bool ignoreCase)
{
if (str.size() >= match.size())
{
auto view = str.substr(0, match.size());
return EqualsImpl(view, match, ignoreCase);
return equalsImpl(view, match, ignoreCase);
}
return false;
}
bool EndsWith(std::string_view str, std::string_view match, bool ignoreCase)
bool endsWith(std::string_view str, std::string_view match, bool ignoreCase)
{
if (str.size() >= match.size())
{
auto view = str.substr(str.size() - match.size());
return EqualsImpl(view, match, ignoreCase);
return equalsImpl(view, match, ignoreCase);
}
return false;
}
bool Contains(std::string_view haystack, std::string_view needle, bool ignoreCase)
bool contains(std::string_view haystack, std::string_view needle, bool ignoreCase)
{
if (needle.size() > haystack.size())
return false;
@@ -241,7 +241,7 @@ namespace OpenRCT2::String
for (size_t start = 0; start <= end; start++)
{
auto sub = haystack.substr(start, needle.size());
if (EqualsImpl(sub, needle, ignoreCase))
if (equalsImpl(sub, needle, ignoreCase))
{
return true;
}
@@ -249,7 +249,7 @@ namespace OpenRCT2::String
return false;
}
size_t IndexOf(const utf8* str, utf8 match, size_t startIndex)
size_t indexOf(const utf8* str, utf8 match, size_t startIndex)
{
const utf8* ch = str + startIndex;
for (; *ch != '\0'; ch++)
@@ -262,7 +262,7 @@ namespace OpenRCT2::String
return SIZE_MAX;
}
ptrdiff_t LastIndexOf(const utf8* str, utf8 match)
ptrdiff_t lastIndexOf(const utf8* str, utf8 match)
{
const utf8* lastOccurance = nullptr;
const utf8* ch = str;
@@ -282,22 +282,22 @@ namespace OpenRCT2::String
return lastOccurance - str;
}
size_t LengthOf(const utf8* str)
size_t lengthOf(const utf8* str)
{
return UTF8Length(str);
}
size_t SizeOf(const utf8* str)
size_t sizeOf(const utf8* str)
{
return strlen(str);
}
utf8* Set(utf8* buffer, size_t bufferSize, const utf8* src)
utf8* set(utf8* buffer, size_t bufferSize, const utf8* src)
{
return SafeStrCpy(buffer, src, bufferSize);
return safeUtf8Copy(buffer, src, bufferSize);
}
utf8* Set(utf8* buffer, size_t bufferSize, const utf8* src, size_t srcSize)
utf8* set(utf8* buffer, size_t bufferSize, const utf8* src, size_t srcSize)
{
utf8* dst = buffer;
size_t minSize = std::min(bufferSize - 1, srcSize);
@@ -312,12 +312,12 @@ namespace OpenRCT2::String
return buffer;
}
utf8* Append(utf8* buffer, size_t bufferSize, const utf8* src)
utf8* append(utf8* buffer, size_t bufferSize, const utf8* src)
{
return SafeStrCat(buffer, src, bufferSize);
return safeConcat(buffer, src, bufferSize);
}
utf8* Format(utf8* buffer, size_t bufferSize, const utf8* format, ...)
utf8* format(utf8* buffer, size_t bufferSize, const utf8* format, ...)
{
va_list args;
@@ -331,16 +331,16 @@ namespace OpenRCT2::String
return buffer;
}
u8string StdFormat(const utf8* format, ...)
u8string stdFormat(const utf8* format, ...)
{
va_list args;
va_start(args, format);
auto result = Format_VA(format, args);
auto result = formatVA(format, args);
va_end(args);
return result;
}
u8string Format_VA(const utf8* format, va_list args)
u8string formatVA(const utf8* format, va_list args)
{
// When passing no buffer and a size of 0, vsnprintf returns the numbers of chars it would have writte, excluding the
// null terminator.
@@ -365,7 +365,7 @@ namespace OpenRCT2::String
return u8string{};
}
utf8* AppendFormat(utf8* buffer, size_t bufferSize, const utf8* format, ...)
utf8* appendFormat(utf8* buffer, size_t bufferSize, const utf8* format, ...)
{
utf8* dst = buffer;
size_t i;
@@ -390,7 +390,7 @@ namespace OpenRCT2::String
return buffer;
}
std::vector<std::string> Split(std::string_view s, std::string_view delimiter)
std::vector<std::string> split(std::string_view s, std::string_view delimiter)
{
if (delimiter.empty())
{
@@ -419,12 +419,12 @@ namespace OpenRCT2::String
return results;
}
utf8* SkipBOM(utf8* buffer)
utf8* skipBOM(utf8* buffer)
{
return const_cast<utf8*>(SkipBOM(static_cast<const utf8*>(buffer)));
return const_cast<utf8*>(skipBOM(static_cast<const utf8*>(buffer)));
}
const utf8* SkipBOM(const utf8* buffer)
const utf8* skipBOM(const utf8* buffer)
{
if (static_cast<uint8_t>(buffer[0]) == 0xEF && static_cast<uint8_t>(buffer[1]) == 0xBB
&& static_cast<uint8_t>(buffer[2]) == 0xBF)
@@ -434,49 +434,49 @@ namespace OpenRCT2::String
return buffer;
}
size_t GetCodepointLength(codepoint_t codepoint)
size_t getCodepointLength(codepoint_t codepoint)
{
return UTF8GetCodepointLength(codepoint);
}
codepoint_t GetNextCodepoint(utf8* ptr, utf8** nextPtr)
codepoint_t getNextCodepoint(utf8* ptr, utf8** nextPtr)
{
return GetNextCodepoint(static_cast<const utf8*>(ptr), const_cast<const utf8**>(nextPtr));
return getNextCodepoint(static_cast<const utf8*>(ptr), const_cast<const utf8**>(nextPtr));
}
codepoint_t GetNextCodepoint(const utf8* ptr, const utf8** nextPtr)
codepoint_t getNextCodepoint(const utf8* ptr, const utf8** nextPtr)
{
return UTF8GetNext(ptr, nextPtr);
}
utf8* WriteCodepoint(utf8* dst, codepoint_t codepoint)
utf8* writeCodepoint(utf8* dst, codepoint_t codepoint)
{
return UTF8WriteCodepoint(dst, codepoint);
}
void AppendCodepoint(std::string& str, codepoint_t codepoint)
void appendCodepoint(std::string& str, codepoint_t codepoint)
{
char buffer[8]{};
UTF8WriteCodepoint(buffer, codepoint);
str.append(buffer);
}
bool IsWhiteSpace(codepoint_t codepoint)
bool isWhiteSpace(codepoint_t codepoint)
{
// 0x3000 is the 'ideographic space', a 'fullwidth' character used in CJK languages.
return iswspace(static_cast<wchar_t>(codepoint)) || codepoint == 0x3000;
}
utf8* Trim(utf8* str)
utf8* trim(utf8* str)
{
utf8* firstNonWhitespace = nullptr;
codepoint_t codepoint;
utf8* ch = str;
utf8* nextCh;
while ((codepoint = GetNextCodepoint(ch, &nextCh)) != '\0')
while ((codepoint = getNextCodepoint(ch, &nextCh)) != '\0')
{
if (codepoint <= WCHAR_MAX && !IsWhiteSpace(codepoint))
if (codepoint <= WCHAR_MAX && !isWhiteSpace(codepoint))
{
if (firstNonWhitespace == nullptr)
{
@@ -493,7 +493,7 @@ namespace OpenRCT2::String
size_t newStringSize = (nextCh - 1) - firstNonWhitespace;
#ifdef DEBUG
size_t currentStringSize = SizeOf(str);
size_t currentStringSize = sizeOf(str);
Guard::Assert(newStringSize < currentStringSize, GUARD_LINE);
#endif
@@ -508,14 +508,14 @@ namespace OpenRCT2::String
return str;
}
const utf8* TrimStart(const utf8* str)
const utf8* trimStart(const utf8* str)
{
codepoint_t codepoint;
const utf8* ch = str;
const utf8* nextCh;
while ((codepoint = GetNextCodepoint(ch, &nextCh)) != '\0')
while ((codepoint = getNextCodepoint(ch, &nextCh)) != '\0')
{
if (codepoint <= WCHAR_MAX && !IsWhiteSpace(codepoint))
if (codepoint <= WCHAR_MAX && !isWhiteSpace(codepoint))
{
return ch;
}
@@ -525,23 +525,23 @@ namespace OpenRCT2::String
return ch;
}
std::string TrimStart(const std::string& s)
std::string trimStart(const std::string& s)
{
const utf8* trimmed = TrimStart(s.c_str());
const utf8* trimmed = trimStart(s.c_str());
return std::string(trimmed);
}
std::string Trim(const std::string& s)
std::string trim(const std::string& s)
{
codepoint_t codepoint;
const utf8* ch = s.c_str();
const utf8* nextCh;
const utf8* startSubstr = nullptr;
const utf8* endSubstr = nullptr;
while ((codepoint = GetNextCodepoint(ch, &nextCh)) != '\0')
while ((codepoint = getNextCodepoint(ch, &nextCh)) != '\0')
{
bool isWhiteSpace = codepoint <= WCHAR_MAX && IsWhiteSpace(codepoint);
if (!isWhiteSpace)
bool whiteSpace = codepoint <= WCHAR_MAX && isWhiteSpace(codepoint);
if (!whiteSpace)
{
if (startSubstr == nullptr)
{
@@ -566,7 +566,7 @@ namespace OpenRCT2::String
}
#ifndef _WIN32
static const char* GetIcuCodePage(int32_t codePage)
static const char* getIcuCodePage(int32_t codePage)
{
switch (codePage)
{
@@ -594,7 +594,7 @@ namespace OpenRCT2::String
}
#endif
std::string ConvertToUtf8(std::string_view src, int32_t srcCodePage)
std::string convertToUtf8(std::string_view src, int32_t srcCodePage)
{
#ifdef _WIN32
// Convert from source code page to UTF-16
@@ -617,7 +617,7 @@ namespace OpenRCT2::String
return dst;
#else
const char* codepage = GetIcuCodePage(srcCodePage);
const char* codepage = getIcuCodePage(srcCodePage);
icu::UnicodeString convertString(src.data(), codepage);
std::string result;
@@ -627,10 +627,10 @@ namespace OpenRCT2::String
#endif
}
std::string ToUpper(std::string_view src)
std::string toUpper(std::string_view src)
{
#ifdef _WIN32
auto srcW = ToWideChar(src);
auto srcW = toWideChar(src);
// Measure how long the destination needs to be
auto requiredSize = LCMapStringEx(
@@ -652,7 +652,7 @@ namespace OpenRCT2::String
return std::string(src);
}
return ToUtf8(dstW);
return toUtf8(dstW);
#else
icu::UnicodeString str = icu::UnicodeString::fromUTF8(std::string(src));
str.toUpper();
@@ -664,12 +664,12 @@ namespace OpenRCT2::String
#endif
}
std::string_view UTF8Truncate(std::string_view v, size_t size)
std::string_view utf8Truncate(std::string_view v, size_t size)
{
auto trunc = v.substr(0, size);
for (size_t i = 0; i < trunc.size();)
{
auto length = UTF8GetCodePointSize(trunc.substr(i, trunc.size()));
auto length = utf8GetCodePointSize(trunc.substr(i, trunc.size()));
if (!length.has_value())
{
return trunc.substr(0, i);
@@ -680,12 +680,12 @@ namespace OpenRCT2::String
return trunc;
}
std::string_view UTF8TruncateCodePoints(std::string_view v, size_t size)
std::string_view utf8TruncateCodePoints(std::string_view v, size_t size)
{
size_t i = 0;
while (i < v.size() && size > 0)
{
auto length = UTF8GetCodePointSize(v.substr(i, v.size()));
auto length = utf8GetCodePointSize(v.substr(i, v.size()));
if (!length.has_value())
{
return v.substr(0, i);
@@ -697,7 +697,7 @@ namespace OpenRCT2::String
return v.substr(0, i);
}
std::string URLEncode(std::string_view value)
std::string urlEncode(std::string_view value)
{
std::ostringstream escaped;
escaped.fill('0');
@@ -729,7 +729,7 @@ namespace OpenRCT2::String
// - Guest 100
// - John v2.0
// - John v2.1
int32_t StrLogicalCmp(const char* s1, const char* s2)
int32_t logicalCmp(const char* s1, const char* s2)
{
for (;;)
{
@@ -761,7 +761,7 @@ namespace OpenRCT2::String
}
}
char* SafeStrCpy(char* destination, const char* source, size_t size)
char* safeUtf8Copy(char* destination, const char* source, size_t size)
{
assert(destination != nullptr);
assert(source != nullptr);
@@ -795,7 +795,7 @@ namespace OpenRCT2::String
return result;
}
char* SafeStrCat(char* destination, const char* source, size_t size)
char* safeConcat(char* destination, const char* source, size_t size)
{
assert(destination != nullptr);
assert(source != nullptr);
+49 -51
View File
@@ -19,83 +19,81 @@
namespace OpenRCT2::String
{
constexpr const utf8* Empty = "";
std::string ToStd(const utf8* str);
std::string ToUtf8(std::wstring_view src);
std::wstring ToWideChar(std::string_view src);
std::string toStd(const utf8* str);
std::string toUtf8(std::wstring_view src);
std::wstring toWideChar(std::string_view src);
/**
* Creates a string_view from a char pointer with a length up to either the
* first null terminator or a given maximum length, whatever is smallest.
*/
std::string_view ToStringView(const char* ch, size_t maxLen);
std::string_view toStringView(const char* ch, size_t maxLen);
bool IsNullOrEmpty(const utf8* str);
int32_t Compare(const std::string& a, const std::string& b, bool ignoreCase = false);
int32_t Compare(const utf8* a, const utf8* b, bool ignoreCase = false);
bool isNullOrEmpty(const utf8* str);
int32_t compare(const std::string& a, const std::string& b, bool ignoreCase = false);
int32_t compare(const utf8* a, const utf8* b, bool ignoreCase = false);
bool Equals(u8string_view a, u8string_view b);
bool Equals(const u8string& a, const u8string& b);
bool Equals(const utf8* a, const utf8* b, bool ignoreCase = false);
bool IEquals(u8string_view a, u8string_view b);
bool IEquals(const u8string& a, const u8string& b);
bool IEquals(const utf8* a, const utf8* b);
bool equals(u8string_view a, u8string_view b);
bool equals(const u8string& a, const u8string& b);
bool equals(const utf8* a, const utf8* b, bool ignoreCase = false);
bool iequals(u8string_view a, u8string_view b);
bool iequals(const u8string& a, const u8string& b);
bool iequals(const utf8* a, const utf8* b);
bool StartsWith(std::string_view str, std::string_view match, bool ignoreCase = false);
bool EndsWith(std::string_view str, std::string_view match, bool ignoreCase = false);
bool Contains(std::string_view haystack, std::string_view needle, bool ignoreCase = false);
size_t IndexOf(const utf8* str, utf8 match, size_t startIndex = 0);
ptrdiff_t LastIndexOf(const utf8* str, utf8 match);
bool startsWith(std::string_view str, std::string_view match, bool ignoreCase = false);
bool endsWith(std::string_view str, std::string_view match, bool ignoreCase = false);
bool contains(std::string_view haystack, std::string_view needle, bool ignoreCase = false);
size_t indexOf(const utf8* str, utf8 match, size_t startIndex = 0);
ptrdiff_t lastIndexOf(const utf8* str, utf8 match);
/**
* Gets the length of the given string in codepoints.
*/
size_t LengthOf(const utf8* str);
size_t lengthOf(const utf8* str);
/**
* Gets the size of the given string in bytes excluding the null terminator.
*/
size_t SizeOf(const utf8* str);
size_t sizeOf(const utf8* str);
utf8* Set(utf8* buffer, size_t bufferSize, const utf8* src);
utf8* Set(utf8* buffer, size_t bufferSize, const utf8* src, size_t srcSize);
utf8* Append(utf8* buffer, size_t bufferSize, const utf8* src);
utf8* Format(utf8* buffer, size_t bufferSize, const utf8* format, ...);
u8string StdFormat(const utf8* format, ...);
u8string Format_VA(const utf8* format, va_list args);
utf8* AppendFormat(utf8* buffer, size_t bufferSize, const utf8* format, ...);
utf8* set(utf8* buffer, size_t bufferSize, const utf8* src);
utf8* set(utf8* buffer, size_t bufferSize, const utf8* src, size_t srcSize);
utf8* append(utf8* buffer, size_t bufferSize, const utf8* src);
utf8* format(utf8* buffer, size_t bufferSize, const utf8* format, ...);
u8string stdFormat(const utf8* format, ...);
u8string formatVA(const utf8* format, va_list args);
utf8* appendFormat(utf8* buffer, size_t bufferSize, const utf8* format, ...);
/**
* Splits the given string by a delimiter and returns the values as a new string array.
* @returns the number of values.
*/
std::vector<std::string> Split(std::string_view s, std::string_view delimiter);
std::vector<std::string> split(std::string_view s, std::string_view delimiter);
utf8* SkipBOM(utf8* buffer);
const utf8* SkipBOM(const utf8* buffer);
utf8* skipBOM(utf8* buffer);
const utf8* skipBOM(const utf8* buffer);
size_t GetCodepointLength(codepoint_t codepoint);
codepoint_t GetNextCodepoint(utf8* ptr, utf8** nextPtr = nullptr);
codepoint_t GetNextCodepoint(const utf8* ptr, const utf8** nextPtr = nullptr);
utf8* WriteCodepoint(utf8* dst, codepoint_t codepoint);
void AppendCodepoint(std::string& str, codepoint_t codepoint);
size_t getCodepointLength(codepoint_t codepoint);
codepoint_t getNextCodepoint(utf8* ptr, utf8** nextPtr = nullptr);
codepoint_t getNextCodepoint(const utf8* ptr, const utf8** nextPtr = nullptr);
utf8* writeCodepoint(utf8* dst, codepoint_t codepoint);
void appendCodepoint(std::string& str, codepoint_t codepoint);
bool IsWhiteSpace(codepoint_t codepoint);
utf8* Trim(utf8* str);
const utf8* TrimStart(const utf8* str);
[[nodiscard]] std::string TrimStart(const std::string& s);
[[nodiscard]] std::string Trim(const std::string& s);
bool isWhiteSpace(codepoint_t codepoint);
utf8* trim(utf8* str);
const utf8* trimStart(const utf8* str);
[[nodiscard]] std::string trimStart(const std::string& s);
[[nodiscard]] std::string trim(const std::string& s);
/**
* Converts a multi-byte string from one code page to UTF-8.
*/
std::string ConvertToUtf8(std::string_view src, int32_t srcCodePage);
std::string convertToUtf8(std::string_view src, int32_t srcCodePage);
/**
* Returns an uppercased version of a UTF-8 string.
*/
std::string ToUpper(std::string_view src);
std::string toUpper(std::string_view src);
template<typename T>
std::optional<T> Parse(std::string_view input)
@@ -149,7 +147,7 @@ namespace OpenRCT2::String
/**
* Returns codepoint size or no value if not valid
*/
constexpr std::optional<int> UTF8GetCodePointSize(std::string_view v)
constexpr std::optional<int> utf8GetCodePointSize(std::string_view v)
{
if (v.size() >= 1 && !(v[0] & 0x80))
{
@@ -174,18 +172,18 @@ namespace OpenRCT2::String
* Truncates a string to at most `size` bytes,
* making sure not to cut in the middle of a sequence.
*/
std::string_view UTF8Truncate(std::string_view v, size_t size);
std::string_view utf8Truncate(std::string_view v, size_t size);
/**
* Truncates a string to at most `size` codepoints,
* making sure not to cut in the middle of a sequence.
*/
std::string_view UTF8TruncateCodePoints(std::string_view v, size_t size);
std::string_view utf8TruncateCodePoints(std::string_view v, size_t size);
// Escapes special characters in a string to the percentage equivalent that can be used in URLs.
std::string URLEncode(std::string_view value);
std::string urlEncode(std::string_view value);
int32_t StrLogicalCmp(char const* a, char const* b);
char* SafeStrCpy(char* destination, const char* source, size_t num);
char* SafeStrCat(char* destination, const char* source, size_t size);
int32_t logicalCmp(char const* a, char const* b);
char* safeUtf8Copy(char* destination, const char* source, size_t num);
char* safeConcat(char* destination, const char* source, size_t size);
} // namespace OpenRCT2::String
+2 -2
View File
@@ -27,9 +27,9 @@ void StringBuilder::Append(int32_t codepoint)
void StringBuilder::Append(codepoint_t codepoint)
{
size_t codepointLength = String::GetCodepointLength(codepoint);
size_t codepointLength = String::getCodepointLength(codepoint);
std::basic_string<utf8> data(codepointLength, {});
String::WriteCodepoint(data.data(), codepoint);
String::writeCodepoint(data.data(), codepoint);
_buffer.insert(_buffer.end(), data.begin(), data.end());
}
+3 -3
View File
@@ -15,7 +15,7 @@ using namespace OpenRCT2;
UTF8StringReader::UTF8StringReader(const utf8* text)
{
text = String::SkipBOM(text);
text = String::skipBOM(text);
_text = text;
_current = text;
@@ -26,7 +26,7 @@ bool UTF8StringReader::TryPeek(codepoint_t* outCodepoint)
if (_current == nullptr)
return false;
codepoint_t codepoint = String::GetNextCodepoint(_current);
codepoint_t codepoint = String::getNextCodepoint(_current);
*outCodepoint = codepoint;
return true;
}
@@ -36,7 +36,7 @@ bool UTF8StringReader::TryRead(codepoint_t* outCodepoint)
if (_current == nullptr)
return false;
codepoint_t codepoint = String::GetNextCodepoint(_current, &_current);
codepoint_t codepoint = String::getNextCodepoint(_current, &_current);
*outCodepoint = codepoint;
if (codepoint == 0)
{
+2 -2
View File
@@ -218,7 +218,7 @@ TTFSurface* TTFSurfaceCacheGetOrAdd(TTF_Font* font, std::string_view text)
// Check if entry is a hit
if (entry->surface == nullptr)
break;
if (entry->font == font && String::Equals(entry->text, text))
if (entry->font == font && String::equals(entry->text, text))
{
_ttfSurfaceCacheHitCount++;
entry->lastUseTick = gCurrentDrawCount;
@@ -292,7 +292,7 @@ uint32_t TTFGetWidthCacheGetOrAdd(TTF_Font* font, std::string_view text)
// Check if entry is a hit
if (entry->text.empty())
break;
if (entry->font == font && String::Equals(entry->text, text))
if (entry->font == font && String::equals(entry->text, text))
{
_ttfGetWidthCacheHitCount++;
entry->lastUseTick = gCurrentDrawCount;
+2 -2
View File
@@ -604,7 +604,7 @@ int32_t Guest::GetEasterEggNameId() const
for (uint32_t i = 0; i < std::size(gPeepEasterEggNames); i++)
{
if (String::IEquals(buffer, gPeepEasterEggNames[i]))
if (String::iequals(buffer, gPeepEasterEggNames[i]))
return static_cast<int32_t>(i);
}
@@ -751,7 +751,7 @@ int32_t Guest::CheckEasterEggName(int32_t index) const
FormatNameTo(ft);
FormatStringLegacy(buffer, sizeof(buffer), STR_STRINGID, ft.Data());
return String::IEquals(buffer, gPeepEasterEggNames[index]);
return String::iequals(buffer, gPeepEasterEggNames[index]);
}
void Guest::UpdateMotivesIdle()
+1 -1
View File
@@ -2664,7 +2664,7 @@ int32_t PeepCompare(const EntityId sprite_index_a, const EntityId sprite_index_b
ft.Rewind();
peep_b->FormatNameTo(ft);
OpenRCT2::FormatStringLegacy(nameB, sizeof(nameB), STR_STRINGID, ft.Data());
return String::StrLogicalCmp(nameA, nameB);
return String::logicalCmp(nameA, nameB);
}
/**
@@ -1495,7 +1495,7 @@ static int32_t ConsoleCommandLoadPark([[maybe_unused]] InteractiveConsole& conso
}
u8string savePath = {};
if (String::IndexOf(argv[0].c_str(), '/') == SIZE_MAX && String::IndexOf(argv[0].c_str(), '\\') == SIZE_MAX)
if (String::indexOf(argv[0].c_str(), '/') == SIZE_MAX && String::indexOf(argv[0].c_str(), '\\') == SIZE_MAX)
{
// no / or \ was included. File should be in save dir.
auto env = OpenRCT2::GetContext()->GetPlatformEnvironment();
@@ -1506,8 +1506,8 @@ static int32_t ConsoleCommandLoadPark([[maybe_unused]] InteractiveConsole& conso
{
savePath = argv[0];
}
if (!String::EndsWith(savePath, ".sv6", true) && !String::EndsWith(savePath, ".sc6", true)
&& !String::EndsWith(savePath, ".park", true))
if (!String::endsWith(savePath, ".sv6", true) && !String::endsWith(savePath, ".sc6", true)
&& !String::endsWith(savePath, ".park", true))
{
savePath += ".park";
}
@@ -1570,7 +1570,7 @@ static int32_t ConsoleCommandReplayStartRecord(InteractiveConsole& console, cons
std::string name = argv[0];
if (!String::EndsWith(name, ".parkrep", true))
if (!String::endsWith(name, ".parkrep", true))
{
name += ".parkrep";
}
@@ -1713,7 +1713,7 @@ static int32_t ConsoleCommandReplayNormalise(InteractiveConsole& console, const
std::string inputFile = argv[0];
std::string outputFile = argv[1];
if (!String::EndsWith(outputFile, ".parkrep", true))
if (!String::endsWith(outputFile, ".parkrep", true))
{
outputFile += ".parkrep";
}
@@ -2187,7 +2187,7 @@ void InteractiveConsole::WriteFormatLine(const char* format, ...)
{
va_list list;
va_start(list, format);
auto buffer = String::Format_VA(format, list);
auto buffer = String::formatVA(format, list);
va_end(list);
WriteLine(buffer);
}
+1 -1
View File
@@ -432,7 +432,7 @@ int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOpti
}
}
bool giantScreenshot = (argc == 5) && String::IEquals(argv[2], "giant");
bool giantScreenshot = (argc == 5) && String::iequals(argv[2], "giant");
if (argc != 4 && argc != 8 && !giantScreenshot)
{
std::printf("Usage: openrct2 screenshot <file> <output_image> <width> <height> [<x> <y> <zoom> <rotation>]\n");
+1 -1
View File
@@ -47,7 +47,7 @@ void CurrencyLoadCustomCurrencyConfig()
CurrencyDescriptors[EnumValue(CurrencyType::Custom)].affix_unicode = Config::Get().general.CustomCurrencyAffix;
if (!Config::Get().general.CustomCurrencySymbol.empty())
{
String::SafeStrCpy(
String::safeUtf8Copy(
CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode,
Config::Get().general.CustomCurrencySymbol.c_str(), kCurrencySymbolMaxSize);
}
+1 -1
View File
@@ -914,7 +914,7 @@ namespace OpenRCT2
FormatStringLegacy(dest, size, format, args);
std::string upperString = String::ToUpper(dest);
std::string upperString = String::toUpper(dest);
if (upperString.size() + 1 >= size)
{
+1 -1
View File
@@ -62,7 +62,7 @@ uint8_t LanguageGetIDFromLocale(const char* locale)
uint8_t i = 0;
for (const auto& langDesc : LanguagesDescriptors)
{
if (String::Equals(locale, langDesc.locale))
if (String::equals(locale, langDesc.locale))
{
return i;
}
+5 -5
View File
@@ -1151,8 +1151,8 @@ void NetworkBase::AppendLog(std::ostream& fs, std::string_view s)
auto tmInfo = localtime(&timer);
if (strftime(buffer, sizeof(buffer), "[%Y/%m/%d %H:%M:%S] ", tmInfo) != 0)
{
String::Append(buffer, sizeof(buffer), std::string(s).c_str());
String::Append(buffer, sizeof(buffer), PLATFORM_NEWLINE);
String::append(buffer, sizeof(buffer), std::string(s).c_str());
String::append(buffer, sizeof(buffer), PLATFORM_NEWLINE);
fs.write(buffer, strlen(buffer));
}
@@ -2135,7 +2135,7 @@ NetworkPlayer* NetworkBase::AddPlayer(const std::string& name, const std::string
player->Group = GetDefaultGroup();
if (!name.empty())
{
player->SetName(MakePlayerNameUnique(String::Trim(name)));
player->SetName(MakePlayerNameUnique(String::trim(name)));
}
}
else
@@ -2152,7 +2152,7 @@ NetworkPlayer* NetworkBase::AddPlayer(const std::string& name, const std::string
player = std::make_unique<NetworkPlayer>();
player->Id = newid;
player->Group = GetDefaultGroup();
player->SetName(String::Trim(std::string(name)));
player->SetName(String::trim(std::string(name)));
}
addedplayer = player.get();
@@ -2175,7 +2175,7 @@ std::string NetworkBase::MakePlayerNameUnique(const std::string& name)
// Check if there is already a player with this name in the server
for (const auto& player : player_list)
{
if (String::IEquals(player->Name, new_name))
if (String::iequals(player->Name, new_name))
{
unique = false;
break;
@@ -119,7 +119,7 @@ private:
{
std::string sender = endpoint->GetHostname();
LOG_VERBOSE("Received %zu bytes from %s on LAN broadcast port", recievedBytes, sender.c_str());
if (String::Equals(buffer, kNetworkLanBroadcastMsg))
if (String::equals(buffer, kNetworkLanBroadcastMsg))
{
auto body = GetBroadcastJson();
auto bodyDump = body.dump();
+1 -1
View File
@@ -189,7 +189,7 @@ const NetworkUser* NetworkUserManager::GetUserByName(const std::string& name) co
for (const auto& kvp : _usersByHash)
{
const auto& networkUser = kvp.second;
if (String::IEquals(name, networkUser->Name))
if (String::iequals(name, networkUser->Name))
{
return networkUser.get();
}
+2 -2
View File
@@ -65,7 +65,7 @@ int32_t ServerListEntry::CompareTo(const ServerListEntry& other) const
return a.Players > b.Players ? -1 : 1;
}
return String::Compare(a.Name, b.Name, true);
return String::compare(a.Name, b.Name, true);
}
bool ServerListEntry::IsVersionValid() const noexcept
@@ -119,7 +119,7 @@ void ServerList::Sort()
[](const ServerListEntry& a, const ServerListEntry& b) {
if (a.Favourite == b.Favourite)
{
return String::IEquals(a.Address, b.Address);
return String::iequals(a.Address, b.Address);
}
return false;
}),
+9 -9
View File
@@ -90,7 +90,7 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::ParseImages(
{
result.push_back(std::make_unique<RequiredImage>());
}
else if (String::StartsWith(s, "$CSG"))
else if (String::startsWith(s, "$CSG"))
{
auto rangeStart = s.find('[');
auto rangeEnd = s.find(']');
@@ -119,7 +119,7 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::ParseImages(
}
}
}
else if (String::StartsWith(s, "$G1"))
else if (String::startsWith(s, "$G1"))
{
auto rangeStart = s.find('[');
auto rangeEnd = s.find(']');
@@ -134,7 +134,7 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::ParseImages(
}
}
}
else if (String::StartsWith(s, "$RCT2:OBJDATA/"))
else if (String::startsWith(s, "$RCT2:OBJDATA/"))
{
auto name = s.substr(14);
auto rangeStart = name.find('[');
@@ -147,7 +147,7 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::ParseImages(
result = LoadObjectImages(context, name, range);
}
}
else if (String::StartsWith(s, "$LGX:"))
else if (String::startsWith(s, "$LGX:"))
{
auto name = s.substr(5);
auto rangeStart = name.find('[');
@@ -179,7 +179,7 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::ParseImages(
}
catch (const std::exception& e)
{
auto msg = String::StdFormat("Unable to load image '%s': %s", s.c_str(), e.what());
auto msg = String::stdFormat("Unable to load image '%s': %s", s.c_str(), e.what());
context->LogWarning(ObjectError::BadImageTable, msg.c_str());
result.push_back(std::make_unique<RequiredImage>());
}
@@ -214,7 +214,7 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::ParseImages(
}
catch (const std::exception& e)
{
auto msg = String::StdFormat("Unable to load image '%s': %s", path.c_str(), e.what());
auto msg = String::stdFormat("Unable to load image '%s': %s", path.c_str(), e.what());
context->LogWarning(ObjectError::BadImageTable, msg.c_str());
result.push_back(std::make_unique<RequiredImage>());
}
@@ -273,7 +273,7 @@ std::vector<std::unique_ptr<ImageTable::RequiredImage>> ImageTable::LoadImageArc
}
else
{
auto msg = String::StdFormat("Unable to load Gx '%s'", path.c_str());
auto msg = String::stdFormat("Unable to load Gx '%s'", path.c_str());
context->LogWarning(ObjectError::BadImageTable, msg.c_str());
for (size_t i = 0; i < range.size(); i++)
{
@@ -349,7 +349,7 @@ std::vector<int32_t> ImageTable::ParseRange(std::string s)
if (s.length() >= 3 && s[0] == '[' && s[s.length() - 1] == ']')
{
s = s.substr(1, s.length() - 2);
auto parts = String::Split(s, "..");
auto parts = String::split(s, "..");
if (parts.size() == 1)
{
result.push_back(std::stoi(parts[0]));
@@ -407,7 +407,7 @@ std::string ImageTable::FindLegacyObject(const std::string& name)
while (scanner->Next())
{
auto currentName = Path::GetFileName(scanner->GetPathRelative());
if (String::IEquals(currentName, name) || String::IEquals(currentName, altName))
if (String::iequals(currentName, name) || String::iequals(currentName, altName))
{
objectPath = scanner->GetPath();
break;
+1 -1
View File
@@ -389,7 +389,7 @@ ObjectVersion VersionTuple(std::string_view version)
return std::make_tuple(0, 0, 0);
}
auto nums = String::Split(version, ".");
auto nums = String::split(version, ".");
uint16_t versions[VersionNumFields] = {};
if (nums.size() > VersionNumFields)
{
+3 -3
View File
@@ -188,7 +188,7 @@ public:
{
_wasVerbose = true;
if (!String::IsNullOrEmpty(text))
if (!String::isNullOrEmpty(text))
{
LOG_VERBOSE("[%s] Info (%d): %s", _identifier.c_str(), code, text);
}
@@ -198,7 +198,7 @@ public:
{
_wasWarning = true;
if (!String::IsNullOrEmpty(text))
if (!String::isNullOrEmpty(text))
{
Console::Error::WriteLine("[%s] Warning (%d): %s", _identifier.c_str(), code, text);
}
@@ -208,7 +208,7 @@ public:
{
_wasError = true;
if (!String::IsNullOrEmpty(text))
if (!String::isNullOrEmpty(text))
{
Console::Error::WriteLine("[%s] Error (%d): %s", _identifier.c_str(), code, text);
}
+9 -9
View File
@@ -98,11 +98,11 @@ public:
{
std::unique_ptr<Object> object;
auto extension = Path::GetExtension(path);
if (String::IEquals(extension, ".json"))
if (String::iequals(extension, ".json"))
{
object = ObjectFactory::CreateObjectFromJsonFile(_objectRepository, path, false);
}
else if (String::IEquals(extension, ".parkobj"))
else if (String::iequals(extension, ".parkobj"))
{
object = ObjectFactory::CreateObjectFromZipFile(_objectRepository, path, false);
}
@@ -169,7 +169,7 @@ protected:
private:
bool IsTrackReadOnly(const std::string& path) const
{
return String::StartsWith(path, SearchPaths[0]) || String::StartsWith(path, SearchPaths[1]);
return String::startsWith(path, SearchPaths[0]) || String::startsWith(path, SearchPaths[1]);
}
};
@@ -264,11 +264,11 @@ public:
Guard::ArgumentNotNull(ori, GUARD_LINE);
auto extension = Path::GetExtension(ori->Path);
if (String::IEquals(extension, ".json"))
if (String::iequals(extension, ".json"))
{
return ObjectFactory::CreateObjectFromJsonFile(*this, ori->Path, !gOpenRCT2NoGraphics);
}
if (String::IEquals(extension, ".parkobj"))
if (String::iequals(extension, ".parkobj"))
{
return ObjectFactory::CreateObjectFromZipFile(*this, ori->Path, !gOpenRCT2NoGraphics);
}
@@ -364,7 +364,7 @@ private:
void SortItems()
{
std::sort(_items.begin(), _items.end(), [](const ObjectRepositoryItem& a, const ObjectRepositoryItem& b) -> bool {
return String::Compare(a.Name, b.Name) < 0;
return String::compare(a.Name, b.Name) < 0;
});
// Fix the IDs
@@ -595,7 +595,7 @@ private:
while (File::Exists(fullPath))
{
counter++;
fullPath = Path::Combine(userObjPath, String::StdFormat("%s-%02X%s", fileName.c_str(), counter, extension));
fullPath = Path::Combine(userObjPath, String::stdFormat("%s-%02X%s", fileName.c_str(), counter, extension));
}
return fullPath;
@@ -622,7 +622,7 @@ private:
}
// Convert to UTF-8 filename
return String::ConvertToUtf8(normalisedName, OpenRCT2::CodePage::CP_1252);
return String::convertToUtf8(normalisedName, OpenRCT2::CodePage::CP_1252);
}
else
{
@@ -635,7 +635,7 @@ private:
const ObjectRepositoryItem* item = FindObject(entry);
if (item == nullptr)
{
throw std::runtime_error(String::StdFormat("Unable to find object '%.8s'", entry->name));
throw std::runtime_error(String::stdFormat("Unable to find object '%.8s'", entry->name));
}
// Read object data from file
+8 -8
View File
@@ -23,7 +23,7 @@ Range<int32_t> ResourceTable::ParseRange(std::string_view s)
if (s.length() >= 3 && s[0] == '[' && s[s.length() - 1] == ']')
{
s = s.substr(1, s.length() - 2);
auto parts = String::Split(s, "..");
auto parts = String::split(s, "..");
if (parts.size() == 1)
{
result = Range<int32_t>(std::stoi(parts[0]));
@@ -71,44 +71,44 @@ ResourceTable::SourceInfo ResourceTable::ParseSource(std::string_view source)
}
}
if (String::StartsWith(base, "$LGX:"))
if (String::startsWith(base, "$LGX:"))
{
info.Kind = SourceKind::Gx;
info.Path = fileName;
}
else if (String::StartsWith(base, "$G1"))
else if (String::startsWith(base, "$G1"))
{
auto env = GetContext()->GetPlatformEnvironment();
auto dataPath = env->GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA);
info.Kind = SourceKind::G1;
// info.Path = env->FindFile(DIRBASE::RCT2, DIRID::DATA, "g1.dat");
}
else if (String::StartsWith(base, "$CSG"))
else if (String::startsWith(base, "$CSG"))
{
auto env = GetContext()->GetPlatformEnvironment();
auto dataPath = env->GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA);
info.Kind = SourceKind::Csg;
// info.Path = env->FindFile(DIRBASE::RCT2, DIRID::DATA, "g1.dat");
}
else if (String::StartsWith(base, "$RCT1:DATA/"))
else if (String::startsWith(base, "$RCT1:DATA/"))
{
auto env = GetContext()->GetPlatformEnvironment();
info.Kind = SourceKind::Data;
info.Path = env->FindFile(DIRBASE::RCT1, DIRID::DATA, fileName);
}
else if (String::StartsWith(base, "$RCT2:DATA/"))
else if (String::startsWith(base, "$RCT2:DATA/"))
{
auto env = GetContext()->GetPlatformEnvironment();
info.Kind = SourceKind::Data;
info.Path = env->FindFile(DIRBASE::RCT2, DIRID::DATA, fileName);
}
else if (String::StartsWith(base, "$RCT2:OBJDATA/"))
else if (String::startsWith(base, "$RCT2:OBJDATA/"))
{
auto env = GetContext()->GetPlatformEnvironment();
info.Kind = SourceKind::ObjData;
info.Path = env->FindFile(DIRBASE::RCT2, DIRID::OBJECT, fileName);
}
else if (!String::StartsWith(base, "$"))
else if (!String::startsWith(base, "$"))
{
info.Path = base;
}
+1 -1
View File
@@ -208,7 +208,7 @@ std::vector<ObjectEntryDescriptor> SceneryGroupObject::ReadJsonEntries(IReadObje
for (const auto& jEntry : jEntries)
{
auto entryName = Json::GetString(jEntry);
if (String::StartsWith(entryName, "$DAT:"))
if (String::startsWith(entryName, "$DAT:"))
{
if (entryName.length() != kDatEntryLength)
{
+2 -2
View File
@@ -65,7 +65,7 @@ void StringTable::Read(IReadObjectContext* context, OpenRCT2::IStream* stream, O
if (!StringIsBlank(stringAsUtf8.data()))
{
stringAsUtf8 = String::Trim(stringAsUtf8);
stringAsUtf8 = String::trim(stringAsUtf8);
StringTableEntry entry{};
entry.Id = id;
entry.LanguageId = languageId;
@@ -166,7 +166,7 @@ void StringTable::Sort()
{
if (a.LanguageId == b.LanguageId)
{
return String::Compare(a.Text, b.Text, true) < 0;
return String::compare(a.Text, b.Text, true) < 0;
}
for (const auto& language : languageOrder)
+5 -5
View File
@@ -217,15 +217,15 @@ namespace OpenRCT2
std::string name;
ReadWriteStringTable(cs, name, "en-GB");
String::Set(entry.Name, sizeof(entry.Name), name.c_str());
String::Set(entry.InternalName, sizeof(entry.InternalName), name.c_str());
String::set(entry.Name, sizeof(entry.Name), name.c_str());
String::set(entry.InternalName, sizeof(entry.InternalName), name.c_str());
std::string parkName;
ReadWriteStringTable(cs, parkName, "en-GB");
std::string scenarioDetails;
ReadWriteStringTable(cs, scenarioDetails, "en-GB");
String::Set(entry.Details, sizeof(entry.Details), scenarioDetails.c_str());
String::set(entry.Details, sizeof(entry.Details), scenarioDetails.c_str());
entry.ObjectiveType = cs.Read<uint8_t>();
entry.ObjectiveArg1 = cs.Read<uint8_t>();
@@ -754,12 +754,12 @@ namespace OpenRCT2
for (const auto* ori : ExportObjectsList)
{
auto extension = Path::GetExtension(ori->Path);
if (String::IEquals(extension, ".dat"))
if (String::iequals(extension, ".dat"))
{
cs.Write(DESCRIPTOR_DAT);
cs.Write(&ori->ObjectEntry, sizeof(RCTObjectEntry));
}
else if (String::IEquals(extension, ".parkobj"))
else if (String::iequals(extension, ".parkobj"))
{
cs.Write(DESCRIPTOR_PARKOBJ);
cs.Write(ori->Identifier);
+10 -10
View File
@@ -76,7 +76,7 @@ static bool UploadMinidump(const std::map<std::wstring, std::wstring>& files, in
L"post?format=minidump&token=" BACKTRACE_TOKEN);
std::map<std::wstring, std::wstring> parameters;
parameters[L"product_name"] = L"openrct2";
parameters[L"version"] = String::ToWideChar(gVersionInfoFull);
parameters[L"version"] = String::toWideChar(gVersionInfoFull);
// In case of releases this can be empty
if (wcslen(_wszCommitSha1Short) > 0)
{
@@ -84,13 +84,13 @@ static bool UploadMinidump(const std::map<std::wstring, std::wstring>& files, in
}
else
{
parameters[L"commit"] = String::ToWideChar(gVersionInfoFull);
parameters[L"commit"] = String::toWideChar(gVersionInfoFull);
}
auto assertMsg = Guard::GetLastAssertMessage();
if (assertMsg.has_value())
{
parameters[L"assert_failure"] = String::ToWideChar(assertMsg.value());
parameters[L"assert_failure"] = String::toWideChar(assertMsg.value());
}
int timeout = 10000;
@@ -173,7 +173,7 @@ static bool OnCrash(
wprintf(L"Commit: %s\n", _wszCommitSha1Short);
bool savedGameDumped = false;
auto saveFilePathUTF8 = String::ToUtf8(saveFilePath);
auto saveFilePathUTF8 = String::toUtf8(saveFilePath);
try
{
PrepareMapForSave();
@@ -199,7 +199,7 @@ static bool OnCrash(
_uploadFiles[L"attachment_park.park"] = saveFilePath;
}
auto configFilePathUTF8 = String::ToUtf8(configFilePath);
auto configFilePathUTF8 = String::toUtf8(configFilePath);
if (Config::SaveToPath(configFilePathUTF8))
{
_uploadFiles[L"attachment_config.ini"] = configFilePath;
@@ -219,14 +219,14 @@ static bool OnCrash(
std::string screenshotPath = ScreenshotDump();
if (!screenshotPath.empty())
{
auto screenshotPathW = String::ToWideChar(screenshotPath.c_str());
auto screenshotPathW = String::toWideChar(screenshotPath.c_str());
_uploadFiles[L"attachment_screenshot.png"] = screenshotPathW;
}
}
if (with_record)
{
auto parkReplayPathW = String::ToWideChar(gSilentRecordingName);
auto parkReplayPathW = String::toWideChar(gSilentRecordingName);
bool record_copied = CopyFileW(parkReplayPathW.c_str(), recordFilePathNew, true);
if (record_copied)
{
@@ -321,7 +321,7 @@ static std::wstring GetDumpDirectory()
auto env = GetContext()->GetPlatformEnvironment();
auto crashPath = env->GetDirectoryPath(DIRBASE::USER, DIRID::CRASH);
auto result = String::ToWideChar(crashPath);
auto result = String::toWideChar(crashPath);
return result;
}
@@ -345,14 +345,14 @@ CExceptionHandler CrashInit()
void CrashRegisterAdditionalFile(const std::string& key, const std::string& path)
{
#ifdef USE_BREAKPAD
_uploadFiles[String::ToWideChar(key.c_str())] = String::ToWideChar(path.c_str());
_uploadFiles[String::toWideChar(key.c_str())] = String::toWideChar(path.c_str());
#endif // USE_BREAKPAD
}
void CrashUnregisterAdditionalFile(const std::string& key)
{
#ifdef USE_BREAKPAD
auto it = _uploadFiles.find(String::ToWideChar(key.c_str()));
auto it = _uploadFiles.find(String::toWideChar(key.c_str()));
if (it != _uploadFiles.end())
{
_uploadFiles.erase(it);
+1 -1
View File
@@ -117,7 +117,7 @@ namespace OpenRCT2::Platform
return std::find(_prohibitedCharacters.begin(), _prohibitedCharacters.end(), ch) != _prohibitedCharacters.end();
},
'_');
sanitised = String::Trim(sanitised);
sanitised = String::trim(sanitised);
return sanitised;
}
+3 -3
View File
@@ -38,7 +38,7 @@ namespace OpenRCT2::Platform
{
std::string GetEnvironmentVariable(std::string_view name)
{
return String::ToStd(getenv(std::string(name).c_str()));
return String::toStd(getenv(std::string(name).c_str()));
}
std::string GetEnvironmentPath(const char* name)
@@ -113,7 +113,7 @@ namespace OpenRCT2::Platform
bool FindApp(std::string_view app, std::string* output)
{
return Execute(String::StdFormat("which %s 2> /dev/null", std::string(app).c_str()), output) == 0;
return Execute(String::stdFormat("which %s 2> /dev/null", std::string(app).c_str()), output) == 0;
}
int32_t Execute(std::string_view command, std::string* output)
@@ -219,7 +219,7 @@ namespace OpenRCT2::Platform
// Find a file which matches by name (case insensitive)
for (int32_t i = 0; i < count; i++)
{
if (String::IEquals(files[i]->d_name, fileName.c_str()))
if (String::iequals(files[i]->d_name, fileName.c_str()))
{
result = Path::Combine(directory, std::string(files[i]->d_name));
break;
+18 -18
View File
@@ -60,7 +60,7 @@ namespace OpenRCT2::Platform
std::string GetEnvironmentVariable(std::string_view name)
{
std::wstring result;
auto wname = String::ToWideChar(name);
auto wname = String::toWideChar(name);
wchar_t wvalue[256];
auto valueSize = GetEnvironmentVariableW(wname.c_str(), wvalue, static_cast<DWORD>(std::size(wvalue)));
if (valueSize < std::size(wvalue))
@@ -74,7 +74,7 @@ namespace OpenRCT2::Platform
result = wlvalue;
delete[] wlvalue;
}
return String::ToUtf8(result);
return String::toUtf8(result);
}
static std::string GetHomePathViaEnvironment()
@@ -188,7 +188,7 @@ namespace OpenRCT2::Platform
LOCALE_NAME_USER_DEFAULT, DATE_SHORTDATE, &st, nullptr, date, static_cast<int>(std::size(date)), nullptr);
if (charsWritten != 0)
{
result = String::ToUtf8(std::wstring_view(date, charsWritten - 1));
result = String::toUtf8(std::wstring_view(date, charsWritten - 1));
}
return result;
}
@@ -203,7 +203,7 @@ namespace OpenRCT2::Platform
LOCALE_NAME_USER_DEFAULT, 0, &st, nullptr, time, static_cast<int>(std::size(time)));
if (charsWritten != 0)
{
result = String::ToUtf8(std::wstring_view(time, charsWritten - 1));
result = String::toUtf8(std::wstring_view(time, charsWritten - 1));
}
return result;
}
@@ -302,7 +302,7 @@ namespace OpenRCT2::Platform
wchar_t* wpath = nullptr;
if (SUCCEEDED(SHGetKnownFolderPath(rfid, KF_FLAG_CREATE, nullptr, &wpath)))
{
path = String::ToUtf8(wpath);
path = String::toUtf8(wpath);
}
CoTaskMemFree(wpath);
return path;
@@ -319,7 +319,7 @@ namespace OpenRCT2::Platform
wExePath = std::make_unique<wchar_t[]>(wExePathCapacity);
size = GetModuleFileNameW(hModule, wExePath.get(), wExePathCapacity);
} while (size >= wExePathCapacity);
return String::ToUtf8(wExePath.get());
return String::toUtf8(wExePath.get());
}
u8string StrDecompToPrecomp(u8string_view input)
@@ -357,7 +357,7 @@ namespace OpenRCT2::Platform
static std::wstring GetProdIDName(std::string_view extension)
{
auto progIdName = std::string(OPENRCT2_NAME) + std::string(extension);
auto progIdNameW = String::ToWideChar(progIdName);
auto progIdNameW = String::toWideChar(progIdName);
return progIdNameW;
}
@@ -373,10 +373,10 @@ namespace OpenRCT2::Platform
GetModuleFileNameW(nullptr, exePathW, static_cast<DWORD>(std::size(exePathW)));
GetModuleFileNameW(GetDLLModule(), dllPathW, static_cast<DWORD>(std::size(dllPathW)));
auto extensionW = String::ToWideChar(extension);
auto fileTypeTextW = String::ToWideChar(fileTypeText);
auto commandTextW = String::ToWideChar(commandText);
auto commandArgsW = String::ToWideChar(commandArgs);
auto extensionW = String::toWideChar(extension);
auto fileTypeTextW = String::toWideChar(fileTypeText);
auto commandTextW = String::toWideChar(commandText);
auto commandArgsW = String::toWideChar(commandArgs);
auto progIdNameW = GetProdIDName(extension);
HKEY hKey = nullptr;
@@ -457,7 +457,7 @@ namespace OpenRCT2::Platform
if (RegOpenKeyW(HKEY_CURRENT_USER, SOFTWARE_CLASSES, &hRootKey) == ERROR_SUCCESS)
{
// [hRootKey\.ext]
RegDeleteTreeW(hRootKey, String::ToWideChar(extension).c_str());
RegDeleteTreeW(hRootKey, String::toWideChar(extension).c_str());
// [hRootKey\OpenRCT2.ext]
auto progIdName = GetProdIDName(extension);
@@ -504,7 +504,7 @@ namespace OpenRCT2::Platform
uint64_t GetLastModified(std::string_view path)
{
uint64_t lastModified = 0;
auto pathW = String::ToWideChar(path);
auto pathW = String::toWideChar(path);
auto hFile = CreateFileW(pathW.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
if (hFile != INVALID_HANDLE_VALUE)
{
@@ -522,7 +522,7 @@ namespace OpenRCT2::Platform
uint64_t GetFileSize(std::string_view path)
{
uint64_t size = 0;
auto pathW = String::ToWideChar(path);
auto pathW = String::toWideChar(path);
WIN32_FILE_ATTRIBUTE_DATA attributes;
if (GetFileAttributesExW(pathW.c_str(), GetFileExInfoStandard, &attributes) != FALSE)
{
@@ -570,7 +570,7 @@ namespace OpenRCT2::Platform
DWORD usernameLength = UNLEN + 1;
if (GetUserNameW(usernameW, &usernameLength))
{
result = String::ToUtf8(usernameW);
result = String::toUtf8(usernameW);
}
return result;
}
@@ -634,7 +634,7 @@ namespace OpenRCT2::Platform
return Platform::GetCurrencyValue(nullptr);
}
return Platform::GetCurrencyValue(String::ToUtf8(currCode).c_str());
return Platform::GetCurrencyValue(String::toUtf8(currCode).c_str());
}
MeasurementFormat GetLocaleMeasurementFormat()
@@ -760,7 +760,7 @@ namespace OpenRCT2::Platform
result = RegQueryValueExW(hKey, L"SteamPath", nullptr, &type, reinterpret_cast<LPBYTE>(wSteamPath), &size);
if (result == ERROR_SUCCESS)
{
auto utf8SteamPath = String::ToUtf8(wSteamPath);
auto utf8SteamPath = String::toUtf8(wSteamPath);
outPath = Path::Combine(utf8SteamPath, u8"steamapps", u8"common");
}
free(wSteamPath);
@@ -810,7 +810,7 @@ namespace OpenRCT2::Platform
time_t FileGetModifiedTime(u8string_view path)
{
WIN32_FILE_ATTRIBUTE_DATA data{};
auto wPath = String::ToWideChar(path);
auto wPath = String::toWideChar(path);
auto result = GetFileAttributesExW(wPath.c_str(), GetFileExInfoStandard, &data);
if (result != FALSE)
{
+2 -2
View File
@@ -144,11 +144,11 @@ namespace OpenRCT2::Platform
bool HandleSpecialCommandLineArgument(const char* argument)
{
if (String::Equals(argument, "-NSDocumentRevisionsDebugMode"))
if (String::equals(argument, "-NSDocumentRevisionsDebugMode"))
{
return true;
}
if (String::StartsWith(argument, "-psn_"))
if (String::startsWith(argument, "-psn_"))
{
return true;
}
+6 -6
View File
@@ -149,11 +149,11 @@ namespace OpenRCT2::RCT1
ParkLoadResult Load(const u8string& path) override
{
const auto extension = Path::GetExtension(path);
if (String::IEquals(extension, ".sc4"))
if (String::iequals(extension, ".sc4"))
{
return LoadScenario(path);
}
if (String::IEquals(extension, ".sv4"))
if (String::iequals(extension, ".sv4"))
{
return LoadSavedGame(path);
}
@@ -260,7 +260,7 @@ namespace OpenRCT2::RCT1
desc.title = name.c_str();
}
String::Set(dst->InternalName, sizeof(dst->InternalName), desc.title);
String::set(dst->InternalName, sizeof(dst->InternalName), desc.title);
if (!desc.textObjectId.empty())
{
@@ -282,8 +282,8 @@ namespace OpenRCT2::RCT1
}
}
String::Set(dst->Name, sizeof(dst->Name), name.c_str());
String::Set(dst->Details, sizeof(dst->Details), details.c_str());
String::set(dst->Name, sizeof(dst->Name), name.c_str());
String::set(dst->Details, sizeof(dst->Details), details.c_str());
return true;
}
@@ -2340,7 +2340,7 @@ namespace OpenRCT2::RCT1
void ImportScenarioNameDetails(GameState_t& gameState)
{
std::string name = String::ToStd(_s4.ScenarioName);
std::string name = String::toStd(_s4.ScenarioName);
std::string parkName;
std::string details;
+1 -1
View File
@@ -44,7 +44,7 @@ namespace OpenRCT2::RCT1
bool Load(const utf8* path) override
{
const auto extension = Path::GetExtension(path);
if (String::IEquals(extension, ".td4"))
if (String::iequals(extension, ".td4"))
{
_name = GetNameFromTrackPath(path);
auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN);
+2 -2
View File
@@ -227,7 +227,7 @@ static std::string DecodeConvertWithTable(std::string_view src, TConvertFunc fun
{
u16.push_back(func(cc));
}
return String::ToUtf8(u16);
return String::toUtf8(u16);
}
std::string RCT2StringToUTF8(std::string_view src, RCT2LanguageId languageId)
@@ -240,5 +240,5 @@ std::string RCT2StringToUTF8(std::string_view src, RCT2LanguageId languageId)
}
auto decoded = DecodeToMultiByte(src);
return String::ConvertToUtf8(decoded, codePage);
return String::convertToUtf8(decoded, codePage);
}
+2 -2
View File
@@ -568,7 +568,7 @@ std::string RCT12RemoveFormattingUTF8(std::string_view s)
{
if (!RCT12IsFormatChar(codepoint))
{
String::AppendCodepoint(result, codepoint);
String::appendCodepoint(result, codepoint);
}
}
@@ -657,7 +657,7 @@ std::string ConvertFormattedStringToOpenRCT2(std::string_view buffer)
}
else
{
String::AppendCodepoint(result, codepoint);
String::appendCodepoint(result, codepoint);
}
}
return result;
+17 -17
View File
@@ -127,11 +127,11 @@ namespace OpenRCT2::RCT2
ParkLoadResult Load(const u8string& path) override
{
const auto extension = Path::GetExtension(path);
if (String::IEquals(extension, ".sc6"))
if (String::iequals(extension, ".sc6"))
{
return LoadScenario(path);
}
if (String::IEquals(extension, ".sv6"))
if (String::iequals(extension, ".sv6"))
{
return LoadSavedGame(path);
}
@@ -197,7 +197,7 @@ namespace OpenRCT2::RCT2
if (!path.empty())
{
auto extension = Path::GetExtension(path);
_isSV7 = String::IEquals(extension, ".sv7");
_isSV7 = String::iequals(extension, ".sv7");
}
chunkReader.ReadChunk(&_s6.Objects, sizeof(_s6.Objects));
@@ -255,16 +255,16 @@ namespace OpenRCT2::RCT2
dst->ObjectiveArg3 = _s6.Info.ObjectiveArg3;
dst->Highscore = nullptr;
if (String::IsNullOrEmpty(_s6.Info.Name))
if (String::isNullOrEmpty(_s6.Info.Name))
{
// If the scenario doesn't have a name, set it to the filename
String::Set(dst->Name, sizeof(dst->Name), Path::GetFileNameWithoutExtension(dst->Path).c_str());
String::set(dst->Name, sizeof(dst->Name), Path::GetFileNameWithoutExtension(dst->Path).c_str());
}
else
{
// Normalise the name to make the scenario as recognisable as possible.
auto normalisedName = ScenarioSources::NormaliseName(_s6.Info.Name);
String::Set(dst->Name, sizeof(dst->Name), normalisedName.c_str());
String::set(dst->Name, sizeof(dst->Name), normalisedName.c_str());
}
// Look up and store information regarding the origins of this scenario.
@@ -291,8 +291,8 @@ namespace OpenRCT2::RCT2
}
// dst->name will be translated later so keep the untranslated name here
String::Set(dst->InternalName, sizeof(dst->InternalName), dst->Name);
String::Set(dst->Details, sizeof(dst->Details), _s6.Info.Details);
String::set(dst->InternalName, sizeof(dst->InternalName), dst->Name);
String::set(dst->Details, sizeof(dst->Details), _s6.Info.Details);
if (!desc.textObjectId.empty())
{
@@ -312,8 +312,8 @@ namespace OpenRCT2::RCT2
auto name = textObject->GetScenarioName();
auto details = textObject->GetScenarioDetails();
String::Set(dst->Name, sizeof(dst->Name), name.c_str());
String::Set(dst->Details, sizeof(dst->Details), details.c_str());
String::set(dst->Name, sizeof(dst->Name), name.c_str());
String::set(dst->Details, sizeof(dst->Details), details.c_str());
}
}
@@ -534,7 +534,7 @@ namespace OpenRCT2::RCT2
{
// For savegames the filename can be arbitrary, so we have no choice but to rely on the name provided
gameState.ScenarioFileName = std::string(
String::ToStringView(_s6.ScenarioFilename, std::size(_s6.ScenarioFilename)));
String::toStringView(_s6.ScenarioFilename, std::size(_s6.ScenarioFilename)));
}
gCurrentRealTimeTicks = 0;
@@ -1139,26 +1139,26 @@ namespace OpenRCT2::RCT2
// and the corrected filename.
// In this park, peep_spawns[0] is incorrect, and peep_spawns[1] is correct.
if (String::Equals(_s6.ScenarioFilename, "WW South America - Rio Carnival.SC6")
|| String::Equals(_s6.ScenarioFilename, "South America - Rio Carnival.SC6"))
if (String::equals(_s6.ScenarioFilename, "WW South America - Rio Carnival.SC6")
|| String::equals(_s6.ScenarioFilename, "South America - Rio Carnival.SC6"))
{
_s6.PeepSpawns[0] = { 2160, 3167, 6, 1 };
_s6.PeepSpawns[1].x = RCT12_PEEP_SPAWN_UNDEFINED;
}
// In this park, peep_spawns[0] is correct. Just clear the other.
else if (
String::Equals(_s6.ScenarioFilename, "Great Wall of China Tourism Enhancement.SC6")
|| String::Equals(_s6.ScenarioFilename, "Asia - Great Wall of China Tourism Enhancement.SC6"))
String::equals(_s6.ScenarioFilename, "Great Wall of China Tourism Enhancement.SC6")
|| String::equals(_s6.ScenarioFilename, "Asia - Great Wall of China Tourism Enhancement.SC6"))
{
_s6.PeepSpawns[1].x = RCT12_PEEP_SPAWN_UNDEFINED;
}
// Amity Airfield has peeps entering from the corner of the tile, instead of the middle.
else if (String::Equals(_s6.ScenarioFilename, "Amity Airfield.SC6"))
else if (String::equals(_s6.ScenarioFilename, "Amity Airfield.SC6"))
{
_s6.PeepSpawns[0].y = 1296;
}
// #9926: Africa - Oasis has peeps spawning on the edge underground near the entrance
else if (String::Equals(_s6.ScenarioFilename, "Africa - Oasis.SC6"))
else if (String::equals(_s6.ScenarioFilename, "Africa - Oasis.SC6"))
{
_s6.PeepSpawns[0].y = 2128;
_s6.PeepSpawns[0].z = 7;
+1 -1
View File
@@ -47,7 +47,7 @@ namespace OpenRCT2::RCT2
bool Load(const utf8* path) override
{
const auto extension = Path::GetExtension(path);
if (String::IEquals(extension, ".td6"))
if (String::iequals(extension, ".td6"))
{
_name = GetNameFromTrackPath(path);
auto fs = OpenRCT2::FileStream(path, OpenRCT2::FILE_MODE_OPEN);
+4 -4
View File
@@ -104,7 +104,7 @@ protected:
private:
bool IsTrackReadOnly(const std::string& path) const
{
return String::StartsWith(path, SearchPaths[0]) || String::StartsWith(path, SearchPaths[1]);
return String::startsWith(path, SearchPaths[0]) || String::startsWith(path, SearchPaths[1]);
}
};
@@ -154,7 +154,7 @@ public:
entryIsNotSeparate = true;
}
if (entryIsNotSeparate || String::IEquals(item.ObjectEntry, entry))
if (entryIsNotSeparate || String::iequals(item.ObjectEntry, entry))
{
count++;
}
@@ -188,7 +188,7 @@ public:
entryIsNotSeparate = true;
}
if (entryIsNotSeparate || String::IEquals(item.ObjectEntry, entry))
if (entryIsNotSeparate || String::iequals(item.ObjectEntry, entry))
{
TrackDesignFileRef ref;
ref.name = GetNameFromTrackPath(item.Path);
@@ -281,7 +281,7 @@ private:
{
return a.RideType < b.RideType;
}
return String::StrLogicalCmp(a.Name.c_str(), b.Name.c_str()) < 0;
return String::logicalCmp(a.Name.c_str(), b.Name.c_str()) < 0;
});
}
+11 -11
View File
@@ -182,7 +182,7 @@ protected:
private:
static std::unique_ptr<IStream> GetStreamFromRCT2Scenario(const std::string& path)
{
if (String::IEquals(Path::GetExtension(path), ".sea"))
if (String::iequals(Path::GetExtension(path), ".sea"))
{
auto data = DecryptSea(fs::u8path(path));
auto ms = std::make_unique<MemoryStream>();
@@ -208,12 +208,12 @@ private:
std::unique_ptr<IParkImporter> importer;
std::string extension = Path::GetExtension(path);
if (String::IEquals(extension, ".park"))
if (String::iequals(extension, ".park"))
{
importer = ParkImporter::CreateParkFile(objRepository);
importer->LoadScenario(path, true);
}
else if (String::IEquals(extension, ".sc4"))
else if (String::iequals(extension, ".sc4"))
{
importer = ParkImporter::CreateS4();
importer->LoadScenario(path, true);
@@ -309,7 +309,7 @@ public:
const auto scenarioFilename = Path::GetFileName(scenario.Path);
// Note: this is always case insensitive search for cross platform consistency
if (String::IEquals(filename, scenarioFilename))
if (String::iequals(filename, scenarioFilename))
{
return &scenario;
}
@@ -327,7 +327,7 @@ public:
continue;
// Note: this is always case insensitive search for cross platform consistency
if (String::IEquals(name, scenario->InternalName))
if (String::iequals(name, scenario->InternalName))
{
return &_scenarios[i];
}
@@ -361,19 +361,19 @@ public:
const std::string scenarioExtension = Path::GetExtension(scenarioFileName);
// Check if this is an RCTC scenario that corresponds to a known RCT1/2 scenario or vice versa, see #12626
if (String::IEquals(scenarioExtension, ".sea"))
if (String::iequals(scenarioExtension, ".sea"))
{
// Get scenario using RCT2 style name of RCTC scenario
scenario = GetByFilename((scenarioBaseName + ".sc6").c_str());
}
else if (String::IEquals(scenarioExtension, ".sc6"))
else if (String::iequals(scenarioExtension, ".sc6"))
{
// Get scenario using RCTC style name of RCT2 scenario
scenario = GetByFilename((scenarioBaseName + ".sea").c_str());
}
// GameState_t::ScenarioFileName .Park scenarios is the full file path instead of just <scenarioName.park>, so need
// to convert
else if (String::IEquals(scenarioExtension, ".park"))
else if (String::iequals(scenarioExtension, ".park"))
{
scenario = GetByFilename((scenarioBaseName + ".park").c_str());
}
@@ -417,7 +417,7 @@ private:
const auto scenarioFilename = Path::GetFileName(scenario.Path);
// Note: this is always case insensitive search for cross platform consistency
if (String::IEquals(filename, scenarioFilename))
if (String::iequals(filename, scenarioFilename))
{
return &scenario;
}
@@ -474,7 +474,7 @@ private:
{
auto filename = Path::GetFileName(entry.Path);
if (!String::Equals(filename, ""))
if (!String::equals(filename, ""))
{
auto existingEntry = GetByFilename(filename.c_str());
if (existingEntry != nullptr)
@@ -602,7 +602,7 @@ private:
bool notFound = true;
for (auto& highscore : _highscores)
{
if (String::IEquals(scBasic.Path, highscore->fileName))
if (String::iequals(scBasic.Path, highscore->fileName))
{
notFound = false;
+3 -3
View File
@@ -367,7 +367,7 @@ namespace OpenRCT2::ScenarioSources
for (size_t j = 0; j < std::size(ScenarioTitlesBySource[i]); j++)
{
const ScenarioTitleDescriptor* desc = &ScenarioTitlesBySource[i][j];
if (String::IEquals(name, desc->Title))
if (String::iequals(name, desc->Title))
{
outDesc->title = desc->Title;
outDesc->id = desc->Id;
@@ -445,13 +445,13 @@ namespace OpenRCT2::ScenarioSources
}
// Trim (for the sake of the above and WW / TT scenarios)
normalisedName = String::TrimStart(normalisedName);
normalisedName = String::trimStart(normalisedName);
// American scenario titles should be converted to British name
// Don't worry, names will be translated using language packs later
for (const ScenarioAlias& alias : ScenarioAliases)
{
if (String::Equals(alias.Alternative, normalisedName))
if (String::equals(alias.Alternative, normalisedName))
{
LOG_VERBOSE("Found alias: %s; will treat as: %s", normalisedName.c_str(), alias.Original);
return u8string(alias.Original);
+24 -24
View File
@@ -56,7 +56,7 @@ namespace OpenRCT2::Title
LOG_VERBOSE("Loading title sequence: %s", path.c_str());
auto ext = Path::GetExtension(path);
if (String::Equals(ext, TITLE_SEQUENCE_EXTENSION))
if (String::equals(ext, TITLE_SEQUENCE_EXTENSION))
{
auto zip = Zip::TryOpen(path, ZIP_ACCESS::READ);
if (zip == nullptr)
@@ -318,7 +318,7 @@ namespace OpenRCT2::Title
{
auto name = zip->GetFileName(i);
auto ext = Path::GetExtension(name);
if (String::IEquals(ext, ".sv6") || String::IEquals(ext, ".sc6") || String::IEquals(ext, ".park"))
if (String::iequals(ext, ".sv6") || String::iequals(ext, ".sc6") || String::iequals(ext, ".park"))
{
saves.push_back(std::move(name));
}
@@ -340,13 +340,13 @@ namespace OpenRCT2::Title
if (token[0] != 0)
{
if (String::IEquals(token, "LOAD"))
if (String::iequals(token, "LOAD"))
{
auto saveIndex = SAVE_INDEX_INVALID;
const std::string relativePath = parts[1].data();
for (size_t i = 0; i < saves.size(); i++)
{
if (String::IEquals(relativePath, saves[i]))
if (String::iequals(relativePath, saves[i]))
{
saveIndex = static_cast<uint8_t>(i);
break;
@@ -354,51 +354,51 @@ namespace OpenRCT2::Title
}
command = LoadParkCommand{ saveIndex };
}
else if (String::IEquals(token, "LOCATION"))
else if (String::iequals(token, "LOCATION"))
{
uint8_t locationX = atoi(parts[1].data()) & 0xFF;
uint8_t locationY = atoi(parts[2].data()) & 0xFF;
command = SetLocationCommand{ locationX, locationY };
}
else if (String::IEquals(token, "ROTATE"))
else if (String::iequals(token, "ROTATE"))
{
uint8_t rotations = atoi(parts[1].data()) & 0xFF;
command = RotateViewCommand{ rotations };
}
else if (String::IEquals(token, "ZOOM"))
else if (String::iequals(token, "ZOOM"))
{
uint8_t zoom = atoi(parts[1].data()) & 0xFF;
command = SetZoomCommand{ zoom };
}
else if (String::IEquals(token, "SPEED"))
else if (String::iequals(token, "SPEED"))
{
uint8_t speed = std::max(1, std::min(4, atoi(parts[1].data()) & 0xFF));
command = SetSpeedCommand{ speed };
}
else if (String::IEquals(token, "FOLLOW"))
else if (String::iequals(token, "FOLLOW"))
{
auto entityID = EntityId::FromUnderlying(atoi(parts[1].data()) & 0xFFFF);
auto followCommand = FollowEntityCommand{ entityID };
String::SafeStrCpy(followCommand.Follow.SpriteName, parts[2].data(), kUserStringMaxLength);
String::safeUtf8Copy(followCommand.Follow.SpriteName, parts[2].data(), kUserStringMaxLength);
command = followCommand;
}
else if (String::IEquals(token, "WAIT"))
else if (String::iequals(token, "WAIT"))
{
uint16_t milliseconds = atoi(parts[1].data()) & 0xFFFF;
command = WaitCommand{ milliseconds };
}
else if (String::IEquals(token, "RESTART"))
else if (String::iequals(token, "RESTART"))
{
command = RestartCommand{};
}
else if (String::IEquals(token, "END"))
else if (String::iequals(token, "END"))
{
command = EndCommand{};
}
else if (String::IEquals(token, "LOADSC"))
else if (String::iequals(token, "LOADSC"))
{
auto loadScenarioCommand = LoadScenarioCommand{};
String::SafeStrCpy(loadScenarioCommand.Scenario, parts[1].data(), sizeof(loadScenarioCommand.Scenario));
String::safeUtf8Copy(loadScenarioCommand.Scenario, parts[1].data(), sizeof(loadScenarioCommand.Scenario));
command = loadScenarioCommand;
}
}
@@ -444,12 +444,12 @@ namespace OpenRCT2::Title
if (!whitespace)
{
if (part == 0
&& ((cindex == 4 && String::StartsWith(parts[0].data(), "LOAD", true))
|| (cindex == 6 && String::StartsWith(parts[0].data(), "LOADSC", true))))
&& ((cindex == 4 && String::startsWith(parts[0].data(), "LOAD", true))
|| (cindex == 6 && String::startsWith(parts[0].data(), "LOADSC", true))))
{
load = true;
}
else if (part == 0 && cindex == 6 && String::StartsWith(parts[0].data(), "FOLLOW", true))
else if (part == 0 && cindex == 6 && String::startsWith(parts[0].data(), "FOLLOW", true))
{
sprite = true;
}
@@ -533,28 +533,28 @@ namespace OpenRCT2::Title
}
else if constexpr (std::is_same_v<T, SetLocationCommand>)
{
sb.Append(String::StdFormat("LOCATION %u %u", command.Location.X, command.Location.Y));
sb.Append(String::stdFormat("LOCATION %u %u", command.Location.X, command.Location.Y));
}
else if constexpr (std::is_same_v<T, RotateViewCommand>)
{
sb.Append(String::StdFormat("ROTATE %u", command.Rotations));
sb.Append(String::stdFormat("ROTATE %u", command.Rotations));
}
else if constexpr (std::is_same_v<T, SetZoomCommand>)
{
sb.Append(String::StdFormat("ZOOM %u", command.Zoom));
sb.Append(String::stdFormat("ZOOM %u", command.Zoom));
}
else if constexpr (std::is_same_v<T, FollowEntityCommand>)
{
sb.Append(String::StdFormat("FOLLOW %u ", command.Follow.SpriteIndex));
sb.Append(String::stdFormat("FOLLOW %u ", command.Follow.SpriteIndex));
sb.Append(command.Follow.SpriteName);
}
else if constexpr (std::is_same_v<T, SetSpeedCommand>)
{
sb.Append(String::StdFormat("SPEED %u", command.Speed));
sb.Append(String::stdFormat("SPEED %u", command.Speed));
}
else if constexpr (std::is_same_v<T, WaitCommand>)
{
sb.Append(String::StdFormat("WAIT %u", command.Milliseconds));
sb.Append(String::stdFormat("WAIT %u", command.Milliseconds));
}
else if constexpr (std::is_same_v<T, RestartCommand>)
{
@@ -168,7 +168,7 @@ namespace OpenRCT2::TitleSequenceManager
auto filename = Path::GetFileName(path);
for (size_t i = 0; i < std::size(PredefinedSequences); i++)
{
if (String::IEquals(filename, PredefinedSequences[i].Filename))
if (String::iequals(filename, PredefinedSequences[i].Filename))
{
return i;
}
@@ -184,7 +184,7 @@ namespace OpenRCT2::TitleSequenceManager
{
return a.PredefinedIndex < b.PredefinedIndex;
}
return String::Compare(a.Name, b.Name, true) < 0;
return String::compare(a.Name, b.Name, true) < 0;
});
}
@@ -215,7 +215,7 @@ namespace OpenRCT2::TitleSequenceManager
{
Item item{};
if (String::IEquals(Path::GetExtension(scanPath), u8".txt"))
if (String::iequals(Path::GetExtension(scanPath), u8".txt"))
{
// If we are given a .txt file, set the path to the containing directory
item.Path = Path::GetDirectory(scanPath);
@@ -268,7 +268,7 @@ namespace OpenRCT2::TitleSequenceManager
{
for (const auto& pseq : TitleSequenceManager::PredefinedSequences)
{
if (String::IEquals(name, pseq.ConfigId))
if (String::iequals(name, pseq.ConfigId))
{
return true;
}
@@ -307,7 +307,7 @@ namespace OpenRCT2::TitleSequenceManager
const auto filename = Path::GetFileName(item->Path);
for (const auto& pseq : PredefinedSequences)
{
if (String::IEquals(filename, pseq.Filename))
if (String::iequals(filename, pseq.Filename))
{
return pseq.ConfigId;
}
@@ -332,7 +332,7 @@ namespace OpenRCT2::TitleSequenceManager
for (size_t i = 0; i < count; i++)
{
const utf8* cid = GetConfigID(i);
if (String::Equals(cid, configId))
if (String::equals(cid, configId))
{
return i;
}
@@ -346,7 +346,7 @@ namespace OpenRCT2::TitleSequenceManager
for (size_t i = 0; i < count; i++)
{
const utf8* tn = GetName(i);
if (String::Equals(tn, name))
if (String::equals(tn, name))
{
return i;
}
@@ -64,7 +64,7 @@ namespace OpenRCT2::Scripting
static std::string TransformPermissionKeyToInternal(const std::string& s)
{
return "PERMISSION_" + String::ToUpper(s);
return "PERMISSION_" + String::toUpper(s);
}
#endif
+1 -1
View File
@@ -324,7 +324,7 @@ namespace OpenRCT2::Park
AwardReset();
gameState.ScenarioName.clear();
gameState.ScenarioDetails = String::ToStd(LanguageGetString(STR_NO_DETAILS_YET));
gameState.ScenarioDetails = String::toStd(LanguageGetString(STR_NO_DETAILS_YET));
}
void Update(GameState_t& gameState, const Date& date)
+2 -2
View File
@@ -39,7 +39,7 @@ TEST_F(FmtStringTests, iteration)
auto fmt = FmtString("{BLACK}Guests: {INT32}");
for (const auto& t : fmt)
{
actual += String::StdFormat("[%d:%s]", t.kind, std::string(t.text).c_str());
actual += String::stdFormat("[%d:%s]", t.kind, std::string(t.text).c_str());
}
ASSERT_EQ("[31:{BLACK}][1:Guests: ][8:{INT32}]", actual);
@@ -52,7 +52,7 @@ TEST_F(FmtStringTests, iteration_escaped)
auto fmt = FmtString("This is an {{ESCAPED}} string.");
for (const auto& t : fmt)
{
actual += String::StdFormat("[%d:%s]", t.kind, std::string(t.text).c_str());
actual += String::stdFormat("[%d:%s]", t.kind, std::string(t.text).c_str());
}
ASSERT_EQ("[1:This is an ][2:{{][1:ESCAPED][2:}}][1: string.]", actual);
+1 -1
View File
@@ -60,7 +60,7 @@ protected:
for (auto& ride : GetRideManager())
{
auto thisName = ride.GetName();
if (String::StartsWith(thisName, u8string{ name }, true))
if (String::startsWith(thisName, u8string{ name }, true))
{
return &ride;
}
+1 -1
View File
@@ -49,7 +49,7 @@ protected:
{
RatingTuple ratings = ride.ratings;
auto name = std::string(ride.GetRideTypeDescriptor().Name);
std::string line = String::StdFormat(
std::string line = String::stdFormat(
"%s: (%d, %d, %d)", name.c_str(), static_cast<int>(ratings.excitement), static_cast<int>(ratings.intensity),
static_cast<int>(ratings.nausea));
return line;
Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff. Show more