Replace all instances of wxString with std::string where possible.

Originally committed to SVN as r5121.
This commit is contained in:
Amar Takhar 2011-01-04 00:22:55 +00:00
parent 4d3c89eebf
commit a0e760c9da
15 changed files with 109 additions and 114 deletions

View file

@ -19,7 +19,6 @@
/// @ingroup base
#ifndef R_PRECOMP
#include <wx/fileconf.h>
#include <wx/wfstream.h>
#include <wx/stdpaths.h>
#endif
@ -36,18 +35,14 @@ Aegisub::Aegisub() {
wxStandardPathsBase &paths = wxStandardPaths::Get();
// Using ifdefs is a pain but it's much easier to centralise this.
#if defined(__APPLE__)
wxString configdir = wxString::Format("%s-%s", paths.GetUserDataDir(), _T(AEGISUB_VERSION_DATA));
std::string configdir(wxString::Format("%s-%s", paths.GetUserDataDir(), _T(AEGISUB_VERSION_DATA)));
#elif defined(__UNIX__)
wxString configdir = wxString::Format("%s/.aegisub-%s", paths.GetUserConfigDir(), _T(AEGISUB_VERSION_DATA));
std::string configdir(wxString::Format("%s/.aegisub-%s", paths.GetUserConfigDir(), _T(AEGISUB_VERSION_DATA)));
#else
wxString configdir = wxString::Format("%s/Aegisub", paths.GetUserConfigDir());
std::string configdir(wxString::Format("%s/Aegisub", paths.GetUserConfigDir()));
#endif
wxFileInputStream file(wxString::Format("%s/config.dat", configdir));
conf = new wxFileConfig(file);
conf->SetExpandEnvVars(false);
}
wxString Aegisub::Read(wxString key) {
return conf->Read(key);
std::string Aegisub::Read(std::string key) {
}

View file

@ -30,6 +30,6 @@ private:
public:
Aegisub();
~Aegisub();
void Config(wxString config);
wxString Read(wxString key);
void Config(std::string config);
std::string Read(std::string key);
};

View file

@ -117,12 +117,12 @@ public:
/// Time
/// @return Time
/// @retval Time in HH:MM:SS
wxString Time();
std::string Time();
/// TimeZone
/// @return TimeZone
/// @retval EST,EDT,JST...
wxString TimeZone();
std::string TimeZone();
//@}
/// @name Platform Specific
@ -201,12 +201,12 @@ public:
/// Service pack
/// @return Service pack
/// @retval Any
virtual wxString ServicePack()=0;
virtual std::string ServicePack()=0;
/// Graphics driver version
/// @return Driver version
/// @retval Any
virtual wxString DriverGraphicsVersion()=0;
virtual std::string DriverGraphicsVersion()=0;
/// Directshow filters installed
/// @return json::Object of filters installed
@ -216,17 +216,17 @@ public:
/// <name version="[version]">[name]</name>
/// </filter>
/// \endverbatim
virtual wxString DirectShowFilters()=0;
virtual std::string DirectShowFilters()=0;
/// AntiVirus installed
/// @return true/false
/// @retval 1,0
virtual wxString AntiVirus()=0;
virtual std::string AntiVirus()=0;
/// Firewall installed
/// @return true/false
/// @retval 1,0
virtual wxString Firewall()=0;
virtual std::string Firewall()=0;
/// DLL versions used
/// @return json::Array of DLLs used
@ -234,7 +234,7 @@ public:
/// \verbatim
/// { "version", "name" }
/// \endverbatim
virtual wxString DLLVersions()=0;
virtual std::string DLLVersions()=0;
#endif
//@}
@ -264,7 +264,7 @@ public:
/// OS patch level
/// @return Patch level
/// @retval Any
virtual wxString PatchLevel()=0;
virtual std::string PatchLevel()=0;
/// QuickTime extensions
/// @return json::Array of extensions used
@ -272,12 +272,12 @@ public:
/// \verbatim
/// { "version", "name" }
/// \endverbatim
virtual wxString QuickTimeExt()=0;
virtual std::string QuickTimeExt()=0;
/// Hardware model
/// @return Model
/// @retval Any
virtual wxString HardwareModel()=0;
virtual std::string HardwareModel()=0;
#endif
//@}

View file

@ -160,6 +160,6 @@ void mFrame::Cancel(wxCommandEvent& WXUNUSED(event)) {
void mFrame::Submit(wxCommandEvent& WXUNUSED(event)) {
Progress *progress = new Progress(this);
Upload *upload = new Upload(progress);
upload->Report(_("./test.json"));
upload->Report("./test.json");
}

View file

@ -91,7 +91,7 @@ Platform::~Platform() {
*/
std::string Platform::GetVideoInfo(enum Platform::VideoInfo which) {
wxString value;
std::string value;
switch (which) {
case VIDEO_EXT:
@ -198,15 +198,15 @@ std::string Platform::OpenGLExt() {
#ifdef __APPLE__
wxString Platform::PatchLevel() {
std::string Platform::PatchLevel() {
return "";
}
wxString Platform::QuickTimeExt() {
std::string Platform::QuickTimeExt() {
return "";
}
wxString Platform::HardwareModel() {
std::string Platform::HardwareModel() {
return "";
}

View file

@ -29,11 +29,11 @@
#include "platform_unix_linux.h"
wxString PlatformUnixLinux::CPUId() {
std::string PlatformUnixLinux::CPUId() {
return getProcValue("/proc/cpuinfo", "model name\t");
};
wxString PlatformUnixLinux::CPUSpeed() {
std::string PlatformUnixLinux::CPUSpeed() {
return getProcValue("/proc/cpuinfo", "cpu MHz\t\t");
};
@ -42,14 +42,14 @@ wxString PlatformUnixLinux::CPUSpeed() {
// due to SMT/HyperThreading.
// For now report the logical CPU count and no number of cores; this seems
// to make the most sense.
wxString PlatformUnixLinux::CPUCores() {
std::string PlatformUnixLinux::CPUCores() {
return "";
};
wxString PlatformUnixLinux::CPUCount() {
std::string PlatformUnixLinux::CPUCount() {
// This returns the index of the last processor.
// Increment and return as string.
wxString procIndex = getProcValue("/proc/cpuinfo", "processor\t");
std::string procIndex = getProcValue("/proc/cpuinfo", "processor\t");
if (procIndex.IsNumber()) {
long val = 0;
procIndex.ToLong(&val);
@ -60,16 +60,16 @@ wxString PlatformUnixLinux::CPUCount() {
return "1";
};
wxString PlatformUnixLinux::CPUFeatures() {
std::string PlatformUnixLinux::CPUFeatures() {
return getProcValue("/proc/cpuinfo", "flags\t\t");
};
wxString PlatformUnixLinux::CPUFeatures2() {
std::string PlatformUnixLinux::CPUFeatures2() {
return "";
};
wxString PlatformUnixLinux::Memory() {
wxString memKb = getProcValue("/proc/meminfo", "MemTotal");
std::string PlatformUnixLinux::Memory() {
std::string memKb = getProcValue("/proc/meminfo", "MemTotal");
memKb = memKb.BeforeFirst(' ');
if (memKb.IsNumber()) {
long val = 0;
@ -80,7 +80,7 @@ wxString PlatformUnixLinux::Memory() {
return "";
};
wxString PlatformUnixLinux::UnixLibraries() {
std::string PlatformUnixLinux::UnixLibraries() {
return "";
};
@ -88,16 +88,16 @@ wxString PlatformUnixLinux::UnixLibraries() {
* @brief Parse a /proc "key: value" style text file and extract a value.
* @return The last valid value
*/
wxString PlatformUnixLinux::getProcValue(const wxString path, const wxString key) {
const wxString prefix = wxString(key) + ":";
std::string PlatformUnixLinux::getProcValue(const std::string path, const std::string key) {
const std::string prefix = std::string(key) + ":";
wxTextFile *file = new wxTextFile(path);
wxString val = wxString();
std::string val = std::string();
file->Open();
for (wxString str = file->GetFirstLine(); !file->Eof(); str = file->GetNextLine()) {
for (std::string str = file->GetFirstLine(); !file->Eof(); str = file->GetNextLine()) {
str.Trim(false);
if (str.StartsWith(prefix)) {
val = wxString(str.Mid(key.Len() + 1));
val = std::string(str.Mid(key.Len() + 1));
val.Trim(false);
}
}

View file

@ -27,16 +27,16 @@ public:
virtual ~PlatformUnixLinux() {};
// Hardware
virtual wxString CPUId();
virtual wxString CPUSpeed();
virtual wxString CPUCores();
virtual wxString CPUCount();
virtual wxString CPUFeatures();
virtual wxString CPUFeatures2();
virtual wxString Memory();
virtual std::string CPUId();
virtual std::string CPUSpeed();
virtual std::string CPUCores();
virtual std::string CPUCount();
virtual std::string CPUFeatures();
virtual std::string CPUFeatures2();
virtual std::string Memory();
// Unix Specific
virtual wxString UnixLibraries();
virtual std::string UnixLibraries();
private:
virtual wxString getProcValue(const wxString path, const wxString key);
virtual std::string getProcValue(const std::string path, const std::string key);
};

View file

@ -32,39 +32,39 @@ extern "C" {
#include "platform_unix_osx.h"
wxString PlatformUnixOSX::CPUId() {
std::string PlatformUnixOSX::CPUId() {
char id[300];
size_t len = sizeof(id);
sysctlbyname("machdep.cpu.brand_string", &id, &len, NULL, 0);
return wxString::Format("%s", id);
};
wxString PlatformUnixOSX::CPUSpeed() {
std::string PlatformUnixOSX::CPUSpeed() {
uint64_t speed;
size_t len = sizeof(speed);
sysctlbyname("hw.cpufrequency_max", &speed, &len, NULL, 0);
return wxString::Format("%d", speed / (1000*1000));
};
wxString PlatformUnixOSX::CPUCores() {
std::string PlatformUnixOSX::CPUCores() {
return "";
};
wxString PlatformUnixOSX::CPUCount() {
std::string PlatformUnixOSX::CPUCount() {
int proc;
size_t len = sizeof(proc);
sysctlbyname("hw.ncpu", &proc, &len, NULL, 0);
return wxString::Format("%d", proc);
};
wxString PlatformUnixOSX::CPUFeatures() {
std::string PlatformUnixOSX::CPUFeatures() {
char feat[300];
size_t len = sizeof(feat);
sysctlbyname("machdep.cpu.features", &feat, &len, NULL, 0);
return wxString::Format("%s", feat);
};
wxString PlatformUnixOSX::CPUFeatures2() {
std::string PlatformUnixOSX::CPUFeatures2() {
char feat[128];
size_t len = sizeof(feat);
sysctlbyname("machdep.cpu.extfeatures", &feat, &len, NULL, 0);
@ -72,26 +72,26 @@ wxString PlatformUnixOSX::CPUFeatures2() {
return "";
};
wxString PlatformUnixOSX::Memory() {
std::string PlatformUnixOSX::Memory() {
uint64_t memory;
size_t len = sizeof(memory);
sysctlbyname("hw.memsize", &memory, &len, NULL, 0);
return wxString::Format("%llu", memory);
};
wxString PlatformUnixOSX::UnixLibraries() {
std::string PlatformUnixOSX::UnixLibraries() {
return "";
};
wxString PlatformUnixOSX::PatchLevel() {
std::string PlatformUnixOSX::PatchLevel() {
return "";
}
wxString PlatformUnixOSX::QuickTimeExt() {
std::string PlatformUnixOSX::QuickTimeExt() {
return "";
}
wxString PlatformUnixOSX::HardwareModel() {
std::string PlatformUnixOSX::HardwareModel() {
char model[300];
size_t len = sizeof(model);
sysctlbyname("hw.model", &model, &len, NULL, 0);

View file

@ -27,18 +27,18 @@ public:
virtual ~PlatformUnixOSX() {};
// Hardware
virtual wxString CPUId();
virtual wxString CPUSpeed();
virtual wxString CPUCores();
virtual wxString CPUCount();
virtual wxString CPUFeatures();
virtual wxString CPUFeatures2();
virtual wxString Memory();
virtual std::string CPUId();
virtual std::string CPUSpeed();
virtual std::string CPUCores();
virtual std::string CPUCount();
virtual std::string CPUFeatures();
virtual std::string CPUFeatures2();
virtual std::string Memory();
virtual wxString PatchLevel();
virtual wxString QuickTimeExt();
virtual wxString HardwareModel();
virtual std::string PatchLevel();
virtual std::string QuickTimeExt();
virtual std::string HardwareModel();
// Unix Specific
virtual wxString UnixLibraries();
virtual std::string UnixLibraries();
};

View file

@ -27,78 +27,78 @@
#include "include/platform.h"
#include "platform_windows.h"
wxString PlatformWindows::OSVersion() {
std::string PlatformWindows::OSVersion() {
return "";
}
wxString PlatformWindows::DesktopEnvironment() {
std::string PlatformWindows::DesktopEnvironment() {
return wxTheApp->GetTraits()->GetDesktopEnvironment();
}
wxString PlatformWindows::CPUId() {
std::string PlatformWindows::CPUId() {
return "";
};
wxString PlatformWindows::CPUSpeed() {
std::string PlatformWindows::CPUSpeed() {
return "";
};
wxString PlatformWindows::CPUCores() {
std::string PlatformWindows::CPUCores() {
return "";
};
wxString PlatformWindows::CPUCount() {
std::string PlatformWindows::CPUCount() {
return "";
};
wxString PlatformWindows::CPUFeatures() {
std::string PlatformWindows::CPUFeatures() {
return "";
};
wxString PlatformWindows::CPUFeatures2() {
std::string PlatformWindows::CPUFeatures2() {
return "";
};
wxString PlatformWindows::Memory() {
std::string PlatformWindows::Memory() {
return "";
};
wxString PlatformWindows::ServicePack() {
std::string PlatformWindows::ServicePack() {
return "";
};
wxString PlatformWindows::DriverGraphicsVersion() {
std::string PlatformWindows::DriverGraphicsVersion() {
return "";
};
wxString PlatformWindows::DirectShowFilters() {
std::string PlatformWindows::DirectShowFilters() {
return "";
};
wxString PlatformWindows::AntiVirus() {
std::string PlatformWindows::AntiVirus() {
return "";
};
wxString PlatformWindows::Firewall() {
std::string PlatformWindows::Firewall() {
return "";
};
wxString PlatformWindows::DLLVersions() {
std::string PlatformWindows::DLLVersions() {
return "";
};
wxString PlatformWindows::OpenGLVendor() {
std::string PlatformWindows::OpenGLVendor() {
return "";
};
wxString PlatformWindows::OpenGLRenderer() {
std::string PlatformWindows::OpenGLRenderer() {
return "";
};
wxString PlatformWindows::OpenGLVersion() {
std::string PlatformWindows::OpenGLVersion() {
return "";
};
wxString PlatformWindows::OpenGLExt() {
std::string PlatformWindows::OpenGLExt() {
return "";
};

View file

@ -26,28 +26,28 @@ public:
PlatformWindows() {};
virtual ~PlatformWindows() {};
const std::string OSVersion();
wxString DesktopEnvironment();
std::string DesktopEnvironment();
// Hardware
virtual wxString CPUId();
virtual wxString CPUSpeed();
virtual wxString CPUCores();
virtual wxString CPUCount();
virtual wxString CPUFeatures();
virtual wxString CPUFeatures2();
virtual wxString Memory();
virtual std::string CPUId();
virtual std::string CPUSpeed();
virtual std::string CPUCores();
virtual std::string CPUCount();
virtual std::string CPUFeatures();
virtual std::string CPUFeatures2();
virtual std::string Memory();
// OpenGL
virtual wxString OpenGLVendor();
virtual wxString OpenGLRenderer();
virtual wxString OpenGLVersion();
virtual wxString OpenGLExt();
virtual std::string OpenGLVendor();
virtual std::string OpenGLRenderer();
virtual std::string OpenGLVersion();
virtual std::string OpenGLExt();
// Windows Specific
virtual wxString ServicePack();
virtual wxString DriverGraphicsVersion();
virtual wxString DirectShowFilters();
virtual wxString AntiVirus();
virtual wxString Firewall();
virtual wxString DLLVersions();
virtual std::string ServicePack();
virtual std::string DriverGraphicsVersion();
virtual std::string DirectShowFilters();
virtual std::string AntiVirus();
virtual std::string Firewall();
virtual std::string DLLVersions();
};

View file

@ -49,7 +49,7 @@ Upload::~Upload() {
/// @brief Submit a JSON report.
/// @param report filename of the report.
void Upload::Report(wxString report) {
void Upload::Report(std::string report) {
wxFile file(report, wxFile::read);
SendFile("http://reporter.darkbeer.org/PUT/", file);
}

View file

@ -41,6 +41,6 @@ private:
public:
Upload(Progress *prog);
~Upload();
void Report(wxString report);
void Report(std::string report);
bool SendFile(const char *url, wxFile &file);
};

View file

@ -40,7 +40,7 @@ View::View(wxWindow *frame, Report *r)
wxListView *listView = new wxListView(this,wxID_ANY,wxDefaultPosition,wxDefaultSize);
// Fill the list with the actual report.
text = new wxString();
text = new std::string();
// r->Fill(text, listView);
listSizer->Add(listView, 1, wxEXPAND);

View file

@ -36,7 +36,7 @@ public:
private:
Report *r;
wxString *text;
std::string *text;
void CloseDialog(wxCommandEvent& event);
void Clipboard(wxCommandEvent& event);
DECLARE_EVENT_TABLE()