Logo
~Sockets~
~Examples~
~Contact~


ServerHandler Class Reference

#include <ServerHandler.h>

Collaboration diagram for ServerHandler:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ServerHandler (const std::string &)
 ~ServerHandler ()
bool Exists (const std::string &)
int GetInt (const std::string &)
std::string GetString (const std::string &)
bool GetBoolean (const std::string &)
std::string GetMimetype (const std::string &)
Database * GetDatabase ()

Private Attributes

Configuration m_config
Database m_db
Mime m_mime

Detailed Description

File ......... ServerHandler.h Published .... 2004-07-13 Author ....... grymse@alhem.net

Definition at line 33 of file ServerHandler.h.


Constructor & Destructor Documentation

ServerHandler::ServerHandler ( const std::string &  filename  ) 

File ......... ServerHandler.cpp Published .... 2004-07-13 Author ....... grymse@alhem.net

Definition at line 30 of file ServerHandler.cpp.

00031 :SocketHandler()
00032 ,m_config(filename)
00033 ,m_db(GetString("database/host"),GetString("database/user"),GetString("database/password"),GetString("database/database"))
00034 ,m_mime(GetString("mime/filename"))
00035 {
00036 }

ServerHandler::~ServerHandler (  ) 

Definition at line 39 of file ServerHandler.cpp.

00040 {
00041 }


Member Function Documentation

bool ServerHandler::Exists ( const std::string &   ) 

int ServerHandler::GetInt ( const std::string &   ) 

Definition at line 44 of file ServerHandler.cpp.

References Configuration::Find(), BaseXMLFile::GetProperty(), BaseXMLFile::GetRootElement(), m_config, and BaseXMLFile::SetCurrent().

Referenced by ServerSocket::Init(), and main().

00045 {
00046         xmlNodePtr p = m_config.Find(m_config.GetRootElement(),path);
00047         if (p)
00048         {
00049                 m_config.SetCurrent(p);
00050                 std::string str = m_config.GetProperty("value");
00051                 return atoi(str.c_str());
00052         }
00053         else
00054         {
00055                 fprintf(stderr,"config path not found: %s\n",path.c_str());
00056         }
00057         return 0;
00058 }

std::string ServerHandler::GetString ( const std::string &   ) 

Definition at line 61 of file ServerHandler.cpp.

References Configuration::Find(), BaseXMLFile::GetProperty(), BaseXMLFile::GetRootElement(), m_config, and BaseXMLFile::SetCurrent().

Referenced by main(), and Deliver::Run().

00062 {
00063         xmlNodePtr p = m_config.Find(m_config.GetRootElement(),path);
00064         if (p)
00065         {
00066                 m_config.SetCurrent(p);
00067                 std::string str = m_config.GetProperty("value");
00068                 return str;
00069         }
00070         fprintf(stderr,"config path not found: %s\n",path.c_str());
00071         return "";
00072 }

bool ServerHandler::GetBoolean ( const std::string &   ) 

Definition at line 75 of file ServerHandler.cpp.

References Configuration::Find(), BaseXMLFile::GetProperty(), BaseXMLFile::GetRootElement(), m_config, and BaseXMLFile::SetCurrent().

Referenced by main().

00076 {
00077         xmlNodePtr p = m_config.Find(m_config.GetRootElement(),path);
00078         std::string str;
00079         if (p)
00080         {
00081                 m_config.SetCurrent(p);
00082                 str = m_config.GetProperty("value");
00083                 if (str.size() && (str[0] == '1' ||
00084                         str[0] == 'y' || str[0] == 'Y' ||
00085                         str[0] == 't' || str[0] == 'T'))
00086                 {
00087                         return true;
00088                 }
00089                 return false;
00090         }
00091         fprintf(stderr,"config path not found: %s\n",path.c_str());
00092         return false;
00093 }

std::string ServerHandler::GetMimetype ( const std::string &   ) 

Definition at line 96 of file ServerHandler.cpp.

References Mime::GetMimeFromExtension(), and m_mime.

Referenced by Deliver::Run().

00097 {
00098         return m_mime.GetMimeFromExtension(ext);
00099 }

Database* ServerHandler::GetDatabase (  )  [inline]

Definition at line 45 of file ServerHandler.h.

References m_db.

Referenced by Deliver::Run().

00045 { return &m_db; }


Member Data Documentation

Definition at line 48 of file ServerHandler.h.

Referenced by GetBoolean(), GetInt(), and GetString().

Database ServerHandler::m_db [private]

Definition at line 49 of file ServerHandler.h.

Referenced by GetDatabase().

Definition at line 50 of file ServerHandler.h.

Referenced by GetMimetype().


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