aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/ParagraphParseResult.cpp
blob: c2da78d300cc37b3654342e8f23b9380af76a017 (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
34
35
36
37
38
39
40
41
42
43
44
45
#include "pch.h"
#include "vcpkg_Checks.h"
#include "ParagraphParseResult.h"

namespace vcpkg
{
    const char* ParagraphParseResultCategoryImpl::name() const noexcept
    {
        return "ParagraphParseResult";
    }

    std::string ParagraphParseResultCategoryImpl::message(int ev) const noexcept
    {
        switch (static_cast<ParagraphParseResult>(ev))
        {
            case ParagraphParseResult::SUCCESS:
                return "OK";
            case ParagraphParseResult::EXPECTED_ONE_PARAGRAPH:
                return "There should be exactly one paragraph";
            default:
                Checks::unreachable(VCPKG_LINE_INFO);
        }
    }

    const std::error_category& paragraph_parse_result_category()
    {
        static ParagraphParseResultCategoryImpl instance;
        return instance;
    }

    std::error_code make_error_code(ParagraphParseResult e)
    {
        return std::error_code(static_cast<int>(e), paragraph_parse_result_category());
    }

    ParagraphParseResult to_paragraph_parse_result(int i)
    {
        return static_cast<ParagraphParseResult>(i);
    }

    ParagraphParseResult to_paragraph_parse_result(std::error_code ec)
    {
        return to_paragraph_parse_result(ec.value());
    }
}