tpString类
Utils
2025-07-05
基础信息
头文件: | include <tpString.h> |
---|---|
Cmake: | None |
发布版本: | V0.1.0 |
继承类: | |
派生类: |
Public 成员函数
tpString() | ||
---|---|---|
tpString(const char &ch) | ||
tpString(const char *value) | ||
tpString(const std::string &value) | ||
tpString tpString::operator= | operator=(const std::string &_others) | |
tpString tpString::operator= | operator=(const char *_others) | |
operator==(const tpString &_others) const | ||
tpList< tpString > tpString::split | split(const char &_ch) const | 指定字符分割字符串 |
tpString tpString::simplified | simplified() const | 去除首尾空格,中间空格只保留一个 |
tpString tpString::replace | replace(const tpString &from, const tpString &to) const | 指定字符串替换 |
tpString tpString::replace | replace(const tpRegex ®ex, const tpString &to) const | 使用正则表达式进行字符串替换 |
tpString tpString::replace | replace(uint64_t pos, uint64_t len, const tpString &str) | |
contains(const tpString &find) const | 是否包含某个字符串 | |
tpString tpString::mid | mid(const uint32_t &_pos, const int32_t &_count=-1) const | 切割字符串 |
remove(const uint32_t &_pos, const uint32_t &_count=1) | 指定索引移除字符 | |
toShort(int32_t base=10) const | 字符串转整数 | |
toInt(int32_t base=10) const | 字符串转整数 | |
toDouble() const | ||
insert(const uint32_t &pos, const tpString &str) | 指定索引插入指定字符或字符串 | |
append(const tpString &str) | 末尾追加字符串 | |
tpString tpString::left | left(const uint32_t &_length) | 从字符串起始位置,切割指定长度字符 |
tpString tpString::right | right(const uint32_t &_length) | 从字符串终止位置,切割指定长度字符 |
startsWith(const tpString &prefix) const | 判断字符串是否以指定字符串开头 | |
endsWith(const tpString &suffix) const | 检查字符串是否以指定后缀结尾 | |
logicalLength() const | 获取字符串的逻辑长度(中英文字符各算一个) | |
logicalPosToBytePos(uint32_t logicalPos) const | 根据逻辑位置获取对应的字节位置 | |
nextCharBytePos(uint32_t currentBytePos) const | 获取下一个字符的字节位置 | |
prevCharBytePos(uint32_t currentBytePos) const | 获取前一个字符的字节位置 | |
static tpString tpString::number | number(const int32_t &num) | 将数字转换为字符串 |
static tpString tpString::number | number(const uint32_t &num) | |
static tpString tpString::number | number(const uint64_t &num) | |
static tpString tpString::number | number(const double &num, const uint32_t &precision=2) |
成员函数说明
tpString::tpString()
暂无注释...
tpString::tpString(const char &ch)
暂无注释...
tpString::tpString(const char *value)
暂无注释...
tpString::tpString(const std::string &value)
暂无注释...
tpString tpString::operator=(const std::string &_others)
暂无注释...
tpString tpString::operator=(const char *_others)
暂无注释...
bool tpString::operator==(const tpString &_others) const
暂无注释...
tpList< tpString > tpString::split(const char &_ch) const
点击查看...
指定字符分割字符串
返回值:
返回分割后的字符串列表
tpString tpString::simplified() const
点击查看...
去除首尾空格,中间空格只保留一个
返回值:
返回处理后的字符串
tpString tpString::replace(const tpString &from, const tpString &to) const
点击查看...
指定字符串替换
返回值:
返回替换后的结果
tpString tpString::replace(const tpRegex ®ex, const tpString &to) const
点击查看...
使用正则表达式进行字符串替换
返回值:
返回替换后的结果
tpString tpString::replace(uint64_t pos, uint64_t len, const tpString &str)
暂无注释...
bool tpString::contains(const tpString &find) const
点击查看...
是否包含某个字符串
返回值:
当前字符串包含find返回true,否则返回false
tpString tpString::mid(const uint32_t &_pos, const int32_t &_count=-1) const
点击查看...
切割字符串
返回值:
切割后字符串
void tpString::remove(const uint32_t &_pos, const uint32_t &_count=1)
点击查看...
指定索引移除字符
int16_t tpString::toShort(int32_t base=10) const
点击查看...
字符串转整数
返回值:
转换结果
int32_t tpString::toInt(int32_t base=10) const
点击查看...
字符串转整数
返回值:
转换结果
double tpString::toDouble() const
暂无注释...
void tpString::insert(const uint32_t &pos, const tpString &str)
点击查看...
指定索引插入指定字符或字符串
void tpString::append(const tpString &str)
点击查看...
末尾追加字符串
tpString tpString::left(const uint32_t &_length)
点击查看...
从字符串起始位置,切割指定长度字符
返回值:
切割后字符串
tpString tpString::right(const uint32_t &_length)
点击查看...
从字符串终止位置,切割指定长度字符
返回值:
切割后字符串
bool tpString::startsWith(const tpString &prefix) const
点击查看...
判断字符串是否以指定字符串开头
返回值:
查询结果
bool tpString::endsWith(const tpString &suffix) const
点击查看...
检查字符串是否以指定后缀结尾
返回值:
查询结果
uint32_t tpString::logicalLength() const
点击查看...
获取字符串的逻辑长度(中英文字符各算一个)
uint32_t tpString::logicalPosToBytePos(uint32_t logicalPos) const
点击查看...
根据逻辑位置获取对应的字节位置
uint32_t tpString::nextCharBytePos(uint32_t currentBytePos) const
点击查看...
获取下一个字符的字节位置
uint32_t tpString::prevCharBytePos(uint32_t currentBytePos) const
点击查看...
获取前一个字符的字节位置
static tpString tpString::number(const int32_t &num)
点击查看...
将数字转换为字符串
返回值:
返回转换后的字符串