aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/package_spec.h
blob: 942b34adc50fd05de6e688e7a9d94bd44b8927a5 (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
#pragma once
#include <string>
#include "package_spec_parse_result.h"
#include "triplet.h"
#include "expected.h"

namespace vcpkg
{
    struct package_spec
    {
        static expected<package_spec> from_string(const std::string& spec, const triplet& default_target_triplet);

        std::string name;
        triplet target_triplet;

        std::string dir() const;
    };

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

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

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

    std::ostream& operator<<(std::ostream& os, const package_spec& spec);
} //namespace vcpkg

namespace std
{
    template <>
    struct hash<vcpkg::package_spec>
    {
        size_t operator()(const vcpkg::package_spec& value) const
        {
            size_t hash = 17;
            hash = hash * 31 + std::hash<std::string>()(value.name);
            hash = hash * 31 + std::hash<vcpkg::triplet>()(value.target_triplet);
            return hash;
        }
    };

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