2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
2017-06-06 06:58:47 +08:00
|
|
|
|
|
|
|
#include "vcpkg_expected.h"
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
2017-04-04 05:47:30 +08:00
|
|
|
enum class PackageSpecParseResult
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2016-10-05 05:48:39 +08:00
|
|
|
SUCCESS = 0,
|
|
|
|
TOO_MANY_COLONS,
|
|
|
|
INVALID_CHARACTERS
|
2016-09-19 11:50:08 +08:00
|
|
|
};
|
|
|
|
|
2017-06-06 06:58:47 +08:00
|
|
|
CStringView to_string(PackageSpecParseResult ev) noexcept;
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-06-06 06:58:47 +08:00
|
|
|
template<>
|
|
|
|
struct ErrorHolder<PackageSpecParseResult>
|
|
|
|
{
|
|
|
|
ErrorHolder() : m_err(PackageSpecParseResult::SUCCESS) {}
|
|
|
|
ErrorHolder(PackageSpecParseResult err) : m_err(err) {}
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-06-06 06:58:47 +08:00
|
|
|
constexpr bool has_error() const { return m_err != PackageSpecParseResult::SUCCESS; }
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-06-06 07:57:35 +08:00
|
|
|
const PackageSpecParseResult& error() const { return m_err; }
|
|
|
|
PackageSpecParseResult& error() { return m_err; }
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-06-06 06:58:47 +08:00
|
|
|
CStringView to_string() const { return vcpkg::to_string(m_err); }
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2017-06-06 06:58:47 +08:00
|
|
|
private:
|
|
|
|
PackageSpecParseResult m_err;
|
2016-10-05 05:46:40 +08:00
|
|
|
};
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|