|
|
@ -21,24 +21,24 @@ class StringUtil { |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 替换字符串中的字符,如果new_value="",则删除旧字符 |
|
|
|
* |
|
|
|
* @param str |
|
|
|
* @param old_value |
|
|
|
* @param new_value |
|
|
|
* @return string& |
|
|
|
* |
|
|
|
* @param str |
|
|
|
* @param old_value |
|
|
|
* @param new_value |
|
|
|
* @return string& |
|
|
|
*/ |
|
|
|
string& replaceAllDistinct(string& str, const string& old_value, const string& new_value); |
|
|
|
/**
|
|
|
|
* @brief 转换HEX字符串成Bytes数组例如 |
|
|
|
* |
|
|
|
* |
|
|
|
* // string("12,0a,2a,ab") ===> char buf[] = {0x12,0x0a,0x2a,0xab}
|
|
|
|
* vector<uint8_t> tobytes; |
|
|
|
* hexStringToBytes("12,0a,2a,ab",",",tobytes); |
|
|
|
* |
|
|
|
* |
|
|
|
* // string("120a2aab") ===> char buf[] = {0x12,0x0a,0x2a,0xab}
|
|
|
|
* vector<uint8_t> tobytes; |
|
|
|
* hexStringToBytes("120a2aab","",tobytes); |
|
|
|
* |
|
|
|
* |
|
|
|
* @param in 输入字符串 |
|
|
|
* @param delims 分割符 |
|
|
|
* @param byteTable 输出的byte数组 |
|
|
@ -46,6 +46,21 @@ class StringUtil { |
|
|
|
* @return false 转换失败 |
|
|
|
*/ |
|
|
|
bool hexStringToBytes(string in, string delims, vector<uint8_t>& byteTable); |
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief |
|
|
|
* |
|
|
|
* @param value 0x55 |
|
|
|
* @param bitCount 8 |
|
|
|
* @param remoteZero true/false |
|
|
|
* @return string 01010101 |
|
|
|
* |
|
|
|
* Demo: |
|
|
|
* StringUtil::bytet2Binary(0x55,8,true) ===> 1010101 |
|
|
|
* StringUtil::bytet2Binary(0x55,8,false) ===> 01010101 |
|
|
|
* |
|
|
|
*/ |
|
|
|
string bytet2Binary(uint32_t value, int bitCount, bool remoteZero = true); |
|
|
|
}; |
|
|
|
|
|
|
|
} // namespace core
|
|
|
|