Rework LinkageType enum
MODIFY
include/PostBuildLint_BuildInfo.h
include/PostBuildLint_BuildInfo.h
@@ -12,8 +12,8 @@ namespace vcpkg::PostBuildLint
{
static BuildInfo create(std::unordered_map<std::string, std::string> pgh);
- LinkageType::Type crt_linkage;
- LinkageType::Type library_linkage;
+ LinkageType crt_linkage;
+ LinkageType library_linkage;
std::map<BuildPolicies, OptBool> policies;
};

MODIFY
include/PostBuildLint_BuildType.h
include/PostBuildLint_BuildType.h
@@ -18,30 +18,30 @@ namespace vcpkg::PostBuildLint::BuildType
{
Type() = delete;
- constexpr explicit Type(const BackingEnum backing_enum, const ConfigurationType::Type config, const LinkageType::Type linkage) :
+ constexpr explicit Type(const BackingEnum backing_enum, const ConfigurationType::Type config, const LinkageType linkage) :
backing_enum(backing_enum), m_config(config), m_linkage(linkage) { }
constexpr operator BackingEnum() const { return backing_enum; }
const ConfigurationType::Type& config() const;
- const LinkageType::Type& linkage() const;
+ const LinkageType& linkage() const;
const std::regex& crt_regex() const;
const std::string& to_string() const;
private:
BackingEnum backing_enum;
ConfigurationType::Type m_config;
- LinkageType::Type m_linkage;
+ LinkageType m_linkage;
};
static const std::string ENUM_NAME = "vcpkg::PostBuildLint::BuildType";
- static constexpr Type DEBUG_STATIC = Type(BackingEnum::DEBUG_STATIC, ConfigurationType::DEBUG, LinkageType::STATIC);
- static constexpr Type DEBUG_DYNAMIC = Type(BackingEnum::DEBUG_DYNAMIC, ConfigurationType::DEBUG, LinkageType::DYNAMIC);
- static constexpr Type RELEASE_STATIC = Type(BackingEnum::RELEASE_STATIC, ConfigurationType::RELEASE, LinkageType::STATIC);
- static constexpr Type RELEASE_DYNAMIC = Type(BackingEnum::RELEASE_DYNAMIC, ConfigurationType::RELEASE, LinkageType::DYNAMIC);
+ static constexpr Type DEBUG_STATIC = Type(BackingEnum::DEBUG_STATIC, ConfigurationType::DEBUG, LinkageTypeC::STATIC);
+ static constexpr Type DEBUG_DYNAMIC = Type(BackingEnum::DEBUG_DYNAMIC, ConfigurationType::DEBUG, LinkageTypeC::DYNAMIC);
+ static constexpr Type RELEASE_STATIC = Type(BackingEnum::RELEASE_STATIC, ConfigurationType::RELEASE, LinkageTypeC::STATIC);
+ static constexpr Type RELEASE_DYNAMIC = Type(BackingEnum::RELEASE_DYNAMIC, ConfigurationType::RELEASE, LinkageTypeC::DYNAMIC);
static constexpr std::array<Type, 4> values = { DEBUG_STATIC, DEBUG_DYNAMIC, RELEASE_STATIC, RELEASE_DYNAMIC };
- Type value_of(const ConfigurationType::Type& config, const LinkageType::Type& linkage);
+ Type value_of(const ConfigurationType::Type& config, const LinkageType& linkage);
}

MODIFY
include/PostBuildLint_LinkageType.h
include/PostBuildLint_LinkageType.h
#pragma once
#include <string>
-namespace vcpkg::PostBuildLint::LinkageType
+namespace vcpkg::PostBuildLint
+{
+ struct LinkageType final
{
enum class BackingEnum
{
@@ -10,10 +12,10 @@ namespace vcpkg::PostBuildLint::LinkageType
STATIC
};
- struct Type
- {
- constexpr Type() : backing_enum(BackingEnum::NULLVALUE) {}
- constexpr explicit Type(BackingEnum backing_enum) : backing_enum(backing_enum) { }
+ static LinkageType value_of(const std::string& as_string);
+
+ constexpr LinkageType() : backing_enum(BackingEnum::NULLVALUE) {}
+ constexpr explicit LinkageType(BackingEnum backing_enum) : backing_enum(backing_enum) { }
constexpr operator BackingEnum() const { return backing_enum; }
const std::string& to_string() const;
@@ -22,13 +24,14 @@ namespace vcpkg::PostBuildLint::LinkageType
BackingEnum backing_enum;
};
- static const std::string ENUM_NAME = "vcpkg::PostBuildLint::LinkageType";
-
- static constexpr Type NULLVALUE(BackingEnum::NULLVALUE);
- static constexpr Type DYNAMIC(BackingEnum::DYNAMIC);
- static constexpr Type STATIC(BackingEnum::STATIC);
+ namespace LinkageTypeC
+ {
+ static constexpr const char* ENUM_NAME = "vcpkg::PostBuildLint::LinkageType";
- static constexpr std::array<Type, 2> values = { DYNAMIC, STATIC };
+ static constexpr LinkageType NULLVALUE(LinkageType::BackingEnum::NULLVALUE);
+ static constexpr LinkageType DYNAMIC(LinkageType::BackingEnum::DYNAMIC);
+ static constexpr LinkageType STATIC(LinkageType::BackingEnum::STATIC);
- Type value_of(const std::string& as_string);
+ static constexpr std::array<LinkageType, 2> VALUES = { DYNAMIC, STATIC };
+ }
}

MODIFY
src/PostBuildLint_BuildInfo.cpp
src/PostBuildLint_BuildInfo.cpp
@@ -19,11 +19,11 @@ namespace vcpkg::PostBuildLint
BuildInfo build_info;
const std::string crt_linkage_as_string = details::remove_required_field(&pgh, BuildInfoRequiredField::CRT_LINKAGE);
build_info.crt_linkage = LinkageType::value_of(crt_linkage_as_string);
- Checks::check_exit(VCPKG_LINE_INFO, build_info.crt_linkage != LinkageType::NULLVALUE, "Invalid crt linkage type: [%s]", crt_linkage_as_string);
+ Checks::check_exit(VCPKG_LINE_INFO, build_info.crt_linkage != LinkageTypeC::NULLVALUE, "Invalid crt linkage type: [%s]", crt_linkage_as_string);
const std::string library_linkage_as_string = details::remove_required_field(&pgh, BuildInfoRequiredField::LIBRARY_LINKAGE);
build_info.library_linkage = LinkageType::value_of(library_linkage_as_string);
- Checks::check_exit(VCPKG_LINE_INFO, build_info.library_linkage != LinkageType::NULLVALUE, "Invalid library linkage type: [%s]", library_linkage_as_string);
+ Checks::check_exit(VCPKG_LINE_INFO, build_info.library_linkage != LinkageTypeC::NULLVALUE, "Invalid library linkage type: [%s]", library_linkage_as_string);
// The remaining entries are policies
for (const std::unordered_map<std::string, std::string>::value_type& p : pgh)

MODIFY
src/PostBuildLint_BuildType.cpp
src/PostBuildLint_BuildType.cpp
namespace vcpkg::PostBuildLint::BuildType
{
- Type value_of(const ConfigurationType::Type& config, const LinkageType::Type& linkage)
+ Type value_of(const ConfigurationType::Type& config, const LinkageType& linkage)
{
- if (config == ConfigurationType::DEBUG && linkage == LinkageType::STATIC)
+ if (config == ConfigurationType::DEBUG && linkage == LinkageTypeC::STATIC)
{
return DEBUG_STATIC;
}
- if (config == ConfigurationType::DEBUG && linkage == LinkageType::DYNAMIC)
+ if (config == ConfigurationType::DEBUG && linkage == LinkageTypeC::DYNAMIC)
{
return DEBUG_DYNAMIC;
}
- if (config == ConfigurationType::RELEASE && linkage == LinkageType::STATIC)
+ if (config == ConfigurationType::RELEASE && linkage == LinkageTypeC::STATIC)
{
return RELEASE_STATIC;
}
- if (config == ConfigurationType::RELEASE && linkage == LinkageType::DYNAMIC)
+ if (config == ConfigurationType::RELEASE && linkage == LinkageTypeC::DYNAMIC)
{
return RELEASE_DYNAMIC;
}
@@ -34,7 +34,7 @@ namespace vcpkg::PostBuildLint::BuildType
return this->m_config;
}
- const LinkageType::Type& Type::linkage() const
+ const LinkageType& Type::linkage() const
{
return this->m_linkage;
}

MODIFY
src/PostBuildLint_LinkageType.cpp
src/PostBuildLint_LinkageType.cpp
#include "vcpkg_Enums.h"
#include "vcpkg_Checks.h"
-namespace vcpkg::PostBuildLint::LinkageType
+namespace vcpkg::PostBuildLint
{
- static const std::string NULLVALUE_STRING = Enums::nullvalue_to_string(ENUM_NAME);
+ static const std::string NULLVALUE_STRING = Enums::nullvalue_to_string(LinkageTypeC::ENUM_NAME);
static const std::string NAME_DYNAMIC = "dynamic";
static const std::string NAME_STATIC = "static";
- const std::string& Type::to_string() const
- {
- switch (this->backing_enum)
- {
- case LinkageType::DYNAMIC:
- return NAME_DYNAMIC;
- case LinkageType::STATIC:
- return NAME_STATIC;
- case LinkageType::NULLVALUE:
- return NULLVALUE_STRING;
- default:
- Checks::unreachable(VCPKG_LINE_INFO);
- }
- }
-
- Type value_of(const std::string& as_string)
+ LinkageType LinkageType::value_of(const std::string& as_string)
{
if (as_string == NAME_DYNAMIC)
{
- return LinkageType::DYNAMIC;
+ return LinkageTypeC::DYNAMIC;
}
if (as_string == NAME_STATIC)
{
- return LinkageType::STATIC;
+ return LinkageTypeC::STATIC;
}
- return LinkageType::NULLVALUE;
+ return LinkageTypeC::NULLVALUE;
+ }
+
+ const std::string& LinkageType::to_string() const
+ {
+ switch (this->backing_enum)
+ {
+ case LinkageTypeC::DYNAMIC:
+ return NAME_DYNAMIC;
+ case LinkageTypeC::STATIC:
+ return NAME_STATIC;
+ case LinkageTypeC::NULLVALUE:
+ return NULLVALUE_STRING;
+ default:
+ Checks::unreachable(VCPKG_LINE_INFO);
+ }
}
}

Rework LinkageType enum