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

enum_t Class Reference

Implements MySQL ENUM datatype. More...

#include <enum_t.h>

Collaboration diagram for enum_t:

Collaboration graph
List of all members.

Public Member Functions

 enum_t (std::map< std::string, uint64_t > &)
const std::string & String ()
unsigned short Value ()
const char * c_str ()
void operator= (const std::string &)
void operator= (unsigned short)
bool operator== (const std::string &)
bool operator== (unsigned short)
bool operator!= (const std::string &)

Private Attributes

std::map< std::string, uint64_t > & m_mmap
std::map< unsigned short,
std::string > 
m_vmap
unsigned short m_value

Detailed Description

Implements MySQL ENUM datatype.

Definition at line 48 of file enum_t.h.


Constructor & Destructor Documentation

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

Definition at line 40 of file enum_t.cpp.

References m_vmap.

00040                                                : m_mmap(ref), m_value(0)
00041 {
00042         for (std::map<std::string, uint64_t>::iterator it = ref.begin(); it != ref.end(); it++)
00043         {
00044                 std::string str = (*it).first;
00045                 uint64_t value = (*it).second;
00046                 m_vmap[value] = str;
00047         }
00048 }


Member Function Documentation

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

Definition at line 63 of file enum_t.cpp.

References m_mmap, m_value, and m_vmap.

Referenced by c_str().

00064 {
00065         if (m_vmap.size() != m_mmap.size())
00066         {
00067                 for (std::map<std::string, uint64_t>::iterator it = m_mmap.begin(); it != m_mmap.end(); it++)
00068                 {
00069                         std::string str = (*it).first;
00070                         uint64_t value = (*it).second;
00071                         m_vmap[value] = str;
00072                 }
00073         }
00074         return m_vmap[m_value];
00075 }

unsigned short enum_t::Value (  ) 

Definition at line 78 of file enum_t.cpp.

References m_value.

00079 {
00080         return m_value;
00081 }

const char * enum_t::c_str (  ) 

Definition at line 98 of file enum_t.cpp.

References String().

Referenced by operator!=(), and operator==().

00099 {
00100         return String().c_str();
00101 }

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

Definition at line 51 of file enum_t.cpp.

References m_mmap, and m_value.

00052 {
00053         m_value = m_mmap[str];
00054 }

void enum_t::operator= ( unsigned  short  ) 

Definition at line 57 of file enum_t.cpp.

References m_value.

00058 {
00059         m_value = s;
00060 }

bool enum_t::operator== ( const std::string &   ) 

Definition at line 84 of file enum_t.cpp.

References c_str().

00085 {
00086         if (!strcasecmp(c_str(), str.c_str()))
00087                 return true;
00088         return false;
00089 }

bool enum_t::operator== ( unsigned  short  ) 

Definition at line 92 of file enum_t.cpp.

References m_value.

00093 {
00094         return m_value == s;
00095 }

bool enum_t::operator!= ( const std::string &   ) 

Definition at line 104 of file enum_t.cpp.

References c_str().

00105 {
00106         if (!strcasecmp(c_str(), str.c_str()))
00107                 return !true;
00108         return !false;
00109 }


Member Data Documentation

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

Definition at line 64 of file enum_t.h.

Referenced by operator=(), and String().

std::map<unsigned short, std::string> enum_t::m_vmap [private]

Definition at line 65 of file enum_t.h.

Referenced by enum_t(), and String().

unsigned short enum_t::m_value [private]

Definition at line 66 of file enum_t.h.

Referenced by operator=(), operator==(), String(), and Value().


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