From a0e760c9dab5245a9fb46f861ef88cd47fe49a8f Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Tue, 4 Jan 2011 00:22:55 +0000 Subject: [PATCH] Replace all instances of wxString with std::string where possible. Originally committed to SVN as r5121. --- aegisub/reporter/aegisub.cpp | 13 +++----- aegisub/reporter/aegisub.h | 4 +-- aegisub/reporter/include/platform.h | 22 +++++++------- aegisub/reporter/main.cpp | 2 +- aegisub/reporter/platform.cpp | 8 ++--- aegisub/reporter/platform_unix_linux.cpp | 30 +++++++++---------- aegisub/reporter/platform_unix_linux.h | 18 +++++------ aegisub/reporter/platform_unix_osx.cpp | 22 +++++++------- aegisub/reporter/platform_unix_osx.h | 22 +++++++------- aegisub/reporter/platform_windows.cpp | 38 ++++++++++++------------ aegisub/reporter/platform_windows.h | 36 +++++++++++----------- aegisub/reporter/upload.cpp | 2 +- aegisub/reporter/upload.h | 2 +- aegisub/reporter/view.cpp | 2 +- aegisub/reporter/view.h | 2 +- 15 files changed, 109 insertions(+), 114 deletions(-) diff --git a/aegisub/reporter/aegisub.cpp b/aegisub/reporter/aegisub.cpp index dc813bbb7..798d28dad 100644 --- a/aegisub/reporter/aegisub.cpp +++ b/aegisub/reporter/aegisub.cpp @@ -19,7 +19,6 @@ /// @ingroup base #ifndef R_PRECOMP -#include #include #include #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) { } diff --git a/aegisub/reporter/aegisub.h b/aegisub/reporter/aegisub.h index da2950bbb..e535f53c7 100644 --- a/aegisub/reporter/aegisub.h +++ b/aegisub/reporter/aegisub.h @@ -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); }; diff --git a/aegisub/reporter/include/platform.h b/aegisub/reporter/include/platform.h index c676470d8..0f4d89830 100644 --- a/aegisub/reporter/include/platform.h +++ b/aegisub/reporter/include/platform.h @@ -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] /// /// \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 //@} diff --git a/aegisub/reporter/main.cpp b/aegisub/reporter/main.cpp index 3815b8c95..374619d9d 100644 --- a/aegisub/reporter/main.cpp +++ b/aegisub/reporter/main.cpp @@ -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"); } diff --git a/aegisub/reporter/platform.cpp b/aegisub/reporter/platform.cpp index 5d191938d..ed1316e93 100644 --- a/aegisub/reporter/platform.cpp +++ b/aegisub/reporter/platform.cpp @@ -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 ""; } diff --git a/aegisub/reporter/platform_unix_linux.cpp b/aegisub/reporter/platform_unix_linux.cpp index 7e0356f30..2ee86cf3b 100644 --- a/aegisub/reporter/platform_unix_linux.cpp +++ b/aegisub/reporter/platform_unix_linux.cpp @@ -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); } } diff --git a/aegisub/reporter/platform_unix_linux.h b/aegisub/reporter/platform_unix_linux.h index f0edca316..7709dd26d 100644 --- a/aegisub/reporter/platform_unix_linux.h +++ b/aegisub/reporter/platform_unix_linux.h @@ -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); }; diff --git a/aegisub/reporter/platform_unix_osx.cpp b/aegisub/reporter/platform_unix_osx.cpp index e8245be96..6f1d82a61 100644 --- a/aegisub/reporter/platform_unix_osx.cpp +++ b/aegisub/reporter/platform_unix_osx.cpp @@ -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); diff --git a/aegisub/reporter/platform_unix_osx.h b/aegisub/reporter/platform_unix_osx.h index fb7d35142..6ddd6f019 100644 --- a/aegisub/reporter/platform_unix_osx.h +++ b/aegisub/reporter/platform_unix_osx.h @@ -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(); }; diff --git a/aegisub/reporter/platform_windows.cpp b/aegisub/reporter/platform_windows.cpp index 57a335ace..921b50e7d 100644 --- a/aegisub/reporter/platform_windows.cpp +++ b/aegisub/reporter/platform_windows.cpp @@ -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 ""; }; diff --git a/aegisub/reporter/platform_windows.h b/aegisub/reporter/platform_windows.h index f4639a49b..dddc6d746 100644 --- a/aegisub/reporter/platform_windows.h +++ b/aegisub/reporter/platform_windows.h @@ -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(); }; diff --git a/aegisub/reporter/upload.cpp b/aegisub/reporter/upload.cpp index df21d8767..b783c8a31 100644 --- a/aegisub/reporter/upload.cpp +++ b/aegisub/reporter/upload.cpp @@ -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); } diff --git a/aegisub/reporter/upload.h b/aegisub/reporter/upload.h index a4a56f5a8..4249f9982 100644 --- a/aegisub/reporter/upload.h +++ b/aegisub/reporter/upload.h @@ -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); }; diff --git a/aegisub/reporter/view.cpp b/aegisub/reporter/view.cpp index 1cff171c0..1cea63159 100644 --- a/aegisub/reporter/view.cpp +++ b/aegisub/reporter/view.cpp @@ -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); diff --git a/aegisub/reporter/view.h b/aegisub/reporter/view.h index 3dc4ae79c..bf3de892c 100644 --- a/aegisub/reporter/view.h +++ b/aegisub/reporter/view.h @@ -36,7 +36,7 @@ public: private: Report *r; - wxString *text; + std::string *text; void CloseDialog(wxCommandEvent& event); void Clipboard(wxCommandEvent& event); DECLARE_EVENT_TABLE()