From cc5597a95943486264bea7f036a06790e0bbcdf3 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 25 Nov 2024 20:11:54 +0800 Subject: [PATCH] add zenum --- bean/zenum.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 bean/zenum.hpp diff --git a/bean/zenum.hpp b/bean/zenum.hpp new file mode 100644 index 0000000..53421ac --- /dev/null +++ b/bean/zenum.hpp @@ -0,0 +1,31 @@ +#pragma once +#include +#include + +namespace iflytop { +class ZEnum { + public: + int val; + char const* name; + char const* chName; + + ZEnum(int val, const char* name, const char* chName) : val(val), name(name), chName(chName) {} + + bool isEq(int val) { return this->val == val; } + bool isEq(ZEnum* role) { return this->val == role->val; } + bool isEqByChName(const char* chName) { return strcmp(this->chName, chName) == 0; } + + ZEnum(const ZEnum& other) : val(other.val), name(other.name), chName(other.chName) {} + + // :operator= + ZEnum& operator=(const ZEnum& other) { + if (this != &other) { + val = other.val; + name = other.name; + chName = other.chName; + } + return *this; + } +}; + +} // namespace iflytop