Database Class Reference

#include <Database.h>

List of all members.


Public Member Functions

 Database ()
 Public constructor.
virtual ~Database ()
 Virtual destructor.
common::ErrorCodeType Connect (const std::string &hostname, const std::string &username, const std::string &password)
 Connects database.
common::ErrorCodeType Close ()
 Closes database.
common::ErrorCodeType GetPlayer (const std::string &rUsername, const std::string &rPassword, common::Player &rPlayer)
 Gets player.
common::ErrorCodeType GetTimeStamp (std::string &rTimeStamp)
 Gets time stamp.

Private Member Functions

common::ErrorCodeType Query (const std::string &rQuery, std::string &rResult)
 Executes query.
std::string EscapeString (const std::string &rString)
 Sanitizes string.

Private Attributes

MYSQL * m_pDatabase
 Pointer to private MySQL structure.
SDL_mutex * m_pQueryMutex
 Pointer to query mutex.

Detailed Description

Database class.
Full Description
This class implements the database.

Constructor & Destructor Documentation

Database (  ) 

Public constructor.

Full Description
This method creates a new instance of the class.
Returns:
New instance of the class.

~Database (  )  [virtual]

Virtual destructor.

Full Description
This method destroys an existing instance of the class.
Returns:
None.


Member Function Documentation

common::ErrorCodeType Connect ( const std::string &  hostname,
const std::string &  username,
const std::string &  password 
)

Connects database.

Full Description
This method connects the database.
Returns:
Success if successful.

Failure otherwise.

Parameters:
hostname  Host name or IP address.
username  User login name on host.
password  Password of given user.

common::ErrorCodeType Close (  ) 

Closes database.

Full Description
This method close the database.
Returns:
Always returns ERROR_CODE_SUCCESS.

common::ErrorCodeType GetPlayer ( const std::string &  rUsername,
const std::string &  rPassword,
common::Player rPlayer 
)

Gets player.

Full Description
This method gets a player from the database.
Returns:
Success if successful.

Failure otherwise.

Parameters:
rUsername  Username.
rPassword  Password.
rPlayer  Player.

common::ErrorCodeType GetTimeStamp ( std::string &  rTimeStamp  ) 

Gets time stamp.

Full Description
This method gets a player from the database.
Returns:
Success if successful.

Failure otherwise.

Parameters:
rTimeStamp  Time stamp.

common::ErrorCodeType Query ( const std::string &  rQuery,
std::string &  rResult 
) [private]

Executes query.

Full Description
This method executes a query.
Returns:
Success if successful.

Failure otherwise.

Parameters:
rQuery  Query to be executed.
rResult  Result of query.

std::string EscapeString ( const std::string &  rString  )  [private]

Sanitizes string.

Full Description
This method creates a legal SQL string.
Returns:
Escape string.


Member Data Documentation

MYSQL* m_pDatabase [private]

Pointer to private MySQL structure.

SDL_mutex* m_pQueryMutex [private]

Pointer to query mutex.


The documentation for this class was generated from the following files: