📄 enum_t.cpp
字号:
/*enum_t.cppCopyright (C) 2004 Anders HedstromThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/#ifdef _WIN32#pragma warning(disable:4786)#endif#include "enum_t.h"enum_t::enum_t(std::map<std::string, uint64_t>& ref) : m_mmap(ref), m_value(0){ for (std::map<std::string, uint64_t>::iterator it = ref.begin(); it != ref.end(); it++) { std::string str = (*it).first; uint64_t value = (*it).second; m_vmap[value] = str; }}void enum_t::operator=(const std::string& str){ m_value = m_mmap[str];}void enum_t::operator=(unsigned short s){ m_value = s;}const std::string& enum_t::String(){ if (m_vmap.size() != m_mmap.size()) { for (std::map<std::string, uint64_t>::iterator it = m_mmap.begin(); it != m_mmap.end(); it++) { std::string str = (*it).first; uint64_t value = (*it).second; m_vmap[value] = str; } } return m_vmap[m_value];}unsigned short enum_t::Value(){ return m_value;}bool enum_t::operator==(const std::string& str){ if (!strcasecmp(c_str(), str.c_str())) return true; return false;}bool enum_t::operator==(unsigned short s){ return m_value == s;}const char *enum_t::c_str(){ return String().c_str();}bool enum_t::operator!=(const std::string& str){ if (!strcasecmp(c_str(), str.c_str())) return !true; return !false;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -