VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
name_detector.h 文件参考

Compile-time type-name and enum-name detection utilities. 更多...

#include <string_view>
#include "../thirdparty/nameof.h"
name_detector.h 的引用(Include)关系图:
此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

命名空间

函数

template<typename T>
constexpr bool vlink::NameDetector::is_support () noexcept
 Checks at compile time whether the nameof library can produce a type name for T.
template<typename T>
constexpr std::string_view vlink::NameDetector::get () noexcept
 Returns the unqualified compile-time name of type T as a std::string_view.
template<typename T>
std::string_view vlink::NameDetector::get_enum (T e) noexcept
 Returns the string representation of an enumeration value e.

详细描述

Compile-time type-name and enum-name detection utilities.

The vlink::NameDetector namespace wraps the third-party nameof library to provide a portable, constexpr API for obtaining the string representation of a type or an enumeration value at compile time.

These utilities are used by the VLink plugin system to automatically derive plugin identifiers from interface class names, avoiding error-prone manual string registration.

Platform notes:

  • On Windows (MSVC / MSYS2) the nameof library may prefix types with "struct " or "class ". NameDetector::get() strips these prefixes automatically to return only the unqualified type name.
  • On GCC/Clang the result of nameof::nameof_type<T>() is used directly.
注解
The get<T>() function returns a constexpr std::string_view that points into static storage generated by the compiler. The view is valid for the entire program lifetime.
Example
// Check support and get the type name:
constexpr std::string_view name = vlink::NameDetector::get<MyPlugin>();
// name == "MyPlugin"
}
// Get enum value name at runtime:
enum class Color { Red, Green, Blue };
std::string_view name = vlink::NameDetector::get_enum(Color::Green);
// name == "Green"