Use nameof instead boost::typeindex for more readability
This commit is contained in:
parent
085f4d8b26
commit
e2510d3b64
5 changed files with 16 additions and 14 deletions
|
@ -10,6 +10,8 @@ find_package(Boost 1.84.0 REQUIRED COMPONENTS url program_options)
|
||||||
find_package(utempl REQUIRED)
|
find_package(utempl REQUIRED)
|
||||||
find_package(llhttp REQUIRED)
|
find_package(llhttp REQUIRED)
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
|
find_package(nameof REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
cmake_policy(SET CMP0079 NEW)
|
cmake_policy(SET CMP0079 NEW)
|
||||||
|
|
||||||
|
@ -19,7 +21,7 @@ target_include_directories(
|
||||||
cserver
|
cserver
|
||||||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
target_link_libraries(cserver INTERFACE utempl::utempl ${Boost_LIBRARIES} llhttp ${OPENSSL_LIBRARIES} )
|
target_link_libraries(cserver INTERFACE utempl::utempl nameof::nameof ${Boost_LIBRARIES} llhttp ${OPENSSL_LIBRARIES} )
|
||||||
|
|
||||||
target_compile_features(cserver INTERFACE cxx_std_23)
|
target_compile_features(cserver INTERFACE cxx_std_23)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <cserver/engine/not_implemented.hpp>
|
#include <cserver/engine/not_implemented.hpp>
|
||||||
#include <cserver/engine/components.hpp>
|
#include <cserver/engine/components.hpp>
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/type_index.hpp>
|
#include <nameof.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace cserver::cli {
|
namespace cserver::cli {
|
||||||
|
@ -44,7 +44,7 @@ struct Manager {
|
||||||
([&]{
|
([&]{
|
||||||
using Current = decltype(Configs)::Type;
|
using Current = decltype(Configs)::Type;
|
||||||
boost::program_options::options_description desc(fmt::format("{} options",
|
boost::program_options::options_description desc(fmt::format("{} options",
|
||||||
boost::typeindex::type_id<Current>().pretty_name()));
|
NAMEOF_TYPE(Current)));
|
||||||
utempl::Unpack(utempl::PackConstexprWrapper<decltype(Configs)::kValue>(), [&](auto... vs) {
|
utempl::Unpack(utempl::PackConstexprWrapper<decltype(Configs)::kValue>(), [&](auto... vs) {
|
||||||
auto&& add = desc.add_options();
|
auto&& add = desc.add_options();
|
||||||
([&]{
|
([&]{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <cserver/engine/components.hpp>
|
#include <cserver/engine/components.hpp>
|
||||||
#include <boost/type_index.hpp>
|
#include <nameof.hpp>
|
||||||
|
|
||||||
COMPONENT_REQUIRES(Some, requires(T t){{t.f()} -> std::same_as<void>;});
|
COMPONENT_REQUIRES(Some, requires(T t){{t.f()} -> std::same_as<void>;});
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@ TEST(Meta, AllDependencies) {
|
||||||
.GetContextFor<cserver::ComponentConfig<"some", SomeComponent, {}>>()
|
.GetContextFor<cserver::ComponentConfig<"some", SomeComponent, {}>>()
|
||||||
.FindAllComponents<SomeM>());
|
.FindAllComponents<SomeM>());
|
||||||
|
|
||||||
EXPECT_EQ(boost::typeindex::type_id<R>().pretty_name(),
|
EXPECT_EQ(NAMEOF_TYPE(R),
|
||||||
boost::typeindex::type_id<Need>().pretty_name());
|
NAMEOF_TYPE(Need));
|
||||||
|
|
||||||
using DependenciesNeed = const cserver::DependencyGraph<
|
using DependenciesNeed = const cserver::DependencyGraph<
|
||||||
cserver::DependencyGraphElement<
|
cserver::DependencyGraphElement<
|
||||||
|
@ -56,6 +56,6 @@ TEST(Meta, AllDependencies) {
|
||||||
"some",
|
"some",
|
||||||
{utempl::ConstexprString{"other"}, utempl::ConstexprString{"other2"}}>>;
|
{utempl::ConstexprString{"other"}, utempl::ConstexprString{"other2"}}>>;
|
||||||
|
|
||||||
EXPECT_EQ(boost::typeindex::type_id<decltype(dependencies)>().pretty_name(),
|
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)),
|
||||||
boost::typeindex::type_id<DependenciesNeed>().pretty_name());
|
NAMEOF_TYPE(DependenciesNeed));
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <cserver/engine/components.hpp>
|
#include <cserver/engine/components.hpp>
|
||||||
#include <boost/type_index.hpp>
|
#include <nameof.hpp>
|
||||||
|
|
||||||
struct SomeComponent {
|
struct SomeComponent {
|
||||||
static constexpr utempl::ConstexprString kName = "some";
|
static constexpr utempl::ConstexprString kName = "some";
|
||||||
|
@ -30,6 +30,6 @@ TEST(Dependencies, Get) {
|
||||||
cserver::DependencyGraphElement<
|
cserver::DependencyGraphElement<
|
||||||
"other",
|
"other",
|
||||||
{utempl::ConstexprString{"some"}}>>;
|
{utempl::ConstexprString{"some"}}>>;
|
||||||
EXPECT_EQ(boost::typeindex::type_id<decltype(dependencies)>().pretty_name(),
|
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)),
|
||||||
boost::typeindex::type_id<Need>().pretty_name());
|
NAMEOF_TYPE(Need));
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <cserver/engine/components.hpp>
|
#include <cserver/engine/components.hpp>
|
||||||
#include <boost/type_index.hpp>
|
#include <nameof.hpp>
|
||||||
|
|
||||||
COMPONENT_REQUIRES(Some, requires(T t){{t.f()} -> std::same_as<void>;});
|
COMPONENT_REQUIRES(Some, requires(T t){{t.f()} -> std::same_as<void>;});
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ TEST(Meta, OneDependency) {
|
||||||
"other2",
|
"other2",
|
||||||
{}>>;
|
{}>>;
|
||||||
|
|
||||||
EXPECT_EQ(boost::typeindex::type_id<decltype(dependencies)>().pretty_name(),
|
EXPECT_EQ(NAMEOF_TYPE(decltype(dependencies)),
|
||||||
boost::typeindex::type_id<Need>().pretty_name());
|
NAMEOF_TYPE(Need));
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SomeStruct2 {
|
struct SomeStruct2 {
|
||||||
|
|
Loading…
Reference in a new issue