STTNet
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 宏定义 
静态 Public 成员函数 | 所有成员列表
stt::data::NumberStringConvertUtil类 参考

负责字符串和数字的转化 更多...

#include <sttnet.h>

静态 Public 成员函数

static int & toInt (const std::string_view &ori_str, int &result, const int &i=-1)
 string转化为int类型 更多...
 
static int & str16toInt (const std::string_view &ori_str, int &result, const int &i=-1)
 16进制数字的字符串表示转化为10进制int类型数字 更多...
 
static long & toLong (const std::string_view &ori_str, long &result, const long &i=-1)
 string转化为long类型 更多...
 
static float & toFloat (const std::string &ori_str, float &result, const float &i=-1)
 string转化为float类型 更多...
 
static double & toDouble (const std::string &ori_str, double &result, const double &i=-1)
 string转化为double类型 更多...
 
static bool & toBool (const std::string_view &ori_str, bool &result)
 string转化为bool类型 更多...
 
static std::string & strto16 (const std::string &ori_str, std::string &result)
 将普通字符串转化为对应的十六进制表示字符串(hex string)。 更多...
 

详细描述

负责字符串和数字的转化

成员函数说明

static int& stt::data::NumberStringConvertUtil::str16toInt ( const std::string_view &  ori_str,
int &  result,
const int &  i = -1 
)
static

16进制数字的字符串表示转化为10进制int类型数字

参数
ori_str16进制数字的字符串表示
result保存转化结果的int容器
返回
返回result的引用
static std::string& stt::data::NumberStringConvertUtil::strto16 ( const std::string &  ori_str,
std::string &  result 
)
static

将普通字符串转化为对应的十六进制表示字符串(hex string)。

例如输入 "ABC" 会被转化为 "414243",每个字符转换为其 ASCII 的十六进制形式。

参数
ori_str输入的原始字符串(可以包含任意字符,包括不可见字符)。
result存放转换后结果的字符串引用。
返回
转换后的十六进制字符串 result 的引用。
Bug:
有bug待修复
static bool& stt::data::NumberStringConvertUtil::toBool ( const std::string_view &  ori_str,
bool &  result 
)
static

string转化为bool类型

注解
不会抛出异常,true或者True,TRUE返回true,否则返回false
参数
ori_str原始string类型数据
result存放结果的bool容器
返回
result的引用
static double& stt::data::NumberStringConvertUtil::toDouble ( const std::string &  ori_str,
double &  result,
const double &  i = -1 
)
static

string转化为double类型

注解
不会抛出异常
参数
ori_str原始string类型数据
result存放结果的double容器
i如果转化失败 则把result赋值为i(默认为-1)
返回
result的引用
static float& stt::data::NumberStringConvertUtil::toFloat ( const std::string &  ori_str,
float &  result,
const float &  i = -1 
)
static

string转化为float类型

注解
不会抛出异常
参数
ori_str原始string类型数据
result存放结果的float容器
i如果转化失败 则把result赋值为i(默认为-1)
返回
result的引用
static int& stt::data::NumberStringConvertUtil::toInt ( const std::string_view &  ori_str,
int &  result,
const int &  i = -1 
)
static

string转化为int类型

注解
不会抛出异常
参数
ori_str原始string类型数据
result存放结果的int容器
i如果转化失败 则把result赋值为i(默认为-1)
返回
result的引用
static long& stt::data::NumberStringConvertUtil::toLong ( const std::string_view &  ori_str,
long &  result,
const long &  i = -1 
)
static

string转化为long类型

注解
不会抛出异常
参数
ori_str原始string类型数据
result存放结果的long容器
i如果转化失败 则把result赋值为i(默认为-1)
返回
result的引用

该类的文档由以下文件生成: