mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 22:20:04 +00:00
Add AlertAction type
This commit is contained in:
parent
9019aa5e33
commit
411a949be9
3 changed files with 74 additions and 2 deletions
42
scwx-qt/source/scwx/qt/types/alert_types.cpp
Normal file
42
scwx-qt/source/scwx/qt/types/alert_types.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include <scwx/qt/types/alert_types.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace types
|
||||
{
|
||||
|
||||
static const std::unordered_map<AlertAction, std::string> alertActionName_ {
|
||||
{AlertAction::Go, "Go"},
|
||||
{AlertAction::View, "View"},
|
||||
{AlertAction::Unknown, "?"}};
|
||||
|
||||
AlertAction GetAlertAction(const std::string& name)
|
||||
{
|
||||
auto result =
|
||||
std::find_if(alertActionName_.cbegin(),
|
||||
alertActionName_.cend(),
|
||||
[&](const std::pair<AlertAction, std::string>& pair) -> bool
|
||||
{ return boost::iequals(pair.second, name); });
|
||||
|
||||
if (result != alertActionName_.cend())
|
||||
{
|
||||
return result->first;
|
||||
}
|
||||
else
|
||||
{
|
||||
return AlertAction::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetAlertActionName(AlertAction alertAction)
|
||||
{
|
||||
return alertActionName_.at(alertAction);
|
||||
}
|
||||
|
||||
} // namespace types
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
28
scwx-qt/source/scwx/qt/types/alert_types.hpp
Normal file
28
scwx-qt/source/scwx/qt/types/alert_types.hpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/util/iterator.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace types
|
||||
{
|
||||
|
||||
enum class AlertAction
|
||||
{
|
||||
Go,
|
||||
View,
|
||||
Unknown
|
||||
};
|
||||
typedef scwx::util::Iterator<AlertAction, AlertAction::Go, AlertAction::View>
|
||||
AlertActionIterator;
|
||||
|
||||
AlertAction GetAlertAction(const std::string& name);
|
||||
std::string GetAlertActionName(AlertAction alertAction);
|
||||
|
||||
} // namespace types
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue