From 20b688dbac759faef2815884f344712c366687bf Mon Sep 17 00:00:00 2001 From: oltolm Date: Thu, 1 Jan 2026 02:53:47 +0100 Subject: [PATCH] use ToStdString and wc_string --- src/gui/wxgui/MemorySearcherTool.cpp | 38 +++++++++---------- src/gui/wxgui/MemorySearcherTool.h | 18 +++------ src/gui/wxgui/TitleManager.cpp | 2 +- src/gui/wxgui/debugger/BreakpointWindow.cpp | 2 +- .../CreateAccount/wxCreateAccountDialog.cpp | 4 +- src/gui/wxgui/helpers/wxHelpers.h | 2 +- 6 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/gui/wxgui/MemorySearcherTool.cpp b/src/gui/wxgui/MemorySearcherTool.cpp index 94840363..5cdfacc4 100644 --- a/src/gui/wxgui/MemorySearcherTool.cpp +++ b/src/gui/wxgui/MemorySearcherTool.cpp @@ -330,19 +330,19 @@ void MemorySearcherTool::Save() { fs->writeLine("[Entry]"); - std::string tmp = "description=" + std::string(m_listEntryTable->GetTextValue(i, 0).mbc_str()); + std::string tmp = "description=" + m_listEntryTable->GetTextValue(i, 0).ToStdString(); fs->writeLine(tmp.c_str()); - tmp = "address=" + std::string(m_listEntryTable->GetTextValue(i, 1).mbc_str()); + tmp = "address=" + m_listEntryTable->GetTextValue(i, 1).ToStdString(); fs->writeLine(tmp.c_str()); - tmp = "type=" + std::string(m_listEntryTable->GetTextValue(i, 2).mbc_str()); + tmp = "type=" + m_listEntryTable->GetTextValue(i, 2).ToStdString(); fs->writeLine(tmp.c_str()); // only save value when FREEZE is active if (m_listEntryTable->GetToggleValue(i, 4)) { - tmp = "value=" + std::string(m_listEntryTable->GetTextValue(i, 3).mbc_str()); + tmp = "value=" + m_listEntryTable->GetTextValue(i, 3).ToStdString(); } else { @@ -420,9 +420,7 @@ void MemorySearcherTool::Reset() bool MemorySearcherTool::VerifySearchValue() const { - const auto s1 = m_textValue->GetValue(); - const auto s2 = s1.c_str(); - const auto inputString = s2.AsChar(); + const auto inputString = m_textValue->GetValue().ToStdString(); switch (m_searchDataType) { @@ -543,10 +541,10 @@ void MemorySearcherTool::RefreshStashList() { auto freeze = m_listEntryTable->GetToggleValue(i, 4); - auto addressText = std::string(m_listEntryTable->GetTextValue(i, 1).mbc_str()); - auto type = std::string(m_listEntryTable->GetTextValue(i, 2).mbc_str()); + auto addressText = m_listEntryTable->GetTextValue(i, 1).ToStdString(); + auto type = m_listEntryTable->GetTextValue(i, 2); - auto address = stol(addressText, nullptr, 16); + auto address = std::stol(addressText, nullptr, 16); // if freeze is activated, set the value instead of refreshing it if (freeze) @@ -580,13 +578,13 @@ void MemorySearcherTool::RefreshStashList() } else if (type == kDatatypeInt64) { - auto valueText = std::string(var.GetString().mbc_str()); - auto value = stoull(valueText); + auto valueText = var.GetString().ToStdString(); + auto value = std::stoull(valueText); memory_writeU64(address, value); } else if (type == kDatatypeString) { - auto valueText = std::string(var.GetString().mbc_str()); + auto valueText = var.GetString().ToStdString(); for (int i = 0; i < valueText.size(); ++i) { memory_writeU8(address + i, valueText[i]); @@ -655,8 +653,8 @@ void MemorySearcherTool::SetSearchDataType() m_searchDataType = SearchDataType_None; } -template <> -bool MemorySearcherTool::ConvertStringToType(const char* inValue, sint8& outValue) const +template<> +bool MemorySearcherTool::ConvertStringToType(const std::string& inValue, sint8& outValue) const { sint16 tmp; std::istringstream iss(inValue); @@ -696,8 +694,8 @@ void MemorySearcherTool::OnItemEdited(wxDataViewEvent& event) if (row == wxNOT_FOUND) return; - auto addressText = std::string(m_listEntryTable->GetTextValue(row, 1).mbc_str()); - uint32 address = stoul(addressText, nullptr, 16); + auto addressText = m_listEntryTable->GetTextValue(row, 1).ToStdString(); + uint32 address = std::stoul(addressText, nullptr, 16); auto type = m_listEntryTable->GetTextValue(row, 2); if (type == kDatatypeFloat) @@ -727,13 +725,13 @@ void MemorySearcherTool::OnItemEdited(wxDataViewEvent& event) } else if (type == kDatatypeInt64) { - auto valueText = std::string(event.GetValue().GetString().mbc_str()); - auto value = stoull(valueText); + auto valueText = event.GetValue().GetString().ToStdString(); + auto value = std::stoull(valueText); memory_writeU64(address, value); } else if (type == kDatatypeString) { - auto valueText = std::string(event.GetValue().GetString().mbc_str()); + auto valueText = event.GetValue().GetString().ToStdString(); for (int i = 0; i < valueText.size(); ++i) { memory_writeU8(address + i, valueText[i]); diff --git a/src/gui/wxgui/MemorySearcherTool.h b/src/gui/wxgui/MemorySearcherTool.h index 3d6c0d87..495b60da 100644 --- a/src/gui/wxgui/MemorySearcherTool.h +++ b/src/gui/wxgui/MemorySearcherTool.h @@ -65,8 +65,8 @@ private: static bool IsAddressValid(uint32 addr); - template - bool ConvertStringToType(const char* inValue, T& outValue) const + template + bool ConvertStringToType(const std::string& inValue, T& outValue) const { std::istringstream iss(inValue); iss >> std::noskipws >> outValue; @@ -117,9 +117,7 @@ private: template ListType_t SearchValues(T* ptr, uint32 size) { - const auto value = m_textValue->GetValue(); - const auto* string_value = value.c_str().AsChar(); - const auto search_value = ConvertString(string_value); + const auto search_value = ConvertString(m_textValue->GetValue().ToStdString()); const auto* end = (T*)((uint8*)ptr + size - sizeof(T)); @@ -148,9 +146,7 @@ private: template ListType_t FilterValues() { - const auto value = m_textValue->GetValue(); - const auto* string_value = value.c_str().AsChar(); - const auto search_value = ConvertString(string_value); + const auto search_value = ConvertString(m_textValue->GetValue().ToStdString()); ListType_t newSearchBuffer; newSearchBuffer.reserve(m_searchBuffer.size()); @@ -195,10 +191,8 @@ wxDECLARE_EVENT_TABLE(); bool m_clear_state = false; }; -template <> -bool MemorySearcherTool::ConvertStringToType(const char* inValue, sint8& outValue) const; - - +template<> +bool MemorySearcherTool::ConvertStringToType(const std::string& inValue, sint8& outValue) const; // //template diff --git a/src/gui/wxgui/TitleManager.cpp b/src/gui/wxgui/TitleManager.cpp index 4dbf9341..a4e191c9 100644 --- a/src/gui/wxgui/TitleManager.cpp +++ b/src/gui/wxgui/TitleManager.cpp @@ -382,7 +382,7 @@ void TitleManager::OnInstallTitle(wxCommandEvent& event) if (openFileDialog.ShowModal() == wxID_CANCEL || openFileDialog.GetPath().IsEmpty()) return; - fs::path filePath(openFileDialog.GetPath().wc_str()); + fs::path filePath(openFileDialog.GetPath().wc_string()); try { filePath = filePath.parent_path(); diff --git a/src/gui/wxgui/debugger/BreakpointWindow.cpp b/src/gui/wxgui/debugger/BreakpointWindow.cpp index 63d5a733..8431b0ee 100644 --- a/src/gui/wxgui/debugger/BreakpointWindow.cpp +++ b/src/gui/wxgui/debugger/BreakpointWindow.cpp @@ -153,7 +153,7 @@ void BreakpointWindow::OnBreakpointToggled(wxListEvent& event) const bool state = m_breakpoints->IsItemChecked(index); wxString line = m_breakpoints->GetItemText(index, ColumnAddress); DebuggerBreakpoint* bp = (DebuggerBreakpoint*)m_breakpoints->GetItemData(index); - const uint32 address = std::stoul(line.c_str().AsChar(), nullptr, 16); + const uint32 address = std::stoul(line.ToStdString(), nullptr, 16); debugger_toggleBreakpoint(address, state, bp); m_breakpoints->CheckItem(index, state); } diff --git a/src/gui/wxgui/dialogs/CreateAccount/wxCreateAccountDialog.cpp b/src/gui/wxgui/dialogs/CreateAccount/wxCreateAccountDialog.cpp index 4e309113..dbe17be4 100644 --- a/src/gui/wxgui/dialogs/CreateAccount/wxCreateAccountDialog.cpp +++ b/src/gui/wxgui/dialogs/CreateAccount/wxCreateAccountDialog.cpp @@ -52,7 +52,7 @@ wxCreateAccountDialog::wxCreateAccountDialog(wxWindow* parent) uint32 wxCreateAccountDialog::GetPersistentId() const { - const std::string id_string = m_persistent_id->GetValue().c_str().AsChar(); + const std::string id_string = m_persistent_id->GetValue().ToStdString(); return ConvertString(id_string, 16); } @@ -98,4 +98,4 @@ void wxCreateAccountDialog::OnOK(wxCommandEvent& event) void wxCreateAccountDialog::OnCancel(wxCommandEvent& event) { EndModal(wxID_CANCEL); -} \ No newline at end of file +} diff --git a/src/gui/wxgui/helpers/wxHelpers.h b/src/gui/wxgui/helpers/wxHelpers.h index 006babb5..fa42338b 100644 --- a/src/gui/wxgui/helpers/wxHelpers.h +++ b/src/gui/wxgui/helpers/wxHelpers.h @@ -11,7 +11,7 @@ struct fmt::formatter : formatter template auto format(const wxString& str, FormatContext& ctx) const { - return formatter::format(str.c_str().AsChar(), ctx); + return formatter::format(str.ToStdString(), ctx); } };