aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/triplet.h
blob: bc99a17dfad960b9fde19031c6e9e15d3b729f2d (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once

#include <string>

namespace vcpkg
{
    struct triplet
    {
        static triplet from_canonical_name(const std::string& triplet_as_string);

        enum class BuildType
        {
            DYNAMIC,
            STATIC
        };

        static const triplet X86_WINDOWS;
        static const triplet X64_WINDOWS;
        static const triplet X86_UWP;
        static const triplet X64_UWP;
        static const triplet ARM_UWP;

        BuildType build_type() const;

        const std::string& canonical_name() const;

        std::string architecture() const;

        std::string system() const;

    private:
        std::string m_canonical_name;
    };

    bool operator==(const triplet& left, const triplet& right);

    bool operator!=(const triplet& left, const triplet& right);

    std::string to_string(const triplet& spec);

    std::string to_printf_arg(const triplet& spec);

    std::ostream& operator<<(std::ostream& os, const triplet& spec);
}

namespace std
{
    template <>
    struct hash<vcpkg::triplet>
    {
        size_t operator()(const vcpkg::triplet& t) const
        {
            std::hash<std::string> hasher;
            size_t hash = 17;
            hash = hash * 31 + hasher(t.canonical_name());
            return hash;
        }
    };

    template <>
    struct equal_to<vcpkg::triplet>
    {
        bool operator()(const vcpkg::triplet& left, const vcpkg::triplet& right) const
        {
            return left == right;
        }
    };
} // namespace std