Logo
~Sockets~
~Examples~
~Contact~


Database Class Reference

#include <Database.h>

List of all members.


Public Member Functions

 Database (const std::string &)
 Database (char *filename, int mode)
virtual ~Database ()
Sessiongrabdb ()
void freedb (Session *odb)
QueryGetQuery ()
QueryGetQuery (const std::string &)
short errcode ()
void debug (short val)
short debug ()
void SetEscapeChar (char)
char GetEscapeChar ()
void SetDecimalChar (char)
char GetDecimalChar ()
void GetErrorText (char *)

Private Attributes

char * filename
int mode
sessions_t m_sessions
short errc
short _debug
char m_escape
char m_decimal

Detailed Description

Definition at line 29 of file Database.h.


Constructor & Destructor Documentation

Database::Database ( const std::string &   ) 

Database::Database ( char *  filename,
int  mode 
)

Definition at line 59 of file Database.cpp.

References errc, filename, freedb(), grabdb(), and m_escape.

00060 :filename(new char[strlen(f) + 1])
00061 ,mode(m)
00062 {
00063         errc = 0;
00064         m_escape = '\\';
00065 
00066         strcpy(filename,f);
00067         
00068         freedb(grabdb());               // open one connection
00069 }

Database::~Database (  )  [virtual]

Definition at line 71 of file Database.cpp.

References filename, and m_sessions.

00072 {
00073         sessions_t::iterator it;
00074         if (filename)
00075                 delete filename;
00076         for (it = m_sessions.begin(); it != m_sessions.end(); it++)
00077         {
00078                 Session *p = *it;
00079                 p -> Disconnect();
00080         }
00081         while (m_sessions.size())
00082         {
00083                 it = m_sessions.begin();
00084                 if ((*it) -> IsBusy())
00085                 {
00086                         fprintf(stderr,"destroying Database object before Connect object(s)\n");
00087                 }
00088                 delete *it;
00089                 m_sessions.erase(it);
00090         }
00091 }


Member Function Documentation

Session * Database::grabdb (  ) 

Definition at line 93 of file Database.cpp.

References DEB, filename, m_sessions, and mode.

Referenced by Database().

00094 {
00095         sessions_t::iterator it;
00096         for (it = m_sessions.begin(); it != m_sessions.end(); it++)
00097         {
00098                 if (!(*it) -> IsBusy())
00099                 {
00100                         (*it) -> SetBusy(true);
00101                         return *it;
00102                 }
00103         }
00104         Session *tmp = new Session();
00105         m_sessions.insert(m_sessions.end(), tmp);
00106 DEB(    printf("number of Database sessions: %d\n",m_sessions.size());)
00107         tmp -> Connect(filename, mode);
00108         tmp -> SetBusy(true);
00109         return tmp;
00110 }

void Database::freedb ( Session odb  ) 

Definition at line 112 of file Database.cpp.

Referenced by Database().

00113 {
00114         odb -> SetBusy(false);
00115 }

Query * Database::GetQuery (  ) 

Definition at line 133 of file Database.cpp.

00134 {
00135         return new Query( this );
00136 }

Query* Database::GetQuery ( const std::string &   ) 

short Database::errcode (  ) 

Definition at line 117 of file Database.cpp.

References errc.

00118 {
00119         return errc;
00120 }

void Database::debug ( short  val  ) 

Definition at line 122 of file Database.cpp.

References _debug.

00123 {
00124         _debug = val;
00125 }

short Database::debug (  ) 

Definition at line 127 of file Database.cpp.

References _debug.

00128 {
00129         return _debug;
00130 }

void Database::SetEscapeChar ( char   ) 

Definition at line 145 of file Database.cpp.

References m_escape.

00146 {
00147         m_escape = ch;
00148 }

char Database::GetEscapeChar (  ) 

Definition at line 150 of file Database.cpp.

References m_decimal.

00151 {
00152         return m_decimal;
00153 }

void Database::SetDecimalChar ( char   ) 

Definition at line 156 of file Database.cpp.

References m_decimal.

00157 {
00158         m_decimal = ch;
00159 }

char Database::GetDecimalChar (  ) 

Definition at line 161 of file Database.cpp.

References m_decimal.

00162 {
00163         return m_decimal;
00164 }

void Database::GetErrorText ( char *   )  [inline]

Definition at line 50 of file Database.h.

00050 {}


Member Data Documentation

char* Database::filename [private]

Definition at line 53 of file Database.h.

Referenced by Database(), grabdb(), and ~Database().

int Database::mode [private]

Definition at line 54 of file Database.h.

Referenced by grabdb().

Definition at line 55 of file Database.h.

Referenced by grabdb(), and ~Database().

short Database::errc [private]

Definition at line 56 of file Database.h.

Referenced by Database(), and errcode().

short Database::_debug [private]

Definition at line 57 of file Database.h.

Referenced by debug().

char Database::m_escape [private]

Definition at line 58 of file Database.h.

Referenced by Database(), and SetEscapeChar().

char Database::m_decimal [private]

Definition at line 59 of file Database.h.

Referenced by GetDecimalChar(), GetEscapeChar(), and SetDecimalChar().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4