replace all instances of wxString with std::string in all cases not

directly involved in either the GUI or other wxWidget classes like wxFile
This commit is contained in:
Peter Tissen 2014-04-01 02:33:55 +02:00
parent b1894ac6cb
commit 8ac226ae69
124 changed files with 1716 additions and 1502 deletions

View file

@ -12,20 +12,20 @@ LogFrame* ConLogFrame;
std::mutex g_cs_conlog;
static const uint max_item_count = 500;
static const uint buffer_size = 1024 * 64 * sizeof(wxChar);
static const uint buffer_size = 1024 * 64;
static const wxString g_log_colors[] =
static const std::string g_log_colors[] =
{
"Black", "Green", "White", "Yellow", "Red",
};
struct LogPacket
{
wxString m_prefix;
wxString m_text;
wxString m_colour;
const std::string m_prefix;
const std::string m_text;
const std::string m_colour;
LogPacket(const wxString& prefix, const wxString& text, const wxString& colour)
LogPacket(const std::string& prefix, const std::string& text, const std::string& colour)
: m_prefix(prefix)
, m_text(text)
, m_colour(colour)
@ -42,9 +42,9 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
void _push(const LogPacket& data)
{
const u32 sprefix = data.m_prefix.length() * sizeof(wxChar);
const u32 stext = data.m_text.length() * sizeof(wxChar);
const u32 scolour = data.m_colour.length() * sizeof(wxChar);
const u32 sprefix = data.m_prefix.length();
const u32 stext = data.m_text.length();
const u32 scolour = data.m_colour.length();
m_buffer.Reserve(
sizeof(u32) + sprefix +
@ -55,17 +55,17 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
memcpy(&m_buffer[c_put], &sprefix, sizeof(u32));
c_put += sizeof(u32);
memcpy(&m_buffer[c_put], data.m_prefix.wx_str(), sprefix);
memcpy(&m_buffer[c_put], data.m_prefix.c_str(), sprefix);
c_put += sprefix;
memcpy(&m_buffer[c_put], &stext, sizeof(u32));
c_put += sizeof(u32);
memcpy(&m_buffer[c_put], data.m_text.wx_str(), stext);
memcpy(&m_buffer[c_put], data.m_text.c_str(), stext);
c_put += stext;
memcpy(&m_buffer[c_put], &scolour, sizeof(u32));
c_put += sizeof(u32);
memcpy(&m_buffer[c_put], data.m_colour.wx_str(), scolour);
memcpy(&m_buffer[c_put], data.m_colour.c_str(), scolour);
c_put += scolour;
m_put = c_put;
@ -78,17 +78,17 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
const u32& sprefix = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32);
const wxString& prefix = wxString((wxChar*)&m_buffer[c_get], sprefix / sizeof(wxChar));
const std::string prefix( (const char*) &m_buffer[c_get], sprefix);
c_get += sprefix;
const u32& stext = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32);
const wxString& text = wxString((wxChar*)&m_buffer[c_get], stext / sizeof(wxChar));
const std::string text( (const char*) &m_buffer[c_get], stext);
c_get += stext;
const u32& scolour = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32);
const wxString& colour = wxString((wxChar*)&m_buffer[c_get], scolour / sizeof(wxChar));
const std::string colour( (const char*) &m_buffer[c_get], scolour);
c_get += scolour;
m_get = c_get;
@ -108,9 +108,9 @@ LogWriter::LogWriter()
}
}
void LogWriter::WriteToLog(const wxString& prefix, const wxString& value, u8 lvl/*, wxColour bgcolour*/)
void LogWriter::WriteToLog(const std::string& prefix, const std::string& value, u8 lvl/*, wxColour bgcolour*/)
{
wxString new_prefix = prefix;
std::string new_prefix = prefix;
if(!prefix.empty())
{
if(NamedThreadBase* thr = GetCurrentNamedThread())
@ -120,7 +120,7 @@ void LogWriter::WriteToLog(const wxString& prefix, const wxString& value, u8 lvl
}
if(m_logfile.IsOpened() && !new_prefix.empty())
m_logfile.Write(wxString("[") + new_prefix + "]: " + value + "\n");
m_logfile.Write(fmt::FromUTF8("[" + new_prefix + "]: " + value + "\n"));
if(!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue()))
return;
@ -157,57 +157,6 @@ void LogWriter::WriteToLog(const wxString& prefix, const wxString& value, u8 lvl
LogBuffer.Push(LogPacket(new_prefix, value, g_log_colors[lvl]));
}
void LogWriter::Write(const wxString& fmt, ...)
{
va_list list;
va_start(list, fmt);
wxString frmt;
frmt = wxString::FormatV(fmt, list);
va_end(list);
WriteToLog("!", frmt, 2);
}
void LogWriter::Error(const wxString& fmt, ...)
{
va_list list;
va_start(list, fmt);
wxString frmt;
frmt = wxString::FormatV(fmt, list);
va_end(list);
WriteToLog("E", frmt, 4);
}
void LogWriter::Warning(const wxString& fmt, ...)
{
va_list list;
va_start(list, fmt);
wxString frmt;
frmt = wxString::FormatV(fmt, list);
va_end(list);
WriteToLog("W", frmt, 3);
}
void LogWriter::Success(const wxString& fmt, ...)
{
va_list list;
va_start(list, fmt);
wxString frmt;
frmt = wxString::FormatV(fmt, list);
va_end(list);
WriteToLog("S", frmt, 1);
}
void LogWriter::SkipLn()
{
@ -271,9 +220,9 @@ void LogFrame::Task()
const int cur_item = m_log.GetItemCount();
m_log.InsertItem(cur_item, item.m_prefix);
m_log.SetItem(cur_item, 1, item.m_text);
m_log.SetItemTextColour(cur_item, item.m_colour);
m_log.InsertItem(cur_item, fmt::FromUTF8(item.m_prefix));
m_log.SetItem(cur_item, 1, fmt::FromUTF8(item.m_text));
m_log.SetItemTextColour(cur_item, fmt::FromUTF8(item.m_colour));
m_log.SetColumnWidth(0, -1); // crashes on exit
m_log.SetColumnWidth(1, -1);