diff --git a/texedit/gui/main_frame.cpp b/texedit/gui/main_frame.cpp index 0f71ada..05276c9 100644 --- a/texedit/gui/main_frame.cpp +++ b/texedit/gui/main_frame.cpp @@ -75,7 +75,7 @@ namespace te { } } - void MainFrame::ShowURL(const std::string &url) { + void MainFrame::ShowURL(const wxString &url) { if (!wxLaunchDefaultBrowser(url)) { util::log::Error("Failed to open URL \"" + url + "\""); } diff --git a/texedit/gui/main_frame.hpp b/texedit/gui/main_frame.hpp index bca5d63..2fe8a37 100644 --- a/texedit/gui/main_frame.hpp +++ b/texedit/gui/main_frame.hpp @@ -28,7 +28,7 @@ namespace te { void OnIdle(wxIdleEvent &ev); - void ShowURL(const std::string &url); + void ShowURL(const wxString &url); void OnMenuAbout(wxCommandEvent &event); void OnMenuQuit(wxCommandEvent &event); diff --git a/texedit/main.cpp b/texedit/main.cpp index 1322cde..abe40e5 100644 --- a/texedit/main.cpp +++ b/texedit/main.cpp @@ -23,7 +23,7 @@ namespace te { what = "Unknown runtime error"; } - util::log::Fatal(what.ToStdString()); + util::log::Fatal(what); if (wxMessageBox("An unexpected exception has occurred:\n" "\"" + what + "\"\n\n" @@ -47,7 +47,7 @@ namespace te { what = "Unknown runtime error"; } - util::log::Fatal("(unhandled) " + what.ToStdString()); + util::log::Fatal("(unhandled) " + what); wxMessageBox("An unexpected exception has occurred:\n" "\"" + what + "\"\n\n" diff --git a/texedit/process/compiler/tecomp_proc.cpp b/texedit/process/compiler/tecomp_proc.cpp index dbb3f84..a28193a 100644 --- a/texedit/process/compiler/tecomp_proc.cpp +++ b/texedit/process/compiler/tecomp_proc.cpp @@ -13,7 +13,7 @@ namespace te { TECompProcess::TECompProcess(ProcessManager &mgr) : _mgr{mgr}, _id{1} { _cmd = util::res::RelToExec("tecomp"); - if (!util::res::ValidateExecutable(_cmd.ToStdString())) { + if (!util::res::ValidateExecutable(_cmd)) { throw util::except::MissingComponentException("tecomp"); } } diff --git a/texedit/process/process_mgr.cpp b/texedit/process/process_mgr.cpp index 52d094a..f858034 100644 --- a/texedit/process/process_mgr.cpp +++ b/texedit/process/process_mgr.cpp @@ -28,7 +28,7 @@ namespace te { wxString cmdstr; for (int i = 0; argv[i] != 0; i++) cmdstr << argv[i] << " "; - util::log::Info("Executing command: " + cmdstr.ToStdString()); + util::log::Info("Executing command: " + cmdstr); wxExecute(argv, wxEXEC_ASYNC, proc); @@ -43,7 +43,7 @@ namespace te { wxString cmdstr; for (int i = 0; argv[i] != 0; i++) cmdstr << argv[i] << " "; - util::log::Info("Executing command: " + cmdstr.ToStdString()); + util::log::Info("Executing command: " + cmdstr); wxExecute(argv, wxEXEC_ASYNC, piproc); @@ -72,13 +72,13 @@ namespace te { } void ProcessManager::HandleProcessTerminated(Process *p, int pid, int status) { - util::log::Info("Process " + std::to_string(pid) + " (" + p->GetCmd().ToStdString() + ") terminated with code " + std::to_string(status)); + util::log::Info("Process " + std::to_string(pid) + " (" + p->GetCmd() + ") terminated with code " + std::to_string(status)); RemoveProcess(p); } void ProcessManager::HandlePipedProcessTerminated(PipedProcess *p, int pid, int status) { - util::log::Info("Process " + std::to_string(pid) + " (" + p->GetCmd().ToStdString() + ") terminated with code " + std::to_string(status)); + util::log::Info("Process " + std::to_string(pid) + " (" + p->GetCmd() + ") terminated with code " + std::to_string(status)); RemovePipedProcess(p); } diff --git a/texedit/util/except.hpp b/texedit/util/except.hpp index b7c68eb..d9814b6 100644 --- a/texedit/util/except.hpp +++ b/texedit/util/except.hpp @@ -12,7 +12,7 @@ namespace te::util::except { class MissingComponentException : public std::runtime_error { public: - inline MissingComponentException(const std::string &name) + inline MissingComponentException(const wxString &name) : std::runtime_error{"Missing " + name} {} }; } diff --git a/texedit/util/log.cpp b/texedit/util/log.cpp index c777502..ae54eb4 100644 --- a/texedit/util/log.cpp +++ b/texedit/util/log.cpp @@ -13,7 +13,7 @@ #include #include -static std::string GetCurrentDateTime( +static wxString GetCurrentDateTime( const bool with_time ); @@ -22,23 +22,23 @@ namespace te::util::log { ciocolstatedef(stderr); } - void Log(const std::string &msg) { + void Log(const wxString &msg) { # if !defined(NDEBUG) std::cerr << "[" << GetCurrentDateTime(true) << "] DEBUG: " << msg << std::endl; # endif } - void Info(const std::string &msg) { + void Info(const wxString &msg) { std::cerr << "[" << GetCurrentDateTime(true) << "] " << msg << std::endl; } - void Warn(const std::string &msg) { + void Warn(const wxString &msg) { ciocolstateset(CIOCOL_YELLOW, 0xff, stderr); std::cerr << "[" << GetCurrentDateTime(true) << "] WARN: " << msg << std::endl; ResetLogColour(); } - void Error(const std::string &msg, bool show) { + void Error(const wxString &msg, bool show) { ciocolstateset(CIOCOL_RED, 0xff, stderr); std::cerr << "[" << GetCurrentDateTime(true) << "] ERROR: " << msg << std::endl; ResetLogColour(); @@ -48,14 +48,14 @@ namespace te::util::log { } } - void Fatal(const std::string &msg) { + void Fatal(const wxString &msg) { ciocolstateset(CIOCOL_RED, 0xff, stderr); std::cerr << "[" << GetCurrentDateTime(true) << "] FATAL: " << msg << std::endl; ResetLogColour(); } } -std::string GetCurrentDateTime(const bool with_time) { +wxString GetCurrentDateTime(const bool with_time) { std::time_t t = std::time(nullptr); std::tm *tm = std::localtime(&t); @@ -68,7 +68,7 @@ std::string GetCurrentDateTime(const bool with_time) { std::strftime(buf, 64, "%Y-%m-%d", tm); } - return std::string { buf }; + return wxString{buf}; } throw std::runtime_error("Date/time get failed"); diff --git a/texedit/util/log.hpp b/texedit/util/log.hpp index f74821e..e3b26b6 100644 --- a/texedit/util/log.hpp +++ b/texedit/util/log.hpp @@ -9,16 +9,16 @@ #ifndef __texedit__log_hpp__ #define __texedit__log_hpp__ -#include +#include namespace te::util::log { void ResetLogColour(); - void Log(const std::string &msg); - void Info(const std::string &msg); - void Warn(const std::string &msg); - void Error(const std::string &msg, bool show = true); - void Fatal(const std::string &msg); + void Log(const wxString &msg); + void Info(const wxString &msg); + void Warn(const wxString &msg); + void Error(const wxString &msg, bool show = true); + void Fatal(const wxString &msg); } #endif diff --git a/texedit/util/resources.cpp b/texedit/util/resources.cpp index 2ed0538..190ae33 100644 --- a/texedit/util/resources.cpp +++ b/texedit/util/resources.cpp @@ -13,25 +13,25 @@ #include "util/log.hpp" namespace te::util::res { - std::string GetTexeditDir() { + wxString GetTexeditDir() { wxFileName f = wxStandardPaths::Get().GetExecutablePath(); - return f.GetPath().ToStdString(); + return f.GetPath(); } - std::string RelToExec(std::vector dirs, std::string filename) { + wxString RelToExec(std::vector dirs, wxString filename) { wxFileName f = wxFileName::DirName(GetTexeditDir()); for (auto d : dirs) { f.AppendDir(d); } - return f.GetPath().ToStdString() + wxString{wxFileName::GetPathSeparator()}.ToStdString() + filename; + return f.GetPath() + wxString{wxFileName::GetPathSeparator()} + filename; } - std::string RelToExec(std::string filename) { + wxString RelToExec(wxString filename) { return RelToExec({}, filename); } - bool ValidateExecutable(std::string path) { + bool ValidateExecutable(wxString path) { wxFileName f{path}; return f.FileExists() && f.IsFileExecutable(); } diff --git a/texedit/util/resources.hpp b/texedit/util/resources.hpp index 7ee40a5..1c6fcfd 100644 --- a/texedit/util/resources.hpp +++ b/texedit/util/resources.hpp @@ -9,16 +9,16 @@ #ifndef __texedit__resources_hpp__ #define __texedit__resources_hpp__ -#include +#include #include namespace te::util::res { - std::string GetTexeditDir(); + wxString GetTexeditDir(); - std::string RelToExec(std::vector dirs, std::string filename); - std::string RelToExec(std::string filename); + wxString RelToExec(std::vector dirs, wxString filename); + wxString RelToExec(wxString filename); - bool ValidateExecutable(std::string path); + bool ValidateExecutable(wxString path); } #endif