The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

PgSQLresult Class Reference

PgSQLresult is a subclass of the mostly-pure-virtual class SQLresult. More...

Inheritance diagram for PgSQLresult:

Inheritance graph
[legend]
Collaboration diagram for PgSQLresult:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PgSQLresult (Module *self, Module *to, unsigned long rid, PGresult *result)
 ~PgSQLresult ()
virtual int Rows ()
 Return the number of rows in the result Note that if you have perfomed an INSERT or UPDATE query or other query which will not return rows, this will return the number of affected rows, and SQLresult::Cols() will contain 0.
virtual int Cols ()
 Return the number of columns in the result.
virtual std::string ColName (int column)
 Get a string name of the column by an index number.
virtual int ColNum (const std::string &column)
 Get an index number for a column from a string name.
virtual SQLfield GetValue (int row, int column)
 Get a string value in a given row and column This does not effect the internal cursor.
virtual SQLfieldListGetRow ()
 Return a list of values in a row, this should increment an internal counter so you can repeatedly call it until it returns an empty vector.
virtual SQLfieldMapGetRowMap ()
 As above, but return a map indexed by key name.
virtual SQLfieldListGetRowPtr ()
 Like GetRow(), but returns a pointer to a dynamically allocated object which must be explicitly freed.
virtual SQLfieldMapGetRowMapPtr ()
 As above, but return a map indexed by key name The internal cursor (row counter) is incremented by one.
virtual void Free (SQLfieldMap *fm)
 Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.
virtual void Free (SQLfieldList *fl)
 Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.

Private Attributes

PGresult * res
int currentrow
int rows
int cols
SQLfieldListfieldlist
SQLfieldMapfieldmap

Detailed Description

PgSQLresult is a subclass of the mostly-pure-virtual class SQLresult.

All SQL providers must create their own subclass and define it's methods using that database library's data retriveal functions. The aim is to avoid a slow and inefficient process of converting all data to a common format before it reaches the result structure. This way data is passes to the module nearly as directly as if it was using the API directly itself.

Definition at line 121 of file m_pgsql.cpp.


Constructor & Destructor Documentation

PgSQLresult::PgSQLresult Module self,
Module to,
unsigned long  rid,
PGresult *  result
[inline]
 

Definition at line 131 of file m_pgsql.cpp.

References cols, res, and rows.

PgSQLresult::~PgSQLresult  )  [inline]
 

Definition at line 138 of file m_pgsql.cpp.

References fieldlist, fieldmap, and res.


Member Function Documentation

virtual std::string PgSQLresult::ColName int  column  )  [inline, virtual]
 

Get a string name of the column by an index number.

Parameters:
column The id number of a column
Returns:
The column name associated with the given ID

Implements SQLresult.

Definition at line 167 of file m_pgsql.cpp.

References res.

Referenced by GetRowMap(), and GetRowMapPtr().

virtual int PgSQLresult::ColNum const std::string column  )  [inline, virtual]
 

Get an index number for a column from a string name.

An exception of type SQLbadColName will be thrown if the name given is invalid.

Parameters:
column The column name to get the ID of
Returns:
The ID number of the column provided

Implements SQLresult.

Definition at line 174 of file m_pgsql.cpp.

References res.

virtual int PgSQLresult::Cols  )  [inline, virtual]
 

Return the number of columns in the result.

If you performed an UPDATE or INSERT which does not return a dataset, this value will be 0.

Returns:
Number of columns in the result set.

Implements SQLresult.

Definition at line 162 of file m_pgsql.cpp.

References res.

virtual void PgSQLresult::Free SQLfieldList fl  )  [inline, virtual]
 

Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.

Parameters:
fl The SQLfieldList to free

Implements SQLresult.

Definition at line 303 of file m_pgsql.cpp.

virtual void PgSQLresult::Free SQLfieldMap fm  )  [inline, virtual]
 

Overloaded function for freeing the lists and maps returned by GetRowPtr or GetRowMapPtr.

Parameters:
fm The SQLfieldMap to free

Implements SQLresult.

Definition at line 298 of file m_pgsql.cpp.

virtual SQLfieldList& PgSQLresult::GetRow  )  [inline, virtual]
 

Return a list of values in a row, this should increment an internal counter so you can repeatedly call it until it returns an empty vector.

This returns a reference to an internal object, the same object is used for all calls to this function and therefore the return value is only valid until you call this function again. It is also invalid if the SQLresult object is destroyed. The internal cursor (row counter) is incremented by one.

Returns:
A reference to the current row's SQLfieldList

Implements SQLresult.

Definition at line 202 of file m_pgsql.cpp.

References currentrow, fieldlist, GetValue(), and res.

virtual SQLfieldMap& PgSQLresult::GetRowMap  )  [inline, virtual]
 

As above, but return a map indexed by key name.

The internal cursor (row counter) is incremented by one.

Returns:
A reference to the current row's SQLfieldMap

Implements SQLresult.

Definition at line 231 of file m_pgsql.cpp.

References ColName(), currentrow, fieldmap, GetValue(), and res.

virtual SQLfieldMap* PgSQLresult::GetRowMapPtr  )  [inline, virtual]
 

As above, but return a map indexed by key name The internal cursor (row counter) is incremented by one.

Returns:
A newly-allocated SQLfieldMap

Implements SQLresult.

Definition at line 279 of file m_pgsql.cpp.

References ColName(), currentrow, GetValue(), and res.

virtual SQLfieldList* PgSQLresult::GetRowPtr  )  [inline, virtual]
 

Like GetRow(), but returns a pointer to a dynamically allocated object which must be explicitly freed.

For portability reasons this must be freed with SQLresult::Free() The internal cursor (row counter) is incremented by one.

Returns:
A newly-allocated SQLfieldList

Implements SQLresult.

Definition at line 260 of file m_pgsql.cpp.

References currentrow, GetValue(), and res.

virtual SQLfield PgSQLresult::GetValue int  row,
int  column
[inline, virtual]
 

Get a string value in a given row and column This does not effect the internal cursor.

Returns:
The value stored at [row,column] in the table

Implements SQLresult.

Definition at line 188 of file m_pgsql.cpp.

References res.

Referenced by GetRow(), GetRowMap(), GetRowMapPtr(), and GetRowPtr().

virtual int PgSQLresult::Rows  )  [inline, virtual]
 

Return the number of rows in the result Note that if you have perfomed an INSERT or UPDATE query or other query which will not return rows, this will return the number of affected rows, and SQLresult::Cols() will contain 0.

In this case you SHOULD NEVER access any of the result set rows, as there arent any!

Returns:
Number of rows in the result set.

Implements SQLresult.

Definition at line 150 of file m_pgsql.cpp.

References cols, res, and rows.


Member Data Documentation

int PgSQLresult::cols [private]
 

Definition at line 126 of file m_pgsql.cpp.

Referenced by PgSQLresult(), and Rows().

int PgSQLresult::currentrow [private]
 

Definition at line 124 of file m_pgsql.cpp.

Referenced by GetRow(), GetRowMap(), GetRowMapPtr(), and GetRowPtr().

SQLfieldList* PgSQLresult::fieldlist [private]
 

Definition at line 128 of file m_pgsql.cpp.

Referenced by GetRow(), and ~PgSQLresult().

SQLfieldMap* PgSQLresult::fieldmap [private]
 

Definition at line 129 of file m_pgsql.cpp.

Referenced by GetRowMap(), and ~PgSQLresult().

PGresult* PgSQLresult::res [private]
 

Definition at line 123 of file m_pgsql.cpp.

Referenced by ColName(), ColNum(), Cols(), GetRow(), GetRowMap(), GetRowMapPtr(), GetRowPtr(), GetValue(), PgSQLresult(), Rows(), and ~PgSQLresult().

int PgSQLresult::rows [private]
 

Definition at line 125 of file m_pgsql.cpp.

Referenced by PgSQLresult(), and Rows().


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