From 99aff7254f2189702c2f6a4ab64645460b7db29d Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Mon, 3 Jan 2011 15:46:21 +0000 Subject: [PATCH] * wxString is really annoying. * Build JSON tree. Originally committed to SVN as r5119. --- aegisub/reporter/include/platform.h | 16 ++++++------ aegisub/reporter/main.cpp | 4 +-- aegisub/reporter/platform.cpp | 39 +++++++++++++++++------------ aegisub/reporter/r_pre.h | 2 +- aegisub/reporter/report.cpp | 31 +++++++++++++++-------- aegisub/reporter/report.h | 5 +--- 6 files changed, 55 insertions(+), 42 deletions(-) diff --git a/aegisub/reporter/include/platform.h b/aegisub/reporter/include/platform.h index 98f1ed512..da3f71d84 100644 --- a/aegisub/reporter/include/platform.h +++ b/aegisub/reporter/include/platform.h @@ -48,22 +48,22 @@ public: /// Architecture /// @return Architecture name. /// @retval 32 bit, 64 bit - const char* ArchName(); + std::string ArchName(); /// OS Family /// @return OS Family /// @retval Unix, Windows, Mac - const char* OSFamily(); + std::string OSFamily(); /// OS Name /// @return OS Name /// @retval FreeBSD, Windows, Mac - const char* OSName(); + std::string OSName(); /// Endian /// @return Endian /// @retval Little endian, Big endian - const char* Endian(); + std::string Endian(); // From @@ -75,12 +75,12 @@ public: /// Display size /// @return Size delimited by a space. /// @retval "w h" - const char* DisplaySize(); + std::string DisplaySize(); /// Pixels per inch /// @return PPI /// @retval Integer - const char* DisplayPPI(); + std::string DisplayPPI(); // Misc @@ -92,12 +92,12 @@ public: /// wxWidgets version /// @return Version /// @retval Major.Minor.Micro.Patch: 2.9.0.0 - const char* wxVersion(); + std::string wxVersion(); /// Locale /// @return Locale name /// @retval C,POSIX, - const char* Locale(); + std::string Locale(); /// Language currently in use /// @return Language reporter is currently running in diff --git a/aegisub/reporter/main.cpp b/aegisub/reporter/main.cpp index 252a041e4..3815b8c95 100644 --- a/aegisub/reporter/main.cpp +++ b/aegisub/reporter/main.cpp @@ -89,7 +89,6 @@ bool Reporter::OnInit() mFrame *frame = new mFrame(_("Aegisub Reporter")); -// Report *r = new Report; if (parser.Found("j")) { r->Save("report.json"); @@ -99,7 +98,8 @@ bool Reporter::OnInit() SetTopWindow(frame); -// frame->SetReport(r); + r = new Report; + frame->SetReport(r); return true; } diff --git a/aegisub/reporter/platform.cpp b/aegisub/reporter/platform.cpp index 89fa728dd..2b7102224 100644 --- a/aegisub/reporter/platform.cpp +++ b/aegisub/reporter/platform.cpp @@ -19,6 +19,7 @@ /// @ingroup base #ifndef R_PRECOMP +#include #include #include #include // Display* functions. @@ -104,20 +105,20 @@ std::string Platform::GetVideoInfo(enum Platform::VideoInfo which) { delete glc; } -const char* Platform::ArchName() { - return plat.GetArchName().c_str(); +std::string Platform::ArchName() { + return std::string(plat.GetArchName()); }; -const char* Platform::OSFamily() { - return plat.GetOperatingSystemFamilyName().c_str(); +std::string Platform::OSFamily() { + return std::string(plat.GetOperatingSystemFamilyName()); }; -const char* Platform::OSName() { - return plat.GetOperatingSystemIdName().c_str(); +std::string Platform::OSName() { + return std::string(plat.GetOperatingSystemIdName()); }; -const char* Platform::Endian() { - return plat.GetEndiannessName().c_str(); +std::string Platform::Endian() { + return std::string(plat.GetEndiannessName()); }; @@ -125,22 +126,28 @@ int Platform::DisplayDepth() { return wxDisplayDepth(); } -const char* Platform::DisplaySize() { +std::string Platform::DisplaySize() { int x, y; wxDisplaySize(&x, &y); - return wxString::Format(L"%d %d", x, y).c_str(); + std::stringstream ss; + ss << x << " " << y; + return ss.str(); } -const char* Platform::DisplayPPI() { - return wxString::Format(L"%d %d", wxGetDisplayPPI().GetWidth(), wxGetDisplayPPI().GetHeight()).c_str(); +std::string Platform::DisplayPPI() { + std::stringstream ss; + ss << wxGetDisplayPPI().GetWidth() << " " << wxGetDisplayPPI().GetHeight(); + return ss.str(); } -const char* Platform::wxVersion() { - return wxString::Format(L"%d.%d.%d.%d", wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, wxSUBRELEASE_NUMBER).c_str(); +std::string Platform::wxVersion() { + std::stringstream ss; + ss << wxMAJOR_VERSION << "." << wxMINOR_VERSION << "." << wxRELEASE_NUMBER << "." << wxSUBRELEASE_NUMBER; + return ss.str(); } -const char* Platform::Locale() { - return wxLocale().GetSysName().c_str(); +std::string Platform::Locale() { + return std::string(wxLocale().GetSysName()); } const char* Platform::Language() { diff --git a/aegisub/reporter/r_pre.h b/aegisub/reporter/r_pre.h index 69fcbb4f5..04cdb65ba 100644 --- a/aegisub/reporter/r_pre.h +++ b/aegisub/reporter/r_pre.h @@ -29,7 +29,7 @@ #include // C++ std -#include +#include // 3rd party packages. #include diff --git a/aegisub/reporter/report.cpp b/aegisub/reporter/report.cpp index 446b2c219..2654f3c67 100644 --- a/aegisub/reporter/report.cpp +++ b/aegisub/reporter/report.cpp @@ -23,6 +23,7 @@ #include #endif +#include #include #include @@ -50,7 +51,7 @@ Report::Report() { general["Locale"] = json::String(p->Locale()); general["Language"] = json::String(p->Language()); general["System Language"] = json::String(p->SystemLanguage()); - + root["General"] = general; json::Object aegisub; @@ -76,7 +77,7 @@ Report::Report() { json::Object hardware; hardware["Memory Size"] = json::Number(); - + root["Hardware"] = hardware; json::Object cpu; cpu["Id"] = json::String(p->CPUId()); @@ -85,20 +86,21 @@ Report::Report() { cpu["Cores"] = json::Number(p->CPUCores()); cpu["Features"] = json::String(p->CPUFeatures()); cpu["Features2"] = json::String(p->CPUFeatures2()); - + root["CPU"] = cpu; json::Object display; display["Depth"] = json::Number(p->DisplayDepth()); display["Size"] = json::String(p->DisplaySize()); display["Pixels Per Inch"] = json::String(p->DisplayPPI()); + json::Object gl; + gl["Vendor"] = json::String(p->OpenGLVendor()); + gl["Renderer"] = json::String(p->OpenGLRenderer()); + gl["Version"] = json::String(p->OpenGLVersion()); + gl["Extensions"] = json::String(p->OpenGLExt()); + display["OpenGL"] = gl; - json::Object gl; - gl["Vendor"] = json::String(p->OpenGLVendor()); - gl["Renderer"] = json::String(p->OpenGLRenderer()); - gl["Version"] = json::String(p->OpenGLVersion()); - gl["Extensions"] = json::String(p->OpenGLExt()); - display["OpenGL"] = gl; + root["Display"] = display; #ifdef __WINDOWS__ @@ -109,6 +111,7 @@ Report::Report() { windows["AntiVirus Installed"] = json::Boolean(); windows["Firewall Installed"] = json::Boolean(); windows["DLL"] = json::String(); + root["Windows"] = windows; #endif @@ -116,6 +119,7 @@ Report::Report() { json::Object u_nix; u_nix["Desktop Environment"] = json::String(p->DesktopEnvironment()); u_nix["Libraries"] = json::String(p->UnixLibraries()); + root["Unix"] = u_nix; #endif #ifdef __APPLE__ @@ -123,11 +127,16 @@ Report::Report() { osx["Patch"] = json::String(p->PatchLevel()); osx["QuickTime Extensions"] = json::String(p->QuickTimeExt()); osx["Model"] = json::String(p->HardwareModel()); + root["OS X"] = osx; #endif + agi::io::Save file("./t.json"); + json::Writer::Write(root, file.Get()); + } /// @brief Return Report as Text for the Clipboard. -void Report::Save(wxString file) { -// doc.doc->Save(file); +void Report::Save(std::string filename) { +// agi::io::Save file(filename); +// json::Writer::Write(root, file.Get()); } diff --git a/aegisub/reporter/report.h b/aegisub/reporter/report.h index c5969b0f5..922f75e93 100644 --- a/aegisub/reporter/report.h +++ b/aegisub/reporter/report.h @@ -19,9 +19,6 @@ /// @ingroup base #ifndef R_PRECOMP -#include - -#include #endif /// @class Report @@ -33,7 +30,7 @@ public: ~Report() {}; /// Save JSON report to a file. - void Save(wxString file); + void Save(std::string filename); private: wxLocale *locale;