AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
anch::sql::ResultSet Class Referenceabstract

SQL result representation. More...

#include <resultSet.hpp>

Inheritance diagram for anch::sql::ResultSet:
Collaboration diagram for anch::sql::ResultSet:

Public Member Functions

 ResultSet ()
 
virtual ~ResultSet ()
 
template<typename T >
const T * get (std::size_t idx) throw (SqlException)
 
template<typename T >
bool get (std::size_t idx, T &out) throw (SqlException)
 
template<typename T >
bool get (const std::string field, T &out) throw (SqlException)
 
template<typename T >
const T * get (const std::string field) throw (SqlException)
 
virtual bool next ()=0 throw (SqlException)
 
template<>
bool get (std::size_t idx, int64_t &out) throw (SqlException)
 
template<>
bool get (std::size_t idx, int32_t &out) throw (SqlException)
 
template<>
bool get (std::size_t idx, int16_t &out) throw (SqlException)
 
template<>
bool get (std::size_t idx, uint64_t &out) throw (SqlException)
 
template<>
bool get (std::size_t idx, uint32_t &out) throw (SqlException)
 
template<>
bool get (std::size_t idx, uint16_t &out) throw (SqlException)
 
template<>
const int64_t * get (std::size_t idx) throw (SqlException)
 
template<>
const int32_t * get (std::size_t idx) throw (SqlException)
 
template<>
const int16_t * get (std::size_t idx) throw (SqlException)
 
template<>
const uint64_t * get (std::size_t idx) throw (SqlException)
 
template<>
const uint32_t * get (std::size_t idx) throw (SqlException)
 
template<>
const uint16_t * get (std::size_t idx) throw (SqlException)
 

Protected Member Functions

virtual bool getValue (std::size_t idx, std::string &out)=0 throw (SqlException)
 

Protected Attributes

std::map< std::string, std::size_t > _fields
 

Detailed Description

SQL result representation.

The ResultSet has to be used with while(res.hasNext()) {res.next(); [...]}.
Field getter is templated. Specializations are included in library. If you need other conversions, you can implement them in your own program.

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

ResultSet::ResultSet ( )

ResultSet default constructor

ResultSet::~ResultSet ( )
virtual

ResultSet destrcutor

Member Function Documentation

template<>
bool anch::sql::ResultSet::get ( std::size_t  idx,
int64_t &  out 
)
throw (SqlException
)

Get field int64_t value by index.
The output parameter will be set only if SQL result is not NULL.

Parameters
idxthe index
outthe result
Returns
true if result is NULL, false otherwise
Exceptions
SqlExceptionany error
template<typename T >
const T* anch::sql::ResultSet::get ( std::size_t  idx)
throw (SqlException
)

Get field value by index.
You have to delete result once treated.

Template Parameters
Texpected type
Parameters
idxthe index
Returns
the result
Exceptions
SqlExceptionany error
template<typename T >
bool anch::sql::ResultSet::get ( std::size_t  idx,
T &  out 
)
throw (SqlException
)

Get field value by index.
The output parameter will be set only if SQL result is not NULL.

Template Parameters
Texpected type
Parameters
idxthe index
outthe result
Returns
true if result is NULL, false otherwise
Exceptions
SqlExceptionany error
template<>
bool anch::sql::ResultSet::get ( std::size_t  idx,
int32_t &  out 
)
throw (SqlException
)

Get field int32_t value by index.
The output parameter will be set only if SQL result is not NULL.

Parameters
idxthe index
outthe result
Returns
true if result is NULL, false otherwise
Exceptions
SqlExceptionany error
template<typename T >
bool anch::sql::ResultSet::get ( const std::string  field,
T &  out 
)
throw (SqlException
)
inline

Get field value by field name.
The output parameter will be set only if SQL result is not NULL.

Template Parameters
Texpected type
Parameters
fieldthe field name
outthe result
Returns
true if result is NULL, false otherwise
template<>
bool anch::sql::ResultSet::get ( std::size_t  idx,
int16_t &  out 
)
throw (SqlException
)

Get field int16_t value by index.
The output parameter will be set only if SQL result is not NULL.

Parameters
idxthe index
outthe result
Returns
true if result is NULL, false otherwise
Exceptions
SqlExceptionany error
template<typename T >
const T* anch::sql::ResultSet::get ( const std::string  field)
throw (SqlException
)
inline

Get field value by field name.
You have to delete result once treated.

Template Parameters
Texpected type
Parameters
fieldthe field name
Returns
the result
Exceptions
SqlExceptionany error
template<>
bool anch::sql::ResultSet::get ( std::size_t  idx,
uint64_t &  out 
)
throw (SqlException
)

Get field uint64_t value by index.
The output parameter will be set only if SQL result is not NULL.

Parameters
idxthe index
outthe result
Returns
true if result is NULL, false otherwise
Exceptions
SqlExceptionany error
template<>
bool anch::sql::ResultSet::get ( std::size_t  idx,
uint32_t &  out 
)
throw (SqlException
)

Get field uint32_t value by index.
The output parameter will be set only if SQL result is not NULL.

Parameters
idxthe index
outthe result
Returns
true if result is NULL, false otherwise
Exceptions
SqlExceptionany error
template<>
bool anch::sql::ResultSet::get ( std::size_t  idx,
uint16_t &  out 
)
throw (SqlException
)

Get field uint16_t value by index.
The output parameter will be set only if SQL result is not NULL.

Parameters
idxthe index
outthe result
Returns
true if result is NULL, false otherwise
Exceptions
SqlExceptionany error
template<>
const int64_t* anch::sql::ResultSet::get ( std::size_t  idx)
throw (SqlException
)

Get field int64_t value by index.
You have to delete result once treated.

Parameters
idxthe index
Returns
the result
Exceptions
SqlExceptionany error
template<>
const int32_t* anch::sql::ResultSet::get ( std::size_t  idx)
throw (SqlException
)

Get field int32_t value by index.
You have to delete result once treated.

Parameters
idxthe index
Returns
the result
Exceptions
SqlExceptionany error
template<>
const int16_t* anch::sql::ResultSet::get ( std::size_t  idx)
throw (SqlException
)

Get field int16_t value by index.
You have to delete result once treated.

Parameters
idxthe index
Returns
the result
Exceptions
SqlExceptionany error
template<>
const uint64_t* anch::sql::ResultSet::get ( std::size_t  idx)
throw (SqlException
)

Get field uint64_t value by index.
You have to delete result once treated.

Parameters
idxthe index
Returns
the result
Exceptions
SqlExceptionany error
template<>
const uint32_t* anch::sql::ResultSet::get ( std::size_t  idx)
throw (SqlException
)

Get field uint32_t value by index.
You have to delete result once treated.

Parameters
idxthe index
Returns
the result
Exceptions
SqlExceptionany error
template<>
const uint16_t* anch::sql::ResultSet::get ( std::size_t  idx)
throw (SqlException
)

Get field uint16_t value by index.
You have to delete result once treated.

Parameters
idxthe index
Returns
the result
Exceptions
SqlExceptionany error
virtual bool anch::sql::ResultSet::getValue ( std::size_t  idx,
std::string &  out 
)
throw (SqlException
)
protectedpure virtual

Retrieve string value from result set according to SQL database engine.

Parameters
idxthe field index
outthe result
Exceptions
SqlExceptionany error

Implemented in anch::sql::PostgreSQLResultSet, anch::sql::MySQLResultSet, and anch::sql::SQLite3ResultSet.

virtual bool anch::sql::ResultSet::next ( )
throw (SqlException
)
pure virtual

Retrieve next row

Returns
true if next row exists, false otherwise
Exceptions
SqlExceptionany error

Implemented in anch::sql::PostgreSQLResultSet, anch::sql::MySQLResultSet, and anch::sql::SQLite3ResultSet.

Member Data Documentation

std::map<std::string, std::size_t> anch::sql::ResultSet::_fields
protected

Result set fields


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