aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/opt_bool.cpp
blob: 324936fb4d76defd12dfdd5b3d67aaac3d4de3ac (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
#include "pch.h"
#include "opt_bool.h"
#include "vcpkg_Checks.h"

namespace vcpkg::opt_bool
{
    static const std::string UNSPECIFIED_NAME = "unspecified";
    static const std::string ENABLED_NAME = "enabled";
    static const std::string DISABLED_NAME = "disabled";
    type parse(const std::string& s)
    {
        if (s == UNSPECIFIED_NAME)
        {
            return opt_bool_t::UNSPECIFIED;
        }

        if (s == ENABLED_NAME)
        {
            return opt_bool_t::ENABLED;
        }

        if (s == DISABLED_NAME)
        {
            return opt_bool_t::DISABLED;
        }

        Checks::exit_with_message("Could not convert string [%s] to opt_bool", s);
    }
}