2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
2017-02-01 05:31:45 +08:00
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
2017-04-04 05:43:44 +08:00
|
|
|
namespace vcpkg::OptBool
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-04 05:43:44 +08:00
|
|
|
enum class Type
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-02-01 05:31:45 +08:00
|
|
|
UNSPECIFIED = 0,
|
2017-02-01 04:59:20 +08:00
|
|
|
ENABLED,
|
|
|
|
DISABLED
|
2016-09-19 11:50:08 +08:00
|
|
|
};
|
2017-02-01 05:31:45 +08:00
|
|
|
|
2017-04-04 05:43:44 +08:00
|
|
|
Type parse(const std::string& s);
|
2017-02-01 05:31:45 +08:00
|
|
|
|
|
|
|
template <class T>
|
2017-04-04 05:43:44 +08:00
|
|
|
Type from_map(const std::map<T, std::string>& map, const T& key)
|
2017-02-01 05:31:45 +08:00
|
|
|
{
|
|
|
|
auto it = map.find(key);
|
|
|
|
if (it == map.cend())
|
|
|
|
{
|
2017-04-04 05:43:44 +08:00
|
|
|
return Type::UNSPECIFIED;
|
2017-02-01 05:31:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return parse(*it);
|
|
|
|
}
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
2017-02-01 05:31:45 +08:00
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
2017-04-04 05:43:44 +08:00
|
|
|
using OptBoolT = OptBool::Type;
|
2017-02-01 05:31:45 +08:00
|
|
|
}
|