Add AlertAction type

This commit is contained in:
Dan Paulat 2023-05-02 22:13:11 -05:00
parent 9019aa5e33
commit 411a949be9
3 changed files with 74 additions and 2 deletions

View 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

View 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