STTNet 0.7.0
载入中...
搜索中...
未找到
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)。
 

详细描述

负责字符串和数字的转化

成员函数说明

◆ str16toInt()

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容器
i转换失败时写入 result 的默认值(默认为 -1)。
返回
返回result的引用

◆ strto16()

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 的引用。
说明
按字节输出小写十六进制;输入可以包含不可见字符和高位字节。

◆ toBool()

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的引用

◆ toDouble()

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的引用

◆ toFloat()

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的引用

◆ toInt()

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的引用

◆ toLong()

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的引用

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