aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/OptBool.h
blob: 4098e6f03408a69ce36cac98259b5fa742faa2f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <string>
#include <map>

namespace vcpkg::OptBool
{
    enum class Type
    {
        UNSPECIFIED = 0,
        ENABLED,
        DISABLED
    };

    Type parse(const std::string& s);

    template <class T>
    Type from_map(const std::map<T, std::string>& map, const T& key)
    {
        auto it = map.find(key);
        if (it == map.cend())
        {
            return Type::UNSPECIFIED;
        }

        return parse(*it);
    }
}

namespace vcpkg
{
    using OptBoolT = OptBool::Type;
}