负责二进制数据,字符串之间的转化
More...
#include <sttnet.h>
|
| static std::string & | bitOutput (char input, std::string &result) |
| | 将单个字符转换为其对应的 8 位二进制字符串。
|
| |
| static std::string & | bitOutput (const std::string &input, std::string &result) |
| | 将字符串中的每个字符依次转换为二进制位,并拼接为一个整体字符串。
|
| |
| static char & | bitOutput_bit (char input, const int pos, char &result) |
| | 获取字符 input 的从左向右第 pos 位(二进制)并返回 '1' 或 '0'。
|
| |
| static unsigned long & | bitStrToNumber (const std::string &input, unsigned long &result) |
| | 将 "01" 字符串(二进制字符串)转换为无符号整数。
|
| |
| static unsigned long & | bitToNumber (const std::string &input, unsigned long &result) |
| | 将字符串转换为二进制,再转换为对应数值。
|
| |
| static char & | toBit (const std::string &input, char &result) |
| | 将最多 8 位的 "01" 字符串压缩成 1 个字节(char)。
|
| |
| static std::string & | toBit (const std::string &input, std::string &result) |
| | 将任意长度的 "01" 字符串压缩为二进制数据,每 8 位为一个字节。
|
| |
◆ bitOutput() [1/2]
| static std::string & stt::data::BitUtil::bitOutput |
( |
char | input, |
|
|
std::string & | result ) |
|
static |
将单个字符转换为其对应的 8 位二进制字符串。
- Parameters
-
| input | 输入的字符。 |
| result | 用于保存输出的二进制字符串(例如 'A' -> "01000001")。 |
- Returns
- 返回 result 的引用。
◆ bitOutput() [2/2]
| static std::string & stt::data::BitUtil::bitOutput |
( |
const std::string & | input, |
|
|
std::string & | result ) |
|
static |
将字符串中的每个字符依次转换为二进制位,并拼接为一个整体字符串。
- Parameters
-
| input | 输入字符串。 |
| result | 保存输出的连续位字符串(长度为 input.size() * 8)。 |
- Returns
- 返回 result 的引用。
◆ bitOutput_bit()
| static char & stt::data::BitUtil::bitOutput_bit |
( |
char | input, |
|
|
const int | pos, |
|
|
char & | result ) |
|
static |
获取字符 input 的从左向右第 pos 位(二进制)并返回 '1' 或 '0'。
- Parameters
-
| input | 输入字符。 |
| pos | 位位置(1~8,1 是最高位)。 |
| result | 返回的位字符:'1' 或 '0'。 |
- Returns
- 返回 result 的引用。
◆ bitStrToNumber()
| static unsigned long & stt::data::BitUtil::bitStrToNumber |
( |
const std::string & | input, |
|
|
unsigned long & | result ) |
|
static |
将 "01" 字符串(二进制字符串)转换为无符号整数。
- Parameters
-
| input | 输入二进制字符串(如 "1011")。 |
| result | 输出结果数值。 |
- Returns
- 返回 result 的引用。
◆ bitToNumber()
| static unsigned long & stt::data::BitUtil::bitToNumber |
( |
const std::string & | input, |
|
|
unsigned long & | result ) |
|
static |
将字符串转换为二进制,再转换为对应数值。
- Parameters
-
| input | 任意原始数据字符串。 |
| result | 返回转换后的数值。 |
- Returns
- 返回 result 的引用。
- Note
- 实际先调用 bitOutput 得到位串,再通过 bitStrToNumber 转换成整数。
◆ toBit() [1/2]
| static char & stt::data::BitUtil::toBit |
( |
const std::string & | input, |
|
|
char & | result ) |
|
static |
将最多 8 位的 "01" 字符串压缩成 1 个字节(char)。
- Parameters
-
| input | 二进制字符串,最多 8 位。 |
| result | 输出压缩后的字节。 |
- Returns
- 返回 result 的引用。
◆ toBit() [2/2]
| static std::string & stt::data::BitUtil::toBit |
( |
const std::string & | input, |
|
|
std::string & | result ) |
|
static |
将任意长度的 "01" 字符串压缩为二进制数据,每 8 位为一个字节。
- Parameters
-
| input | 输入位串(长度应为 8 的倍数)。 |
| result | 返回压缩后的二进制数据(每个字符代表 1 个字节)。 |
- Returns
- 返回 result 的引用。
The documentation for this class was generated from the following file: