CppDB
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Friends
cppdb::result Class Reference

This object represents query result. More...

#include <cppdb/frontend.h>

List of all members.

Public Member Functions

 result ()
 ~result ()
 result (result const &)
result const & operator= (result const &)
int cols ()
bool next ()
int index (std::string const &n)
int find_column (std::string const &name)
std::string name (int col)
bool is_null (int col)
bool is_null (std::string const &n)
void clear ()
void rewind_column ()
bool empty ()
bool fetch (int col, short &v)
bool fetch (int col, unsigned short &v)
bool fetch (int col, int &v)
bool fetch (int col, unsigned &v)
bool fetch (int col, long &v)
bool fetch (int col, unsigned long &v)
bool fetch (int col, long long &v)
bool fetch (int col, unsigned long long &v)
bool fetch (int col, float &v)
bool fetch (int col, double &v)
bool fetch (int col, long double &v)
bool fetch (int col, std::string &v)
bool fetch (int col, std::tm &v)
bool fetch (int col, std::ostream &v)
bool fetch (std::string const &n, short &v)
bool fetch (std::string const &n, unsigned short &v)
bool fetch (std::string const &n, int &v)
bool fetch (std::string const &n, unsigned &v)
bool fetch (std::string const &n, long &v)
bool fetch (std::string const &n, unsigned long &v)
bool fetch (std::string const &n, long long &v)
bool fetch (std::string const &n, unsigned long long &v)
bool fetch (std::string const &n, float &v)
bool fetch (std::string const &n, double &v)
bool fetch (std::string const &n, long double &v)
bool fetch (std::string const &n, std::string &v)
bool fetch (std::string const &n, std::tm &v)
bool fetch (std::string const &n, std::ostream &v)
bool fetch (short &v)
bool fetch (unsigned short &v)
bool fetch (int &v)
bool fetch (unsigned &v)
bool fetch (long &v)
bool fetch (unsigned long &v)
bool fetch (long long &v)
bool fetch (unsigned long long &v)
bool fetch (float &v)
bool fetch (double &v)
bool fetch (long double &v)
bool fetch (std::string &v)
bool fetch (std::tm &v)
bool fetch (std::ostream &v)
template<typename T >
get (std::string const &name)
template<typename T >
get (std::string const &name, T const &def)
template<typename T >
get (int col)
template<typename T >
get (int col, T const &def)
template<typename T >
resultoperator>> (tags::into_tag< T > ref)
template<typename T >
resultoperator>> (T &value)

Friends

class statement

Detailed Description

This object represents query result.

This object and it is generally created by statement::query() call, default constructor is provided for consistency, but access to any member function with exception of empty() would throw an exception.


Constructor & Destructor Documentation

Create an empty result, it is not useful except for having default constructor

Destroys the result, note, if the result of statement is not destroyed, it would not be returned to statements cache.

Copy result, note it only keeps the reference to actual object so copy is just copy of the reference


Member Function Documentation

Clears the result, no further use of the result should be done until it is assigned again with a new statement result.

It is useful when you want to release all data and return the statement to cache

Return the number of columns in the result

Check if the current row is empty, it is in 3 cases:

  1. Empty result
  2. next() wasn't called first time
  3. next() returned false;
bool cppdb::result::fetch ( int  col,
short &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
unsigned short &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
int &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
unsigned &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
long &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
unsigned long &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
long long &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
unsigned long long &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
float &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
double &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
long double &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
std::string &  v 
)

Fetch a textual value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same, if possible it converts it into textual representation.

bool cppdb::result::fetch ( int  col,
std::tm &  v 
)

Fetch a value from column col (starting from 0) into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

bool cppdb::result::fetch ( int  col,
std::ostream &  v 
)

Fetch a binary large object value from column col (starting from 0) into a stream v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not blob, it may throw bad_value_cast()

bool cppdb::result::fetch ( std::string const &  n,
short &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
unsigned short &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
int &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
unsigned &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
long &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
unsigned long &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
long long &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
unsigned long long &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
float &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
double &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
long double &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
std::string &  v 
)

Fetch a textual value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same, if possible it converts it into textual representation. If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
std::tm &  v 
)

Fetch a value from column named n into v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( std::string const &  n,
std::ostream &  v 
)

Fetch a binary large object value from column named name into a stream v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not blob, it may throw bad_value_cast(). If the n value is invalid throws invalid_column exception

bool cppdb::result::fetch ( short &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( unsigned short &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( int &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( unsigned &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( long &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( unsigned long &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( long long &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( unsigned long long &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( float &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( double &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( long double &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( std::string &  v)

Fetch a textual value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same, if possible it converts it into textual representation.

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( std::tm &  v)

Fetch a value from the next column in the row starting from the first one. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not same it tries to cast the data, if casting fails or the data is out of the type range, throws bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

bool cppdb::result::fetch ( std::ostream &  v)

Fetch a blob value from the next column in the row starting from the first one into stream v. Returns false if the value in NULL and v is not updated, otherwise returns true.

If the data type is not blob, it may throw bad_value_cast().

If fetch was called more times then cols() it throws invalid_column exception, to use it once again from the beginning on the same row call rewind_column() member function. It is not required to call rewind_column() after calling next() as column index is reset automatically.

int cppdb::result::find_column ( std::string const &  name)

Convert column name n to its index, returns -1 if the name is not valid.

template<typename T >
T cppdb::result::get ( std::string const &  name) [inline]

Get a value of type T from column named name. If the column is null throws null_value_fetch(), if the column name is invalid throws invalid_column, if the column value cannot be converted to type T (see fetch functions) it throws bad_value_cast.

template<typename T >
T cppdb::result::get ( std::string const &  name,
T const &  def 
) [inline]

Get a value of type T from column named name. If the column is null returns def, if the column name is invalid throws invalid_column, if the column value cannot be converted to type T (see fetch functions) it throws bad_value_cast.

template<typename T >
T cppdb::result::get ( int  col) [inline]

Get a value of type T from column col (starting from 0). If the column is null throws null_value_fetch(), if the column index is invalid throws invalid_column, if the column value cannot be converted to type T (see fetch functions) it throws bad_value_cast.

template<typename T >
T cppdb::result::get ( int  col,
T const &  def 
) [inline]

Get a value of type T from column col (starting from 0). If the column is null returns def, if the column index is invalid throws invalid_column, if the column value cannot be converted to type T (see fetch functions) it throws bad_value_cast.

int cppdb::result::index ( std::string const &  n)

Convert column name n to its index, throws invalid_column if the name is not valid.

bool cppdb::result::is_null ( int  col)

Return true if the column number col (starting from 0) has NULL value

bool cppdb::result::is_null ( std::string const &  n)

Return true if the column named n has NULL value

std::string cppdb::result::name ( int  col)

Convert column index to column name, throws invalid_column if col is not in range 0<= col < cols()

Move forward to next row, returns false if no more rows available.

Notes:

result const& cppdb::result::operator= ( result const &  )

Assign result, note it only keeps the reference to actual object so assignment is just copy of the reference

template<typename T >
result& cppdb::result::operator>> ( tags::into_tag< T >  ref) [inline]

Syntactic sugar, used together with into() function.

res << into(x,y) is same as

template<typename T >
result& cppdb::result::operator>> ( T &  value) [inline]

Syntactic sugar, same as fetch(value)

Reset current column index, so fetch without column index can be used once again


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator