51 lines
1.9 KiB
C++
51 lines
1.9 KiB
C++
#ifndef ODF_MANAGEMENT_NAMING_HELPER_HPP
|
||
#define ODF_MANAGEMENT_NAMING_HELPER_HPP
|
||
|
||
#include <string>
|
||
#include <optional>
|
||
|
||
/**
|
||
* @brief 命名规则辅助工具
|
||
*
|
||
* 提供 ODF 单元编号的生成与校验功能。
|
||
* 格式:区域代码-楼层号-机房编号-设备类型-端口容量-序列号-扩展标识
|
||
* 示例:DC01-F03-TX-ODP-LC24-001-A
|
||
*/
|
||
class NamingHelper {
|
||
public:
|
||
/**
|
||
* @brief 校验 ODF 编号是否符合命名规则
|
||
* @param code 待校验的编号字符串
|
||
* @return 符合规则返回包含解析后的各部分信息,否则返回 std::nullopt
|
||
*/
|
||
[[nodiscard]] static std::optional<std::string> validateFormat(const std::string& code);
|
||
|
||
/**
|
||
* @brief 生成 ODF 单元编号
|
||
* @param areaCode 区域代码,如 "DC01"
|
||
* @param floor 楼层号,如 "F03"
|
||
* @param room 机房编号,如 "TX"
|
||
* @param deviceType 设备类型,如 "ODP"
|
||
* @param portDesc 端口容量描述,如 "LC24"
|
||
* @param serial 序列号,如 "001"
|
||
* @param extension 扩展标识(可选),如 "A"
|
||
* @return 完整编号字符串
|
||
*/
|
||
[[nodiscard]] static std::string generate(const std::string& areaCode,
|
||
const std::string& floor,
|
||
const std::string& room,
|
||
const std::string& deviceType,
|
||
const std::string& portDesc,
|
||
const std::string& serial,
|
||
const std::string& extension = "");
|
||
|
||
/// @brief 命名规则的正则表达式模式
|
||
static constexpr const char* PATTERN =
|
||
"^[A-Z0-9]{2,6}-[A-Z]\\d{2}-[A-Z0-9]{2,6}-[A-Z]{2,6}-[A-Z]{2}\\d{2,4}-\\d{3}(-[A-Z0-9]+)?$";
|
||
|
||
private:
|
||
NamingHelper() = delete;
|
||
};
|
||
|
||
#endif // ODF_MANAGEMENT_NAMING_HELPER_HPP
|