The Battle for Wesnoth  1.15.5+dev
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
mariadb::result_set Class Reference

Class used to store query and statement results. More...

#include <result_set.hpp>

Inheritance diagram for mariadb::result_set:
Inheritance graph

Public Member Functions

virtual ~result_set ()
 Destructs the result_set and frees all result data. More...
 
u32 column_count () const
 Get the count of columns contained in this result_set. More...
 
u32 column_index (const std::string &name) const
 Get the index of a column by column-name (case sensitive) More...
 
value::type column_type (u32 index) const
 Gets the type of a column by index. More...
 
const std::string column_name (u32 index)
 Gets the name of a column by index. More...
 
unsigned long column_size (u32 index) const
 Gets the size of the data contained in the column at index. More...
 
u64 row_index () const
 Gets the row index of the currently selected row. More...
 
u64 row_count () const
 Gets the number of rows in this result. More...
 
bool next ()
 Fetch next row from result_set. More...
 
bool set_row_index (u64 index)
 Set the current row index in result_set (seek to result). More...
 
 MAKE_GETTER_DECL (blob, stream_ref)
 
 MAKE_GETTER_DECL (data, data_ref)
 
 MAKE_GETTER_DECL (date, date_time)
 
 MAKE_GETTER_DECL (date_time, date_time)
 
 MAKE_GETTER_DECL (time, time)
 
 MAKE_GETTER_DECL (decimal, decimal)
 
 MAKE_GETTER_DECL (string, std::string)
 
 MAKE_GETTER_DECL (boolean, bool)
 
 MAKE_GETTER_DECL (unsigned8, u8)
 
 MAKE_GETTER_DECL (signed8, s8)
 
 MAKE_GETTER_DECL (unsigned16, u16)
 
 MAKE_GETTER_DECL (signed16, s16)
 
 MAKE_GETTER_DECL (unsigned32, u32)
 
 MAKE_GETTER_DECL (signed32, s32)
 
 MAKE_GETTER_DECL (unsigned64, u64)
 
 MAKE_GETTER_DECL (signed64, s64)
 
 MAKE_GETTER_DECL (float, f32)
 
 MAKE_GETTER_DECL (double, f64)
 
 MAKE_GETTER_DECL (is_null, bool)
 
- Public Member Functions inherited from mariadb::last_error
 last_error ()
 
u32 error_no () const
 
const std::string & error () const
 

Private Types

typedef std::map< std::string, u32map_indexes_t
 

Private Member Functions

 result_set (connection *conn)
 Create result_set from connection. More...
 
 result_set (connection *conn, const statement_data_ref &stmt)
 Create result_set from statement. More...
 
void check_row_fetched () const
 Throws if the result set was created, but no row was ever fetched (using next()) More...
 
void check_type (u32 index, value::type requested) const
 Throws if the actual type of column at index cannot be converted to the requested type. More...
 

Private Attributes

MYSQL_RES * m_result_set
 
MYSQL_FIELD * m_fields
 
MYSQL_ROW m_row
 
MYSQL_BIND * m_raw_binds
 
std::vector< bind_refm_binds
 
statement_data_ref m_stmt_data
 
map_indexes_t m_indexes
 
long unsigned int * m_lengths
 
u32 m_field_count
 
bool m_was_fetched
 

Friends

class connection
 
class statement
 

Additional Inherited Members

- Protected Attributes inherited from mariadb::last_error
u32 m_last_error_no
 
std::string m_last_error
 

Detailed Description

Class used to store query and statement results.

Definition at line 69 of file result_set.hpp.

Member Typedef Documentation

◆ map_indexes_t

typedef std::map<std::string, u32> mariadb::result_set::map_indexes_t
private

Definition at line 73 of file result_set.hpp.

Constructor & Destructor Documentation

◆ ~result_set()

result_set::~result_set ( )
virtual

Destructs the result_set and frees all result data.

Definition at line 80 of file result_set.cpp.

References m_raw_binds, m_result_set, m_row, and m_stmt_data.

◆ result_set() [1/2]

result_set::result_set ( connection conn)
explicitprivate

Create result_set from connection.

Definition at line 21 of file result_set.cpp.

References i, m_field_count, m_fields, m_indexes, and m_result_set.

◆ result_set() [2/2]

result_set::result_set ( connection conn,
const statement_data_ref stmt 
)
explicitprivate

Create result_set from statement.

Definition at line 39 of file result_set.cpp.

References mariadb::connection::account(), i, m_binds, m_field_count, m_fields, m_indexes, m_raw_binds, m_result_set, m_row, and STMT_ERROR.

Member Function Documentation

◆ check_row_fetched()

void result_set::check_row_fetched ( ) const
private

Throws if the result set was created, but no row was ever fetched (using next())

Definition at line 210 of file result_set.cpp.

References m_was_fetched.

◆ check_type()

void result_set::check_type ( u32  index,
value::type  requested 
) const
private

◆ column_count()

u32 result_set::column_count ( ) const

Get the count of columns contained in this result_set.

Returns
Count of columns

Definition at line 92 of file result_set.cpp.

References m_field_count.

◆ column_index()

u32 result_set::column_index ( const std::string &  name) const

Get the index of a column by column-name (case sensitive)

Parameters
nameName of column to look up
Returns
Index of column if found, maximum uint32 if not found

Definition at line 164 of file result_set.cpp.

References i, and m_indexes.

◆ column_name()

const std::string result_set::column_name ( u32  index)

Gets the name of a column by index.

Parameters
indexIndex of the column to get the name for
Returns
String representing column name

Definition at line 158 of file result_set.cpp.

References utf8::index(), m_field_count, and m_fields.

◆ column_size()

unsigned long result_set::column_size ( u32  index) const

Gets the size of the data contained in the column at index.

Parameters
indexIndex of the column to get the size for
Returns
Size of the column contents for the currently active row

Definition at line 172 of file result_set.cpp.

References utf8::index(), m_binds, m_field_count, m_lengths, and m_stmt_data.

◆ column_type()

value::type result_set::column_type ( u32  index) const

◆ MAKE_GETTER_DECL() [1/19]

mariadb::result_set::MAKE_GETTER_DECL ( blob  ,
stream_ref   
)

◆ MAKE_GETTER_DECL() [2/19]

mariadb::result_set::MAKE_GETTER_DECL ( data  ,
data_ref   
)

◆ MAKE_GETTER_DECL() [3/19]

mariadb::result_set::MAKE_GETTER_DECL ( date  ,
date_time   
)

◆ MAKE_GETTER_DECL() [4/19]

mariadb::result_set::MAKE_GETTER_DECL ( date_time  ,
date_time   
)

◆ MAKE_GETTER_DECL() [5/19]

mariadb::result_set::MAKE_GETTER_DECL ( time  ,
time   
)

◆ MAKE_GETTER_DECL() [6/19]

mariadb::result_set::MAKE_GETTER_DECL ( decimal  ,
decimal   
)

◆ MAKE_GETTER_DECL() [7/19]

mariadb::result_set::MAKE_GETTER_DECL ( string  ,
std::string   
)

◆ MAKE_GETTER_DECL() [8/19]

mariadb::result_set::MAKE_GETTER_DECL ( boolean  ,
bool   
)

◆ MAKE_GETTER_DECL() [9/19]

mariadb::result_set::MAKE_GETTER_DECL ( unsigned8  ,
u8   
)

◆ MAKE_GETTER_DECL() [10/19]

mariadb::result_set::MAKE_GETTER_DECL ( signed8  ,
s8   
)

◆ MAKE_GETTER_DECL() [11/19]

mariadb::result_set::MAKE_GETTER_DECL ( unsigned16  ,
u16   
)

◆ MAKE_GETTER_DECL() [12/19]

mariadb::result_set::MAKE_GETTER_DECL ( signed16  ,
s16   
)

◆ MAKE_GETTER_DECL() [13/19]

mariadb::result_set::MAKE_GETTER_DECL ( unsigned32  ,
u32   
)

◆ MAKE_GETTER_DECL() [14/19]

mariadb::result_set::MAKE_GETTER_DECL ( signed32  ,
s32   
)

◆ MAKE_GETTER_DECL() [15/19]

mariadb::result_set::MAKE_GETTER_DECL ( unsigned64  ,
u64   
)

◆ MAKE_GETTER_DECL() [16/19]

mariadb::result_set::MAKE_GETTER_DECL ( signed64  ,
s64   
)

◆ MAKE_GETTER_DECL() [17/19]

mariadb::result_set::MAKE_GETTER_DECL ( float  ,
f32   
)

◆ MAKE_GETTER_DECL() [18/19]

mariadb::result_set::MAKE_GETTER_DECL ( double  ,
f64   
)

◆ MAKE_GETTER_DECL() [19/19]

mariadb::result_set::MAKE_GETTER_DECL ( is_null  ,
bool   
)

◆ next()

bool result_set::next ( )

Fetch next row from result_set.

Returns
True if next row exists

Definition at line 186 of file result_set.cpp.

References m_lengths, m_result_set, m_row, m_stmt_data, and m_was_fetched.

Referenced by set_row_index().

◆ row_count()

u64 result_set::row_count ( ) const

Gets the number of rows in this result.

Returns
Number of rows in result_set

Definition at line 204 of file result_set.cpp.

References m_result_set, and m_stmt_data.

◆ row_index()

u64 result_set::row_index ( ) const

Gets the row index of the currently selected row.

Returns
Index of current row

Definition at line 198 of file result_set.cpp.

References m_result_set, and m_stmt_data.

◆ set_row_index()

bool result_set::set_row_index ( u64  index)

Set the current row index in result_set (seek to result).

Also immediately fetches the selected row.

Parameters
indexIndex of row to select
Returns
True if row could be seeked to and fetched.

Definition at line 178 of file result_set.cpp.

References m_result_set, m_stmt_data, and next().

Friends And Related Function Documentation

◆ connection

friend class connection
friend

Definition at line 70 of file result_set.hpp.

◆ statement

friend class statement
friend

Definition at line 71 of file result_set.hpp.

Member Data Documentation

◆ m_binds

std::vector<bind_ref> mariadb::result_set::m_binds
private

Definition at line 205 of file result_set.hpp.

Referenced by column_size(), and result_set().

◆ m_field_count

u32 mariadb::result_set::m_field_count
private

Definition at line 214 of file result_set.hpp.

Referenced by column_count(), column_name(), column_size(), column_type(), and result_set().

◆ m_fields

MYSQL_FIELD* mariadb::result_set::m_fields
private

Definition at line 198 of file result_set.hpp.

Referenced by column_name(), column_type(), and result_set().

◆ m_indexes

map_indexes_t mariadb::result_set::m_indexes
private

Definition at line 209 of file result_set.hpp.

Referenced by column_index(), and result_set().

◆ m_lengths

long unsigned int* mariadb::result_set::m_lengths
private

Definition at line 211 of file result_set.hpp.

Referenced by column_size(), and next().

◆ m_raw_binds

MYSQL_BIND* mariadb::result_set::m_raw_binds
private

◆ m_result_set

MYSQL_RES* mariadb::result_set::m_result_set
private

Definition at line 196 of file result_set.hpp.

Referenced by next(), result_set(), row_count(), row_index(), set_row_index(), and ~result_set().

◆ m_row

MYSQL_ROW mariadb::result_set::m_row
private

Definition at line 200 of file result_set.hpp.

Referenced by next(), result_set(), and ~result_set().

◆ m_stmt_data

statement_data_ref mariadb::result_set::m_stmt_data
private

Definition at line 207 of file result_set.hpp.

Referenced by column_size(), next(), row_count(), row_index(), set_row_index(), and ~result_set().

◆ m_was_fetched

bool mariadb::result_set::m_was_fetched
private

Definition at line 216 of file result_set.hpp.

Referenced by check_row_fetched(), and next().


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