2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
|
|
|
#include "package_spec_parse_result.h"
|
|
|
|
#include "triplet.h"
|
|
|
|
#include "expected.h"
|
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
|
|
|
struct package_spec
|
|
|
|
{
|
2016-10-04 08:45:01 +08:00
|
|
|
static expected<package_spec> from_string(const std::string& spec_as_string, const triplet& default_target_triplet);
|
2016-09-24 07:39:07 +08:00
|
|
|
|
2016-10-05 05:47:42 +08:00
|
|
|
static expected<package_spec> 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
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
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 <>
|
|
|
|
struct equal_to<vcpkg::package_spec>
|
|
|
|
{
|
|
|
|
bool operator()(const vcpkg::package_spec& left, const vcpkg::package_spec& right) const
|
|
|
|
{
|
|
|
|
return left == right;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace std
|