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

View file

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

View file

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

View file

@ -160,6 +160,6 @@ void mFrame::Cancel(wxCommandEvent& WXUNUSED(event)) {
void mFrame::Submit(wxCommandEvent& WXUNUSED(event)) { void mFrame::Submit(wxCommandEvent& WXUNUSED(event)) {
Progress *progress = new Progress(this); Progress *progress = new Progress(this);
Upload *upload = new Upload(progress); 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) { std::string Platform::GetVideoInfo(enum Platform::VideoInfo which) {
wxString value; std::string value;
switch (which) { switch (which) {
case VIDEO_EXT: case VIDEO_EXT:
@ -198,15 +198,15 @@ std::string Platform::OpenGLExt() {
#ifdef __APPLE__ #ifdef __APPLE__
wxString Platform::PatchLevel() { std::string Platform::PatchLevel() {
return ""; return "";
} }
wxString Platform::QuickTimeExt() { std::string Platform::QuickTimeExt() {
return ""; return "";
} }
wxString Platform::HardwareModel() { std::string Platform::HardwareModel() {
return ""; return "";
} }

View file

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

View file

@ -27,16 +27,16 @@ public:
virtual ~PlatformUnixLinux() {}; virtual ~PlatformUnixLinux() {};
// Hardware // Hardware
virtual wxString CPUId(); virtual std::string CPUId();
virtual wxString CPUSpeed(); virtual std::string CPUSpeed();
virtual wxString CPUCores(); virtual std::string CPUCores();
virtual wxString CPUCount(); virtual std::string CPUCount();
virtual wxString CPUFeatures(); virtual std::string CPUFeatures();
virtual wxString CPUFeatures2(); virtual std::string CPUFeatures2();
virtual wxString Memory(); virtual std::string Memory();
// Unix Specific // Unix Specific
virtual wxString UnixLibraries(); virtual std::string UnixLibraries();
private: 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" #include "platform_unix_osx.h"
wxString PlatformUnixOSX::CPUId() { std::string PlatformUnixOSX::CPUId() {
char id[300]; char id[300];
size_t len = sizeof(id); size_t len = sizeof(id);
sysctlbyname("machdep.cpu.brand_string", &id, &len, NULL, 0); sysctlbyname("machdep.cpu.brand_string", &id, &len, NULL, 0);
return wxString::Format("%s", id); return wxString::Format("%s", id);
}; };
wxString PlatformUnixOSX::CPUSpeed() { std::string PlatformUnixOSX::CPUSpeed() {
uint64_t speed; uint64_t speed;
size_t len = sizeof(speed); size_t len = sizeof(speed);
sysctlbyname("hw.cpufrequency_max", &speed, &len, NULL, 0); sysctlbyname("hw.cpufrequency_max", &speed, &len, NULL, 0);
return wxString::Format("%d", speed / (1000*1000)); return wxString::Format("%d", speed / (1000*1000));
}; };
wxString PlatformUnixOSX::CPUCores() { std::string PlatformUnixOSX::CPUCores() {
return ""; return "";
}; };
wxString PlatformUnixOSX::CPUCount() { std::string PlatformUnixOSX::CPUCount() {
int proc; int proc;
size_t len = sizeof(proc); size_t len = sizeof(proc);
sysctlbyname("hw.ncpu", &proc, &len, NULL, 0); sysctlbyname("hw.ncpu", &proc, &len, NULL, 0);
return wxString::Format("%d", proc); return wxString::Format("%d", proc);
}; };
wxString PlatformUnixOSX::CPUFeatures() { std::string PlatformUnixOSX::CPUFeatures() {
char feat[300]; char feat[300];
size_t len = sizeof(feat); size_t len = sizeof(feat);
sysctlbyname("machdep.cpu.features", &feat, &len, NULL, 0); sysctlbyname("machdep.cpu.features", &feat, &len, NULL, 0);
return wxString::Format("%s", feat); return wxString::Format("%s", feat);
}; };
wxString PlatformUnixOSX::CPUFeatures2() { std::string PlatformUnixOSX::CPUFeatures2() {
char feat[128]; char feat[128];
size_t len = sizeof(feat); size_t len = sizeof(feat);
sysctlbyname("machdep.cpu.extfeatures", &feat, &len, NULL, 0); sysctlbyname("machdep.cpu.extfeatures", &feat, &len, NULL, 0);
@ -72,26 +72,26 @@ wxString PlatformUnixOSX::CPUFeatures2() {
return ""; return "";
}; };
wxString PlatformUnixOSX::Memory() { std::string PlatformUnixOSX::Memory() {
uint64_t memory; uint64_t memory;
size_t len = sizeof(memory); size_t len = sizeof(memory);
sysctlbyname("hw.memsize", &memory, &len, NULL, 0); sysctlbyname("hw.memsize", &memory, &len, NULL, 0);
return wxString::Format("%llu", memory); return wxString::Format("%llu", memory);
}; };
wxString PlatformUnixOSX::UnixLibraries() { std::string PlatformUnixOSX::UnixLibraries() {
return ""; return "";
}; };
wxString PlatformUnixOSX::PatchLevel() { std::string PlatformUnixOSX::PatchLevel() {
return ""; return "";
} }
wxString PlatformUnixOSX::QuickTimeExt() { std::string PlatformUnixOSX::QuickTimeExt() {
return ""; return "";
} }
wxString PlatformUnixOSX::HardwareModel() { std::string PlatformUnixOSX::HardwareModel() {
char model[300]; char model[300];
size_t len = sizeof(model); size_t len = sizeof(model);
sysctlbyname("hw.model", &model, &len, NULL, 0); sysctlbyname("hw.model", &model, &len, NULL, 0);

View file

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

View file

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

View file

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

View file

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

View file

@ -41,6 +41,6 @@ private:
public: public:
Upload(Progress *prog); Upload(Progress *prog);
~Upload(); ~Upload();
void Report(wxString report); void Report(std::string report);
bool SendFile(const char *url, wxFile &file); 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); wxListView *listView = new wxListView(this,wxID_ANY,wxDefaultPosition,wxDefaultSize);
// Fill the list with the actual report. // Fill the list with the actual report.
text = new wxString(); text = new std::string();
// r->Fill(text, listView); // r->Fill(text, listView);
listSizer->Add(listView, 1, wxEXPAND); listSizer->Add(listView, 1, wxEXPAND);

View file

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