Forums  +  C++ and Sockets  +  C++ and SQL: MySQL, sqlite, ODBC  +  Miscellaneous Projects
Logo
~Database~
~ C++ ~
~Contact~

set_t Class Reference

Implements MySQL SET datatype. More...

#include <set_t.h>

Collaboration diagram for set_t:

Collaboration graph
List of all members.

Public Member Functions

 set_t (std::map< std::string, uint64_t > &)
const std::string & String ()
uint64_t Value ()
const char * c_str ()
bool in_set (const std::string &)
void operator= (const std::string &)
void operator= (uint64_t)
void operator|= (uint64_t)
void operator &= (uint64_t)
void operator+= (const std::string &)
void operator-= (const std::string &)

Private Attributes

std::map< std::string, uint64_t > & m_mmap
uint64_t m_value
std::string m_strvalue

Detailed Description

Implements MySQL SET datatype.

Definition at line 47 of file set_t.h.


Constructor & Destructor Documentation

set_t::set_t ( std::map< std::string, uint64_t > &   ) 

Definition at line 40 of file set_t.cpp.

00040                                              : m_mmap(ref), m_value(0)
00041 {
00042 }


Member Function Documentation

const std::string & set_t::String (  ) 

Definition at line 80 of file set_t.cpp.

References m_mmap, m_strvalue, and m_value.

Referenced by c_str().

00081 {
00082         std::string str;
00083         for (std::map<std::string, uint64_t>::iterator it = m_mmap.begin(); it != m_mmap.end(); it++)
00084         {
00085                 std::string tmp = (*it).first;
00086                 uint64_t bit = (*it).second;
00087                 if (m_value & bit)
00088                 {
00089                         if (str.size())
00090                                 str += ",";
00091                         str += tmp;
00092                 }
00093         }
00094         m_strvalue = str;
00095         return m_strvalue;
00096 }

uint64_t set_t::Value (  ) 

Definition at line 99 of file set_t.cpp.

References m_value.

00100 {
00101         return m_value;
00102 }

const char * set_t::c_str (  ) 

Definition at line 113 of file set_t.cpp.

References String().

00114 {
00115         return String().c_str();
00116 }

bool set_t::in_set ( const std::string &   ) 

Definition at line 105 of file set_t.cpp.

References m_mmap, and m_value.

00106 {
00107         if (m_value & m_mmap[str])
00108                 return true;
00109         return false;
00110 }

void set_t::operator= ( const std::string &   ) 

Definition at line 45 of file set_t.cpp.

References m_mmap, and m_value.

00046 {
00047         size_t x = 0;
00048         size_t i;
00049         m_value = 0;
00050         for (i = 0; i < str.size(); i++)
00051         {
00052                 if (str[i] == ',')
00053                 {
00054                         m_value |= m_mmap[str.substr(x,i - x)];
00055                         x = i + 1;
00056                 }
00057         }
00058         m_value |= m_mmap[str.substr(x,i - x)];
00059 }

void set_t::operator= ( uint64_t   ) 

Definition at line 62 of file set_t.cpp.

References m_value.

00063 {
00064         m_value = s;
00065 }

void set_t::operator|= ( uint64_t   ) 

Definition at line 68 of file set_t.cpp.

References m_value.

00069 {
00070         m_value |= s;
00071 }

void set_t::operator &= ( uint64_t   ) 

Definition at line 74 of file set_t.cpp.

References m_value.

00075 {
00076         m_value &= s;
00077 }

void set_t::operator+= ( const std::string &   ) 

Definition at line 119 of file set_t.cpp.

References m_mmap, and m_value.

00120 {
00121         size_t x = 0;
00122         size_t i;
00123         for (i = 0; i < str.size(); i++)
00124         {
00125                 if (str[i] == ',')
00126                 {
00127                         m_value |= m_mmap[str.substr(x,i - x)];
00128                         x = i + 1;
00129                 }
00130         }
00131         m_value |= m_mmap[str.substr(x,i - x)];
00132 }

void set_t::operator-= ( const std::string &   ) 

Definition at line 135 of file set_t.cpp.

References m_mmap, and m_value.

00136 {
00137         size_t x = 0;
00138         size_t i;
00139         for (i = 0; i < str.size(); i++)
00140         {
00141                 if (str[i] == ',')
00142                 {
00143                         m_value &= ~m_mmap[str.substr(x,i - x)];
00144                         x = i + 1;
00145                 }
00146         }
00147         m_value &= ~m_mmap[str.substr(x,i - x)];
00148 }


Member Data Documentation

std::map<std::string, uint64_t>& set_t::m_mmap [private]

Definition at line 66 of file set_t.h.

Referenced by in_set(), operator+=(), operator-=(), operator=(), and String().

uint64_t set_t::m_value [private]

Definition at line 67 of file set_t.h.

Referenced by in_set(), operator &=(), operator+=(), operator-=(), operator=(), operator|=(), String(), and Value().

std::string set_t::m_strvalue [private]

Definition at line 68 of file set_t.h.

Referenced by String().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström