2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
2017-04-04 05:47:30 +08:00
|
|
|
#include "PackageSpecParseResult.h"
|
2017-04-04 06:02:45 +08:00
|
|
|
#include "Triplet.h"
|
2017-04-01 07:33:10 +08:00
|
|
|
#include "vcpkg_expected.h"
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
2017-04-04 05:45:00 +08:00
|
|
|
struct PackageSpec
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-11 04:00:33 +08:00
|
|
|
static Expected<PackageSpec> from_string(const std::string& spec_as_string, const Triplet& default_triplet);
|
2017-05-03 08:52:59 +08:00
|
|
|
static std::string to_string(const std::string& name, const Triplet& triplet);
|
2017-04-11 04:04:34 +08:00
|
|
|
static Expected<PackageSpec> from_name_and_triplet(const std::string& name, const Triplet& triplet);
|
2016-10-04 08:45:01 +08:00
|
|
|
|
|
|
|
const std::string& name() const;
|
|
|
|
|
2017-04-11 04:03:34 +08:00
|
|
|
const Triplet& triplet() const;
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
std::string dir() const;
|
2016-10-04 08:45:01 +08:00
|
|
|
|
2017-04-04 08:06:53 +08:00
|
|
|
std::string to_string() const;
|
2017-01-28 09:28:00 +08:00
|
|
|
|
2016-10-04 08:45:01 +08:00
|
|
|
private:
|
|
|
|
std::string m_name;
|
2017-04-11 04:04:34 +08:00
|
|
|
Triplet m_triplet;
|
2016-09-19 11:50:08 +08:00
|
|
|
};
|
|
|
|
|
2017-04-04 05:45:00 +08:00
|
|
|
bool operator==(const PackageSpec& left, const PackageSpec& right);
|
2017-04-13 13:36:44 +08:00
|
|
|
bool operator!=(const PackageSpec& left, const PackageSpec& right);
|
2017-04-28 08:56:06 +08:00
|
|
|
}
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-04-28 08:56:06 +08:00
|
|
|
template<>
|
|
|
|
struct std::hash<vcpkg::PackageSpec>
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-28 08:56:06 +08:00
|
|
|
size_t operator()(const vcpkg::PackageSpec& value) const
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-28 08:56:06 +08:00
|
|
|
size_t hash = 17;
|
|
|
|
hash = hash * 31 + std::hash<std::string>()(value.name());
|
|
|
|
hash = hash * 31 + std::hash<vcpkg::Triplet>()(value.triplet());
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct std::equal_to<vcpkg::PackageSpec>
|
|
|
|
{
|
|
|
|
bool operator()(const vcpkg::PackageSpec& left, const vcpkg::PackageSpec& right) const { return left == right; }
|
|
|
|
};
|