diff --git a/src/snoretoastactions.h b/src/snoretoastactions.h index 75e9563..2317f0d 100644 --- a/src/snoretoastactions.h +++ b/src/snoretoastactions.h @@ -1,86 +1,68 @@ /* SnoreToast is capable to invoke Windows 8 toast notifications. Copyright (C) 2013-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 -#if __cplusplus > 201402L || _HAS_CXX17 -#define SNORE_HAS_CXX17 -#endif - -#ifdef SNORE_HAS_CXX17 -#include -#endif - class SnoreToastActions { public: enum class Actions { Clicked, Hidden, Dismissed, Timedout, ButtonClicked, TextEntered, Error = -1 }; static const inline std::wstring& getActionString(const Actions &a) { return actionMap().at(a); } - static inline SnoreToastActions::Actions getAction(const std::wstring &s) + template + static inline SnoreToastActions::Actions getAction(const T &s) { for (const auto &a : actionMap()) { if (a.second.compare(s) == 0) { return a.first; } } return SnoreToastActions::Actions::Error; } -#ifdef SNORE_HAS_CXX17 - static inline SnoreToastActions::Actions getAction(const std::wstring_view &s) - { - for (const auto &a : actionMap()) { - if (a.second.compare(s) == 0) { - return a.first; - } - } - return SnoreToastActions::Actions::Error; - } -#endif private: static const std::map &actionMap(){ static const std::map _ActionStrings = { {Actions::Clicked, L"clicked"}, {Actions::Hidden, L"hidden"}, {Actions::Dismissed, L"dismissed"}, {Actions::Timedout, L"timedout"}, {Actions::ButtonClicked, L"buttonClicked"}, {Actions::TextEntered, L"textEntered"} }; return _ActionStrings; } };