diff --git a/src/utils.h b/src/utils.h index fbc6303..a4556ed 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,91 +1,91 @@ /* SnoreToast is capable to invoke Windows 8 toast notifications. Copyright (C) 2019 Hannah von Reth SnoreToast is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SnoreToast is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SnoreToast. If not, see . */ #pragma once #include #include #include #include class ToastLog; class ToastLog { public: ToastLog(); ~ToastLog(); inline ToastLog &log() { return *this; } private: std::wstringstream m_log; template friend ToastLog &operator<<(ToastLog &, const T &); }; template ToastLog &operator<<(ToastLog &log, const T &t) { log.m_log << L" " << t; return log; } template<> inline ToastLog &operator<<(ToastLog &log, const HRESULT &hr) { if (FAILED(hr)) { _com_error err(hr); log.m_log << L" Error: " << hr << L" " << err.ErrorMessage(); } return log; } #define tLog ToastLog().log() << __FUNCSIG__ << L"\n\t\t" #define ReturnOnErrorHr(hr) \ do { \ HRESULT _tmp = hr; \ if (FAILED(_tmp)) { \ - tLog << ##hr << _tmp; \ + tLog << __LINE__ << #hr << _tmp; \ return _tmp; \ } \ } while (false) namespace Utils { bool registerActivator(); void unregisterActivator(); std::unordered_map splitData(const std::wstring_view &data); const std::filesystem::path &selfLocate(); std::wstring formatData(const std::vector> &data); bool writePipe(const std::filesystem::path &pipe, const std::wstring &data, bool wait = false); bool startProcess(const std::filesystem::path &app); inline bool checkResult(const HRESULT &hr) { if (FAILED(hr)) { tLog << hr; return false; } return true; } -}; \ No newline at end of file +};