负责字符串和数字的转化
More...
#include <sttnet.h>
|
| 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类型数字
- Parameters
-
| ori_str | 16进制数字的字符串表示 |
| result | 保存转化结果的int容器 |
| i | 转换失败时写入 result 的默认值(默认为 -1)。 |
- Returns
- 返回result的引用
◆ strto16()
| static std::string & stt::data::NumberStringConvertUtil::strto16 |
( |
const std::string & | ori_str, |
|
|
std::string & | result ) |
|
static |
将普通字符串转化为对应的十六进制表示字符串(hex string)。
例如输入 "ABC" 会被转化为 "414243",每个字符转换为其 ASCII 的十六进制形式。
- Parameters
-
| ori_str | 输入的原始字符串(可以包含任意字符,包括不可见字符)。 |
| result | 存放转换后结果的字符串引用。 |
- Returns
- 转换后的十六进制字符串 result 的引用。
- Note
- Produces lowercase hexadecimal per byte; the input may contain invisible and high-bit bytes.
◆ toBool()
| static bool & stt::data::NumberStringConvertUtil::toBool |
( |
const std::string_view & | ori_str, |
|
|
bool & | result ) |
|
static |
string转化为bool类型
- Note
- 不会抛出异常,true或者True,TRUE返回true,否则返回false
- Parameters
-
| ori_str | 原始string类型数据 |
| result | 存放结果的bool容器 |
- Returns
- result的引用
◆ toDouble()
| static double & stt::data::NumberStringConvertUtil::toDouble |
( |
const std::string & | ori_str, |
|
|
double & | result, |
|
|
const double & | i = -1 ) |
|
static |
string转化为double类型
- Note
- 不会抛出异常
- Parameters
-
| ori_str | 原始string类型数据 |
| result | 存放结果的double容器 |
| i | 如果转化失败 则把result赋值为i(默认为-1) |
- Returns
- result的引用
◆ toFloat()
| static float & stt::data::NumberStringConvertUtil::toFloat |
( |
const std::string & | ori_str, |
|
|
float & | result, |
|
|
const float & | i = -1 ) |
|
static |
string转化为float类型
- Note
- 不会抛出异常
- Parameters
-
| ori_str | 原始string类型数据 |
| result | 存放结果的float容器 |
| i | 如果转化失败 则把result赋值为i(默认为-1) |
- Returns
- result的引用
◆ toInt()
| static int & stt::data::NumberStringConvertUtil::toInt |
( |
const std::string_view & | ori_str, |
|
|
int & | result, |
|
|
const int & | i = -1 ) |
|
static |
string转化为int类型
- Note
- 不会抛出异常
- Parameters
-
| ori_str | 原始string类型数据 |
| result | 存放结果的int容器 |
| i | 如果转化失败,则把 result 赋值为 i(默认为 -1)。 |
- Returns
- result的引用
◆ toLong()
| static long & stt::data::NumberStringConvertUtil::toLong |
( |
const std::string_view & | ori_str, |
|
|
long & | result, |
|
|
const long & | i = -1 ) |
|
static |
string转化为long类型
- Note
- 不会抛出异常
- Parameters
-
| ori_str | 原始string类型数据 |
| result | 存放结果的long容器 |
| i | 如果转化失败 则把result赋值为i(默认为-1) |
- Returns
- result的引用
The documentation for this class was generated from the following file: