7/include/naming_helper.hpp

51 lines
1.9 KiB
C++
Raw Normal View History

2026-06-09 02:34:04 +00:00
#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