aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/opt_bool.h
blob: 06642a399f24b4aabb9cf644587e65d0a426b2b3 (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::opt_bool
{
    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 opt_bool_t = opt_bool::type;
}