⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 set_t.cpp

📁 MySql++ wrapper
💻 CPP
字号:
/*set_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 "set_t.h"set_t::set_t(std::map<std::string, uint64_t>& ref) : m_mmap(ref), m_value(0){}void set_t::operator=(const std::string& str){  size_t x = 0;  size_t i;  m_value = 0;  for (i = 0; i < str.size(); i++)  {    if (str[i] == ',')    {      m_value |= m_mmap[str.substr(x,i - x)];      x = i + 1;    }  }  m_value |= m_mmap[str.substr(x,i - x)];}void set_t::operator=(uint64_t s){  m_value = s;}void set_t::operator|=(uint64_t s){  m_value |= s;}void set_t::operator&=(uint64_t s){  m_value &= s;}const std::string& set_t::String(){  std::string str;  for (std::map<std::string, uint64_t>::iterator it = m_mmap.begin(); it != m_mmap.end(); it++)  {    std::string tmp = (*it).first;    uint64_t bit = (*it).second;    if (m_value & bit)    {      if (str.size())        str += ",";      str += tmp;    }  }  m_strvalue = str;  return m_strvalue;}uint64_t set_t::Value(){  return m_value;}bool set_t::in_set(const std::string& str){  if (m_value & m_mmap[str])    return true;  return false;}const char *set_t::c_str(){  return String().c_str();}void set_t::operator+=(const std::string& str){  size_t x = 0;  size_t i;  for (i = 0; i < str.size(); i++)  {    if (str[i] == ',')    {      m_value |= m_mmap[str.substr(x,i - x)];      x = i + 1;    }  }  m_value |= m_mmap[str.substr(x,i - x)];}void set_t::operator-=(const std::string& str){  size_t x = 0;  size_t i;  for (i = 0; i < str.size(); i++)  {    if (str[i] == ',')    {      m_value &= ~m_mmap[str.substr(x,i - x)];      x = i + 1;    }  }  m_value &= ~m_mmap[str.substr(x,i - x)];}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -