dal::RecordSet Class Reference

A RecordSet to store the result of a SQL query. More...

#include <recordset.h>

List of all members.

Public Member Functions

 RecordSet (void) throw ()
 Default constructor.
 ~RecordSet (void) throw ()
 Destructor.
void clear (void)
 Remove all the records.
bool isEmpty (void) const
 Check if the RecordSet is empty.
unsigned int rows (void) const
 Get the number of rows.
unsigned int cols (void) const
 Get the number of columns.
void setColumnHeaders (const Row &headers)
 Set the column headers.
void add (const Row &row)
 Add a new row.
const std::string & operator() (const unsigned int row, const unsigned int col) const
 Operator() Get the value of a particular field of a particular row by field index.
const std::string & operator() (const unsigned int row, const std::string &name) const
 Operator() Get the value of a particular field of a particular row by field name (slower than by field index).

Friends

std::ostream & operator<< (std::ostream &out, const RecordSet &rhs)
 Operator<< Append the stringified RecordSet to the output stream.


Detailed Description

A RecordSet to store the result of a SQL query.

Limitations:

Definition at line 45 of file recordset.h.


Member Function Documentation

void dal::RecordSet::clear ( void   ) 

Remove all the records.

Remove all the Records.

Definition at line 57 of file recordset.cpp.

Referenced by dal::SqLiteDataProvider::execSql(), dal::PqDataProvider::execSql(), and dal::MySqlDataProvider::execSql().

bool dal::RecordSet::isEmpty ( void   )  const

Check if the RecordSet is empty.

Returns:
true if empty.

Definition at line 68 of file recordset.cpp.

Referenced by DALStorage::banCharacter(), DALStorage::getGuildList(), DALStorage::getQuestVar(), DALStorage::getStoredPost(), and DALStorage::getWorldStateVar().

unsigned int dal::RecordSet::rows ( void   )  const

Get the number of rows.

Returns:
the number of rows.

Definition at line 80 of file recordset.cpp.

Referenced by DALStorage::getGuildList(), DALStorage::getStoredPost(), and DALStorage::getTransactions().

unsigned int dal::RecordSet::cols ( void   )  const

Get the number of columns.

Returns:
the number of columns.

Definition at line 92 of file recordset.cpp.

void dal::RecordSet::setColumnHeaders ( const Row &  headers  ) 

Set the column headers.

Parameters:
headers the column headers.
Exceptions:
AlreadySetException if the column headers are already set.

Definition at line 102 of file recordset.cpp.

Referenced by dal::SqLiteDataProvider::execSql(), dal::PqDataProvider::execSql(), and dal::MySqlDataProvider::execSql().

void dal::RecordSet::add ( const Row &  row  ) 

Add a new row.

This method does not check the field data types, only the number of columns is checked.

Parameters:
row the new row.
Exceptions:
RsColumnHeadersNotSet if the row is being added before the column headers.
std::invalid_argument if the number of columns in the new row is not equal to the number of column headers.

Definition at line 116 of file recordset.cpp.

Referenced by dal::SqLiteDataProvider::execSql(), dal::PqDataProvider::execSql(), and dal::MySqlDataProvider::execSql().

const std::string & dal::RecordSet::operator() ( const unsigned int  row,
const unsigned int  col 
) const

Operator() Get the value of a particular field of a particular row by field index.

Operator().

Parameters:
row the row index.
col the field index.
Returns:
the field value.
Exceptions:
std::out_of_range if row or col are out of range.
std::invalid_argument if the recordset is empty.

Definition at line 140 of file recordset.cpp.

const std::string & dal::RecordSet::operator() ( const unsigned int  row,
const std::string &  name 
) const

Operator() Get the value of a particular field of a particular row by field name (slower than by field index).

Operator().

Parameters:
row the row index.
name the field name.
Returns:
the field value.
Exceptions:
std::out_of_range if the row index is out of range.
std::invalid_argument if the field name is not found or the recordset is empty.

Definition at line 160 of file recordset.cpp.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const RecordSet rhs 
) [friend]

Operator<< Append the stringified RecordSet to the output stream.

Parameters:
out the output stream.
rhs the right hand side.
Returns:
the output stream for chaining.

Definition at line 198 of file recordset.cpp.


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

Generated on Sun Apr 26 17:30:47 2009 for TMW Server Collection by  doxygen 1.5.5