|
ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
|
声明工具库中的共享辅助函数和模板。 More...
#include <source_location>#include <unordered_map>#include <type_traits>#include <string_view>#include <functional>#include <algorithm>#include <stdexcept>#include <typeinfo>#include <charconv>#include <utility>#include <cstdint>#include <cstdlib>#include <cstring>#include <compare>#include <vector>#include <string>#include <format>#include <atomic>#include <cctype>#include <tuple>#include <regex>#include <array>#include <bit>#include <map>#include <set>#include <google/protobuf/util/json_util.h>#include <google/protobuf/message_lite.h>#include <google/protobuf/descriptor.h>#include <boost/lexical_cast.hpp>#include <google/protobuf/map.h>Classes | |
| struct | ngl::tools::parm< T > |
| 参数包装器模板。 More... | |
Namespaces | |
| namespace | ngl::detail |
| 详细实现命名空间。 | |
| namespace | ngl::tools |
| 工具函数命名空间。 | |
Typedefs | |
| template<typename T> | |
| using | ngl::detail::remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>> |
| 移除cv限定符和引用的类型特征。 | |
Functions | |
| constexpr std::string_view | ngl::detail::ext_type (std::string_view asign, std::size_t aprefix, std::size_t asize, std::size_t aend=g_tn_npos) noexcept |
| 提取类型名称的辅助函数。 | |
| constexpr std::size_t | ngl::detail::find_tend (std::string_view asign, std::size_t abeg, std::string_view asuf) noexcept |
| 查找类型名称结束位置的辅助函数。 | |
| constexpr std::size_t | ngl::detail::find_tend (std::string_view asign, std::size_t abeg, char asuf) noexcept |
| 查找类型名称结束位置的辅助函数(单字符版本)。 | |
| constexpr std::size_t | ngl::detail::find_tend (std::string_view asign, std::size_t abeg, char asuf1, char asuf2) noexcept |
| 查找类型名称结束位置的辅助函数(双字符版本)。 | |
| template<typename T> | |
| constexpr std::string_view | ngl::detail::comp_type () noexcept |
| 获取编译期类型名称。 | |
| template<typename T> | |
| std::string_view | ngl::detail::to_sv (const T &avalue) |
| 将任意类型转换为字符串视图。 | |
| char | ngl::detail::first_non_space (std::string_view avalue) |
| 查找字符串中第一个非空白字符。 | |
| bool | ngl::detail::is_url_safe (unsigned char achar) |
| 判断字符是否为URL安全字符。 | |
| int | ngl::detail::hex_value (char achar) |
| 获取十六进制字符的数值。 | |
| bool | ngl::detail::keep_pct (unsigned char ahex) |
| 判断百分号编码字符是否需要保留。 | |
| bool | ngl::detail::parse_ip4 (std::string_view aip, std::array< int, 4 > &aoct) |
| 解析IPv4地址字符串。 | |
| template<typename TMAP, typename TKEY> | |
| auto | ngl::tools::findmap (TMAP &amap, const TKEY &akey) |
| 在映射中查找元素。 | |
| template<typename TMAP, typename TKEY> | |
| auto | ngl::tools::insertmap (TMAP &amap, const TKEY &akey, const typename TMAP::mapped_type &avalue) |
| 向映射中插入元素。 | |
| template<typename TMAP, typename TKEY> | |
| bool | ngl::tools::erasemap (TMAP &amap, const TKEY &akey, typename TMAP::mapped_type &adata) |
| 从映射中提取并移除元素。 | |
| template<typename T> | |
| bool | ngl::tools::proto2json (const T &adata, std::string &ajson) |
| 将Protobuf消息转换为JSON字符串。 | |
| template<typename T> | |
| void | ngl::tools::print_json (const T &adata, bool aislog=false) |
| 打印Protobuf消息的JSON表示。 | |
| template<typename T> | |
| bool | ngl::tools::json2proto (const std::string &ajson, T &adata) |
| 将JSON字符串转换为Protobuf消息。 | |
| template<typename T> | |
| bool | ngl::tools::json2custom (const std::string &ajson, T &adata) |
| 将JSON字符串转换为自定义类型。 | |
| template<typename T> | |
| bool | ngl::tools::custom2json (const T &adata, std::string &ajson) |
| 将自定义类型转换为JSON字符串。 | |
| template<typename TKEY, typename TVAL> | |
| void | ngl::tools::copy (const std::map< TKEY, TVAL > &asrc, google::protobuf::Map< TKEY, TVAL > &adst) |
| 将std::map复制到Protobuf Map。 | |
| template<typename TKEY, typename TVAL> | |
| void | ngl::tools::copy (const google::protobuf::Map< TKEY, TVAL > &asrc, std::map< TKEY, TVAL > &adst) |
| 将Protobuf Map复制到std::map。 | |
| void | ngl::tools::log_lex_err (const char *atotype, const char *afromtype, const char *aerror, const std::source_location &asource) |
| 记录lexical_cast类型转换失败的错误日志 | |
| template<typename To, typename From> | |
| To | ngl::tools::lexical_cast (const From &afrom, const std::source_location &asource=std::source_location::current()) |
| 类型安全的lexical_cast实现。 | |
| template<typename To, typename From> | |
| bool | ngl::tools::try_lexical_cast (const From &afrom, To &ato, const std::source_location &asource=std::source_location::current()) |
| 安全的lexical_cast实现,不抛出异常。 | |
Variables | |
| constexpr std::string_view | ngl::detail::g_hex_tab = "0123456789ABCDEF" |
| 十六进制字符表 | |
| constexpr std::size_t | ngl::detail::g_tn_npos = std::string_view::npos |
| 无效位置常量 | |
| template<typename T> | |
| constexpr bool | ngl::detail::is_char_ptr_v |
| 判断类型是否为字符指针。 | |
| template<typename T> | |
| constexpr bool | ngl::detail::is_char_arr_v |
| 判断类型是否为字符数组。 | |
| template<typename T> | |
| constexpr bool | ngl::detail::is_str_v |
| 判断类型是否为字符串类型。 | |
声明工具库中的共享辅助函数和模板。
本文件定义了工具库的核心功能,包括:
这些工具函数和模板是整个工具库的基础,被其他工具模块广泛使用。