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

字符串拆分与拼接工具。 More...

Namespaces

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

Functions

template<typename T>
bool ngl::tools::splite (const char *abuff, const char *afg, std::vector< T > &avec)
template<typename T>
bool ngl::tools::splite (const char *abuff, const char *afg, std::set< T > &aset)
bool ngl::tools::splite (const char *abuff, const char *afg, std::vector< std::string > &avec)
 按分隔符拆分C字符串到vector
template<typename T>
bool ngl::tools::splite (int32_t aindex, const std::vector< std::string > &avec, T &adata)
template<typename T>
bool ngl::tools::splite (int32_t aindex, const std::vector< std::string > &avec, std::vector< T > &adata)
bool ngl::tools::splite (int32_t aindex, const std::vector< std::string > &avec, std::vector< std::string > &adata)
 从指定索引开始提取子vector
template<std::size_t... INDEX, typename TTUPLE>
bool ngl::tools::splite_tuple (std::index_sequence< INDEX... >, const std::vector< std::string > &avec, TTUPLE &atup)
template<std::size_t... INDEX, typename... ARGS>
bool ngl::tools::splite (std::index_sequence< INDEX... >, const char *abuff, const char *afg, ARGS &... aargs)
template<typename... ARGS>
bool ngl::tools::splite (const char *abuff, const char *afg, ARGS &... aargs)
template<typename TFIRST = std::string, typename TSECOND = std::string>
bool ngl::tools::splite_special (const char *astr, const char *akey1, const char *akey2, std::vector< std::pair< TFIRST, TSECOND > > &avec)
template<typename TFIRST = std::string, typename TSECOND = std::string>
bool ngl::tools::splite_special (const char *astr, const char *akey1, const char *akey2, std::map< TFIRST, TSECOND > &amap)
template<typename T>
bool ngl::tools::splicing (const std::vector< T > &avec, const char *afg, std::string &astr, const std::function< std::string(const T &)> &afun=m_splicing< T >)
bool ngl::tools::splicing (const std::vector< std::string > &avec, const char *afg, std::string &astr, int32_t apos)
 将vector中的字符串用分隔符拼接
template<typename T>
bool ngl::tools::splicing (const std::set< T > &avec, const char *afg, std::string &astr, const std::function< std::string(const T &)> &afun=m_splicing< T >)
template<typename TKEY, typename TVAL>
bool ngl::tools::splicing (const std::map< TKEY, TVAL > &amap, const char *afg, std::string &astr, const std::function< std::string(const TKEY &, const TVAL &)> &afun=m_splicingmap< TKEY, TVAL >)
template<typename TKEY, typename TVAL>
bool ngl::tools::splicing (const google::protobuf::Map< TKEY, TVAL > &amap, const char *afg, std::string &astr, const std::function< std::string(const TKEY &, const TVAL &)> &afun=m_splicingmap< TKEY, TVAL >)
bool ngl::tools::splicing (const std::set< std::string > &aset, const char *afg, std::string &astr)
 将set中的字符串用分隔符拼接
template<typename T>
bool ngl::tools::splicing (int32_t aindex, const char *afg, std::string &astr, T &adata)
template<std::size_t... INDEX, typename... ARGS>
bool ngl::tools::splicing (std::index_sequence< INDEX... >, const char *afg, std::string &astr, ARGS &... aargs)
template<typename... ARGS>
bool ngl::tools::splicing (const char *afg, std::string &astr, ARGS &... aargs)

Variables

template<typename T>
std::function< std::string(const T &)> ngl::tools::m_splicing
template<typename TKEY, typename TVAL>
std::function< std::string(const TKEY &, const TVAL &)> ngl::tools::m_splicingmap

Detailed Description

字符串拆分与拼接工具。

提供字符串按分隔符拆分和按分隔符拼接的功能,支持:

  • 基础字符串拆分(vector/set/map输出)
  • 类型安全的数值拆分(自动lexical_cast转换)
  • 可变参数模板拆分(一次拆分多个值)
  • 元组拆分(编译期索引序列展开)
  • 容器拼接(vector/set/map到字符串)
  • 特殊键值对拆分(支持多级分隔符)