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