ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
tools_misc.h File Reference

杂项辅助函数和Protobuf特性萃取 More...

Classes

struct  ngl::tools::has_pb_desc< T, typename >
 检查类型是否具有Protobuf descriptor()方法 More...
struct  ngl::tools::has_pb_desc< T, std::void_t< decltype(T::descriptor())> >
 has_pb_desc 特化,检测 descriptor() 方法 More...
struct  ngl::tools::is_protobuf_message< T >
 检查类型是否为Protobuf消息类型 More...

Namespaces

namespace  ngl::tools
 工具函数命名空间。

Functions

std::size_t ngl::tools::strlen (const char *astr)
 安全的字符串长度计算
std::string & ngl::tools::type_name_handle (std::string &aname)
 处理C++类型名称,使其更易读
template<typename T>
std::string & ngl::tools::type_name ()
 获取类型的字符串表示
std::vector< const char * > ngl::tools::split_str (char *apbuff, int32_t abuff_cnt)
 按逗号分割字符缓冲区
template<std::size_t N>
void ngl::tools::split_str (char *apbuff, int32_t abuff_cnt, std::array< const char *, N > &aarr)
 分割字符串到固定大小数组
bool ngl::tools::bit (int32_t atype, int32_t acjson)
 检查指定位是否被设置
void ngl::tools::erase_repeat (std::string &astr, char ach)
 删除字符串中连续的重复字符
std::strong_ordering ngl::tools::less_member ()
 比较成员的递归终止函数
template<typename T>
auto ngl::tools::less_member (const T &alhs, const T &arhs)
 单成员三路比较
template<typename T, typename... TARGS>
auto ngl::tools::less_member (const T &alhs, const T &arhs, const TARGS &... amems)
 多成员三路比较
std::string_view ngl::tools::trim_ascii_spaces (std::string_view avalue)
 去除字符串首尾的ASCII空格

Detailed Description

杂项辅助函数和Protobuf特性萃取

提供字符串处理、类型名称获取、Protobuf消息特性检测等通用工具函数。 包含类型萃取器用于在编译期判断类型是否为Protobuf消息。

Note
所有类和函数均位于 ngl::tools 命名空间下。
// 类型名称获取示例
std::string& name = ngl::tools::type_name<MyClass>();
// Protobuf特性检测示例