2016-09-18 20:50:08 -07:00
|
|
|
#pragma once
|
2017-04-03 14:47:30 -07:00
|
|
|
#include "PackageSpecParseResult.h"
|
2017-04-03 15:02:45 -07:00
|
|
|
#include "Triplet.h"
|
2017-03-31 16:33:10 -07:00
|
|
|
#include "vcpkg_expected.h"
|
2016-09-18 20:50:08 -07:00
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
2017-04-03 14:45:00 -07:00
|
|
|
struct PackageSpec
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-06-05 15:58:47 -07:00
|
|
|
static ExpectedT<PackageSpec, PackageSpecParseResult> from_string(const std::string& spec_as_string,
|
|
|
|
const Triplet& default_triplet);
|
2017-05-02 17:52:59 -07:00
|
|
|
static std::string to_string(const std::string& name, const Triplet& triplet);
|
2017-06-05 15:58:47 -07:00
|
|
|
static ExpectedT<PackageSpec, PackageSpecParseResult> from_name_and_triplet(const std::string& name,
|
|
|
|
const Triplet& triplet);
|
2016-10-03 17:45:01 -07:00
|
|
|
|
|
|
|
const std::string& name() const;
|
|
|
|
|
2017-04-10 13:03:34 -07:00
|
|
|
const Triplet& triplet() const;
|
2016-09-18 20:50:08 -07:00
|
|
|
|
|
|
|
std::string dir() const;
|
2016-10-03 17:45:01 -07:00
|
|
|
|
2017-04-03 17:06:53 -07:00
|
|
|
std::string to_string() const;
|
2017-01-27 17:28:00 -08:00
|
|
|
|
2016-10-03 17:45:01 -07:00
|
|
|
private:
|
|
|
|
std::string m_name;
|
2017-04-10 13:04:34 -07:00
|
|
|
Triplet m_triplet;
|
2016-09-18 20:50:08 -07:00
|
|
|
};
|
|
|
|
|
2017-06-19 15:06:15 -07:00
|
|
|
struct FullPackageSpec
|
|
|
|
{
|
|
|
|
PackageSpec package_spec;
|
|
|
|
std::vector<std::string> features;
|
|
|
|
};
|
|
|
|
|
2017-04-03 14:45:00 -07:00
|
|
|
bool operator==(const PackageSpec& left, const PackageSpec& right);
|
2017-04-12 22:36:44 -07:00
|
|
|
bool operator!=(const PackageSpec& left, const PackageSpec& right);
|
2017-04-27 17:56:06 -07:00
|
|
|
}
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
template<>
|
|
|
|
struct std::hash<vcpkg::PackageSpec>
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-04-27 17:56:06 -07:00
|
|
|
size_t operator()(const vcpkg::PackageSpec& value) const
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-04-27 17:56:06 -07: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; }
|
|
|
|
};
|