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

负责二进制数据,字符串之间的转化 更多...

#include <sttnet.h>

静态 Public 成员函数

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 位为一个字节。 更多...
 

详细描述

负责二进制数据,字符串之间的转化

成员函数说明

static std::string& stt::data::BitUtil::bitOutput ( char  input,
std::string &  result 
)
static

将单个字符转换为其对应的 8 位二进制字符串。

参数
input输入的字符。
result用于保存输出的二进制字符串(例如 'A' -> "01000001")。
返回
返回 result 的引用。
static std::string& stt::data::BitUtil::bitOutput ( const std::string &  input,
std::string &  result 
)
static

将字符串中的每个字符依次转换为二进制位,并拼接为一个整体字符串。

参数
input输入字符串。
result保存输出的连续位字符串(长度为 input.size() * 8)。
返回
返回 result 的引用。
static char& stt::data::BitUtil::bitOutput_bit ( char  input,
const int  pos,
char &  result 
)
static

获取字符 input 的从左向右第 pos 位(二进制)并返回 '1' 或 '0'。

参数
input输入字符。
pos位位置(1~8,1 是最高位)。
result返回的位字符:'1' 或 '0'。
返回
返回 result 的引用。
static unsigned long& stt::data::BitUtil::bitStrToNumber ( const std::string &  input,
unsigned long &  result 
)
static

将 "01" 字符串(二进制字符串)转换为无符号整数。

参数
input输入二进制字符串(如 "1011")。
result输出结果数值。
返回
返回 result 的引用。
static unsigned long& stt::data::BitUtil::bitToNumber ( const std::string &  input,
unsigned long &  result 
)
static

将字符串转换为二进制,再转换为对应数值。

参数
input任意原始数据字符串。
result返回转换后的数值。
返回
返回 result 的引用。
注解
实际先调用 bitOutput 得到位串,再通过 bitStrToNumber 转换成整数。
static char& stt::data::BitUtil::toBit ( const std::string &  input,
char &  result 
)
static

将最多 8 位的 "01" 字符串压缩成 1 个字节(char)。

参数
input二进制字符串,最多 8 位。
result输出压缩后的字节。
返回
返回 result 的引用。
static std::string& stt::data::BitUtil::toBit ( const std::string &  input,
std::string &  result 
)
static

将任意长度的 "01" 字符串压缩为二进制数据,每 8 位为一个字节。

参数
input输入位串(长度应为 8 的倍数)。
result返回压缩后的二进制数据(每个字符代表 1 个字节)。
返回
返回 result 的引用。

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