paragraph_parse_result -> ParagraphParseResult

This commit is contained in:
Alexander Karatarakis 2017-04-03 14:48:24 -07:00
parent 83cde51334
commit 7ee180ebdd
6 changed files with 61 additions and 61 deletions

View File

@ -3,13 +3,13 @@
namespace vcpkg
{
enum class paragraph_parse_result
enum class ParagraphParseResult
{
SUCCESS = 0,
EXPECTED_ONE_PARAGRAPH
};
struct paragraph_parse_result_category_impl final : std::error_category
struct ParagraphParseResultCategoryImpl final : std::error_category
{
virtual const char* name() const noexcept override;
@ -18,18 +18,18 @@ namespace vcpkg
const std::error_category& paragraph_parse_result_category();
std::error_code make_error_code(paragraph_parse_result e);
std::error_code make_error_code(ParagraphParseResult e);
paragraph_parse_result to_paragraph_parse_result(int i);
ParagraphParseResult to_paragraph_parse_result(int i);
paragraph_parse_result to_paragraph_parse_result(std::error_code ec);
ParagraphParseResult to_paragraph_parse_result(std::error_code ec);
}
// Enable implicit conversion to std::error_code
namespace std
{
template <>
struct is_error_code_enum<vcpkg::paragraph_parse_result> : ::std::true_type
struct is_error_code_enum<vcpkg::ParagraphParseResult> : ::std::true_type
{
};
}

View File

@ -0,0 +1,45 @@
#include "pch.h"
#include "vcpkg_Checks.h"
#include "ParagraphParseResult.h"
namespace vcpkg
{
const char* ParagraphParseResultCategoryImpl::name() const noexcept
{
return "ParagraphParseResult";
}
std::string ParagraphParseResultCategoryImpl::message(int ev) const noexcept
{
switch (static_cast<ParagraphParseResult>(ev))
{
case ParagraphParseResult::SUCCESS:
return "OK";
case ParagraphParseResult::EXPECTED_ONE_PARAGRAPH:
return "There should be exactly one paragraph";
default:
Checks::unreachable(VCPKG_LINE_INFO);
}
}
const std::error_category& paragraph_parse_result_category()
{
static ParagraphParseResultCategoryImpl instance;
return instance;
}
std::error_code make_error_code(ParagraphParseResult e)
{
return std::error_code(static_cast<int>(e), paragraph_parse_result_category());
}
ParagraphParseResult to_paragraph_parse_result(int i)
{
return static_cast<ParagraphParseResult>(i);
}
ParagraphParseResult to_paragraph_parse_result(std::error_code ec)
{
return to_paragraph_parse_result(ec.value());
}
}

View File

@ -1,7 +1,7 @@
#include "pch.h"
#include "Paragraphs.h"
#include "vcpkg_Files.h"
#include "paragraph_parse_result.h"
#include "ParagraphParseResult.h"
namespace vcpkg::Paragraphs
{
@ -203,7 +203,7 @@ namespace vcpkg::Paragraphs
return p.at(0);
}
return std::error_code(paragraph_parse_result::EXPECTED_ONE_PARAGRAPH);
return std::error_code(ParagraphParseResult::EXPECTED_ONE_PARAGRAPH);
}
expected<std::vector<std::unordered_map<std::string, std::string>>> parse_paragraphs(const std::string& str)

View File

@ -1,45 +0,0 @@
#include "pch.h"
#include "vcpkg_Checks.h"
#include "paragraph_parse_result.h"
namespace vcpkg
{
const char* paragraph_parse_result_category_impl::name() const noexcept
{
return "paragraph_parse_result";
}
std::string paragraph_parse_result_category_impl::message(int ev) const noexcept
{
switch (static_cast<paragraph_parse_result>(ev))
{
case paragraph_parse_result::SUCCESS:
return "OK";
case paragraph_parse_result::EXPECTED_ONE_PARAGRAPH:
return "There should be exactly one paragraph";
default:
Checks::unreachable(VCPKG_LINE_INFO);
}
}
const std::error_category& paragraph_parse_result_category()
{
static paragraph_parse_result_category_impl instance;
return instance;
}
std::error_code make_error_code(paragraph_parse_result e)
{
return std::error_code(static_cast<int>(e), paragraph_parse_result_category());
}
paragraph_parse_result to_paragraph_parse_result(int i)
{
return static_cast<paragraph_parse_result>(i);
}
paragraph_parse_result to_paragraph_parse_result(std::error_code ec)
{
return to_paragraph_parse_result(ec.value());
}
}

View File

@ -140,7 +140,7 @@
<ClInclude Include="..\include\CStringView.h" />
<ClInclude Include="..\include\lazy.h" />
<ClInclude Include="..\include\LineInfo.h" />
<ClInclude Include="..\include\paragraph_parse_result.h" />
<ClInclude Include="..\include\ParagraphParseResult.h" />
<ClInclude Include="..\include\PostBuildLint_BuildInfo.h" />
<ClInclude Include="..\include\PostBuildLint_BuildPolicies.h" />
<ClInclude Include="..\include\coff_file_reader.h" />
@ -187,7 +187,7 @@
<ClCompile Include="..\src\commands_ci.cpp" />
<ClCompile Include="..\src\commands_env.cpp" />
<ClCompile Include="..\src\LineInfo.cpp" />
<ClCompile Include="..\src\paragraph_parse_result.cpp" />
<ClCompile Include="..\src\ParagraphParseResult.cpp" />
<ClCompile Include="..\src\PostBuildLint_BuildInfo.cpp" />
<ClCompile Include="..\src\PostBuildLint_BuildPolicies.cpp" />
<ClCompile Include="..\src\coff_file_reader.cpp" />

View File

@ -162,9 +162,6 @@
<ClCompile Include="..\src\LineInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\paragraph_parse_result.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\include\version_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -180,6 +177,9 @@
<ClCompile Include="..\src\PackageSpecParseResult.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\ParagraphParseResult.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\SourceParagraph.h">
@ -287,9 +287,6 @@
<ClInclude Include="..\include\LineInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\paragraph_parse_result.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\vcpkg_expected.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -314,5 +311,8 @@
<ClInclude Include="..\include\PackageSpecParseResult.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\ParagraphParseResult.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>