Files
HIS-GUI/include/utils/uuid.h
2026-04-05 20:11:43 +08:00

42 lines
896 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef UUID_H
#define UUID_H
#include <string>
/**
* UUID工具类
* 用于生成符合RFC 4122标准的UUID v4
*/
class UUID {
public:
/**
* 生成一个新的UUID字符串
* 格式: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
* 例如: 550e8400-e29b-41d4-a716-446655440000
*/
static std::string generate();
/**
* 生成一个简短的UUID无连字符
* 格式: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*/
static std::string generateShort();
/**
* 检查UUID格式是否有效
*/
static bool isValid(const std::string& uuid);
/**
* 将标准UUID转换为简短的UUID移除连字符
*/
static std::string toShort(const std::string& uuid);
/**
* 将简短UUID转换为标准UUID添加连字符
*/
static std::string fromShort(const std::string& shortUuid);
};
#endif // UUID_H