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

namespace vcpkg
{
    static const std::string UNSPECIFIED_NAME = "unspecified";
    static const std::string ENABLED_NAME = "enabled";
    static const std::string DISABLED_NAME = "disabled";

    OptBool OptBool::parse(const std::string& s)
    {
        if (s == UNSPECIFIED_NAME)
        {
            return OptBoolC::UNSPECIFIED;
        }

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

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

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