use ToStdString and wc_string

This commit is contained in:
oltolm 2026-01-01 02:53:47 +01:00
parent 68bad90890
commit 20b688dbac
6 changed files with 29 additions and 37 deletions

View File

@ -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<signed char>(const char* inValue, sint8& outValue) const
template<>
bool MemorySearcherTool::ConvertStringToType<signed char>(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]);

View File

@ -65,8 +65,8 @@ private:
static bool IsAddressValid(uint32 addr);
template <typename T>
bool ConvertStringToType(const char* inValue, T& outValue) const
template<typename T>
bool ConvertStringToType(const std::string& inValue, T& outValue) const
{
std::istringstream iss(inValue);
iss >> std::noskipws >> outValue;
@ -117,9 +117,7 @@ private:
template <typename T>
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<T>(string_value);
const auto search_value = ConvertString<T>(m_textValue->GetValue().ToStdString());
const auto* end = (T*)((uint8*)ptr + size - sizeof(T));
@ -148,9 +146,7 @@ private:
template <typename T>
ListType_t FilterValues()
{
const auto value = m_textValue->GetValue();
const auto* string_value = value.c_str().AsChar();
const auto search_value = ConvertString<T>(string_value);
const auto search_value = ConvertString<T>(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 <typename T>

View File

@ -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();

View File

@ -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);
}

View File

@ -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<uint32>(id_string, 16);
}
@ -98,4 +98,4 @@ void wxCreateAccountDialog::OnOK(wxCommandEvent& event)
void wxCreateAccountDialog::OnCancel(wxCommandEvent& event)
{
EndModal(wxID_CANCEL);
}
}

View File

@ -11,7 +11,7 @@ struct fmt::formatter<wxString> : formatter<string_view>
template <typename FormatContext>
auto format(const wxString& str, FormatContext& ctx) const
{
return formatter<string_view>::format(str.c_str().AsChar(), ctx);
return formatter<string_view>::format(str.ToStdString(), ctx);
}
};