2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
2017-04-04 05:47:30 +08:00
|
|
|
#include "PackageSpecParseResult.h"
|
2016-09-19 11:50:08 +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-04 05:45:00 +08:00
|
|
|
static expected<PackageSpec> from_string(const std::string& spec_as_string, const triplet& default_target_triplet);
|
2016-09-24 07:39:07 +08:00
|
|
|
|
2017-04-04 05:45:00 +08:00
|
|
|
static expected<PackageSpec> from_name_and_triplet(const std::string& name, const triplet& target_triplet);
|
2016-10-04 08:45:01 +08:00
|
|
|
|
|
|
|
const std::string& name() const;
|
|
|
|
|
|
|
|
const triplet& target_triplet() const;
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-01-31 04:45:26 +08:00
|
|
|
std::string display_name() const;
|
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
std::string dir() const;
|
2016-10-04 08:45:01 +08:00
|
|
|
|
2017-01-28 09:28:00 +08:00
|
|
|
std::string toString() const;
|
|
|
|
|
2016-10-04 08:45:01 +08:00
|
|
|
private:
|
|
|
|
std::string m_name;
|
|
|
|
triplet m_target_triplet;
|
2016-09-19 11:50:08 +08:00
|
|
|
};
|
|
|
|
|
2017-04-04 05:45:00 +08:00
|
|
|
std::string to_printf_arg(const PackageSpec& spec);
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-04-04 05:45:00 +08:00
|
|
|
bool operator==(const PackageSpec& left, const PackageSpec& right);
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-04-04 05:45:00 +08:00
|
|
|
std::ostream& operator<<(std::ostream& os, const PackageSpec& spec);
|
2016-09-19 11:50:08 +08:00
|
|
|
} //namespace vcpkg
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <>
|
2017-04-04 05:45:00 +08:00
|
|
|
struct hash<vcpkg::PackageSpec>
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-04 05:45:00 +08:00
|
|
|
size_t operator()(const vcpkg::PackageSpec& value) const
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
|
|
|
size_t hash = 17;
|
2016-10-04 08:45:01 +08:00
|
|
|
hash = hash * 31 + std::hash<std::string>()(value.name());
|
|
|
|
hash = hash * 31 + std::hash<vcpkg::triplet>()(value.target_triplet());
|
2016-09-19 11:50:08 +08:00
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
2017-04-04 05:45:00 +08:00
|
|
|
struct equal_to<vcpkg::PackageSpec>
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-04 05:45:00 +08:00
|
|
|
bool operator()(const vcpkg::PackageSpec& left, const vcpkg::PackageSpec& right) const
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
|
|
|
return left == right;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace std
|