TpUuid 类
V0.2.1TpUtils
2025-11-14
介绍
UUID (Universally Unique Identifier) 生成和表示类
该类提供了多种版本 UUID 的生成方法(包括 V1 和 V4),
基础信息
| 头文件: | include <TpUuid.h> |
|---|---|
| Cmake: | None |
| 发布版本: | V0.2.1 |
| 继承类: | |
| 派生类: |
Public 成员函数
| TpUuid() | 默认构造函数 | |
|---|---|---|
| TpUuid(const TpUuid &other) | 拷贝构造函数 | |
| ~TpUuid() | 析构函数 | |
| TpUuid & TpUuid::operator= | operator=(const TpUuid &other) | 赋值运算符重载 |
| TpString | toString() | 将 UUID 转换为标准格式字符串 |
| TpString | toBase62() | 将 UUID 转换为 Base62 编码字符串 |
| TpString | toPretty() | 将 UUID 转换为更易读的格式化字符串 |
| static TpUuid TpUuid::createUuid | createUuid() | 创建 UUID(默认版本) |
| static TpUuid TpUuid::createUuidV1 | createUuidV1() | 创建基于时间和主机ID的 UUID (版本1) |
| static TpUuid TpUuid::createUuidV4 | createUuidV4() | 创建基于随机数的 UUID (版本4) |
| static TpUuid TpUuid::fromString | fromString(const TpString &text) | 从字符串解析生成 UUID 对象 |
成员函数说明
TpUuid::TpUuid()
默认构造函数...
默认构造函数
初始化一个空的 UUID。
TpUuid::TpUuid(const TpUuid &other)
拷贝构造函数...
拷贝构造函数
TpUuid::~TpUuid()
析构函数...
析构函数
TpUuid & TpUuid::operator=(const TpUuid &other)
赋值运算符重载...
赋值运算符重载
通过深拷贝另一个 对象来赋值给当前对象。
参数:other: 赋值操作的源 对象
返回值:& 返回当前对象的引用,支持链式赋值
TpString TpUuid::toString()
将 UUID 转换为标准格式字符串...
将 UUID 转换为标准格式字符串
返回值:代表 UUID 的字符串,格式为 "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
TpString TpUuid::toBase62()
将 UUID 转换为 Base62 编码字符串...
将 UUID 转换为 Base62 编码字符串
返回值:Base62 编码的字符串表示
TpString TpUuid::toPretty()
将 UUID 转换为更易读的格式化字符串...
将 UUID 转换为更易读的格式化字符串
返回值:美化后的字符串表示
static TpUuid TpUuid::createUuid()
创建 UUID(默认版本)...
创建 UUID(默认版本)
返回值:新生成的 UUID 对象
static TpUuid TpUuid::createUuidV1()
创建基于时间和主机ID的 UUID (版本1)...
创建基于时间和主机ID的 UUID (版本1)
返回值:新生成的 UUID 对象
static TpUuid TpUuid::createUuidV4()
创建基于随机数的 UUID (版本4)...
创建基于随机数的 UUID (版本4)
返回值:新生成的 UUID 对象
static TpUuid TpUuid::fromString(const TpString &text)
从字符串解析生成 UUID 对象...
从字符串解析生成 UUID 对象
参数:text: 符合 UUID 格式的字符串
返回值:解析后生成的 UUID 对象
