vcpkg/toolsrc/include/PackageSpecParseResult.h

33 lines
808 B
C
Raw Normal View History

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