-
Notifications
You must be signed in to change notification settings - Fork 288
/
triplet.h
83 lines (61 loc) · 2.19 KB
/
triplet.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <vcpkg/base/fwd/fmt.h>
#include <vcpkg/base/fwd/optional.h>
#include <vcpkg/base/fwd/system.h>
#include <vcpkg/fwd/triplet.h>
#include <vcpkg/fwd/vcpkgcmdarguments.h>
#include <vcpkg/base/path.h>
#include <vcpkg/base/stringview.h>
#include <string>
namespace vcpkg
{
struct Triplet
{
public:
constexpr Triplet() noexcept : m_instance(&DEFAULT_INSTANCE) { }
static Triplet from_canonical_name(std::string triplet_as_string);
const std::string& canonical_name() const;
const std::string& to_string() const;
void to_string(std::string& out) const;
size_t hash_code() const;
Optional<CPUArchitecture> guess_architecture() const noexcept;
operator StringView() const { return canonical_name(); }
bool operator==(Triplet other) const { return this->m_instance == other.m_instance; }
bool operator<(Triplet other) const { return canonical_name() < other.canonical_name(); }
private:
static const TripletInstance DEFAULT_INSTANCE;
constexpr Triplet(const TripletInstance* ptr) : m_instance(ptr) { }
const TripletInstance* m_instance;
};
inline bool operator!=(Triplet left, Triplet right) { return !(left == right); }
}
VCPKG_FORMAT_AS(vcpkg::Triplet, vcpkg::StringView);
namespace std
{
template<>
struct hash<vcpkg::Triplet>
{
size_t operator()(vcpkg::Triplet t) const { return t.hash_code(); }
};
}
namespace vcpkg
{
Triplet default_triplet(const VcpkgCmdArguments& args, const TripletDatabase& database);
Triplet default_host_triplet(const VcpkgCmdArguments& args, const TripletDatabase& database);
struct TripletFile
{
std::string name;
Path location;
TripletFile(StringView name, StringView location);
Path get_full_path() const;
};
struct TripletDatabase
{
Path default_triplet_directory;
Path community_triplet_directory;
std::vector<TripletFile> available_triplets;
Path get_triplet_file_path(Triplet triplet) const;
bool is_valid_triplet_name(StringView name) const;
bool is_valid_triplet_canonical_name(StringView name) const;
};
}