Browse Source

add zenum

master
zhaohe 8 months ago
parent
commit
cc5597a959
  1. 31
      bean/zenum.hpp

31
bean/zenum.hpp

@ -0,0 +1,31 @@
#pragma once
#include <stdint.h>
#include <string.h>
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
Loading…
Cancel
Save