Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

dbserver_impl Class Reference

implements most of the methods of the dbserver interface More...

#include <db.h>

Inheritance diagram for dbserver_impl:

dbserver terimber_thread_employer terimber_log_helper terimber_log mysql_dbserver odbc_dbserver orcl_dbserver

List of all members.

Public Member Functions

virtual size_t get_ident () const
 returns current ident
virtual bool is_ready () const
 returns current state for asynchronous actions
virtual size_t get_code () const
 returns error code
virtual const char * get_error () const
 returns error description, NULL will be returned if there are no errors
virtual bool connect (bool trusted_connection, const char *connect_string)
 establishes db connection the syntax of the connection string depends on db server type
virtual bool disconnect ()
 closes connection
virtual bool start_transaction ()
 starts transaction
virtual bool commit ()
 commits transaction
virtual bool rollback ()
 rolls back transaction
virtual bool is_connect () const
 returns the connection status
virtual bool is_in_transaction () const
 returns the transaction status
virtual bool is_connect_alive ()
 checks if ythe connection is alive or not
virtual bool resize_params (size_t size)
 resizes the parameters
virtual size_t get_param_count () const
 gets parameter count
virtual dbtypes get_param_type (size_t index) const
 returns the virtual db terimber type
virtual db_param_type get_param_in_out (size_t index) const
 returns the in/out
virtual bool get_param_is_null (size_t index) const
 returns the nullable - database specific
virtual bool get_param_as_bool (size_t index) const
 returns param value as boolean
virtual sb1_t get_param_as_char (size_t index) const
 returns param value as char
virtual ub1_t get_param_as_byte (size_t index) const
 returns param value as byte
virtual sb2_t get_param_as_short (size_t index) const
 returns param value as short
virtual ub2_t get_param_as_word (size_t index) const
 returns param value as word
virtual sb4_t get_param_as_long (size_t index) const
 returns param value as long
virtual ub4_t get_param_as_dword (size_t index) const
 returns param value as dword
virtual float get_param_as_float (size_t index) const
 returns param value as float
virtual double get_param_as_double (size_t index) const
 returns param value as double
virtual sb8_t get_param_as_long64 (size_t index) const
 returns param value as long64
virtual ub8_t get_param_as_dword64 (size_t index) const
 returns param value as dword64
virtual bool get_param_as_guid (size_t index, guid_t &val) const
 returns param value as guid for high performance we are using reference
virtual const char * get_param_as_numeric (size_t index, char delimeter) const
 returns param value as numeric delimeter defines the desirable delimeter sign
virtual const char * get_param_as_decimal (size_t index, char delimeter) const
 returns param value as decimal delimeter defines the desirable delimeter sign
virtual bool get_param_as_date (size_t index, ub4_t &year, ub1_t &month, ub1_t &day, ub1_t &hour, ub1_t &minute, ub1_t &second, ub2_t &millisec, ub1_t &wday, ub2_t &yday) const
 returns param value as date to avoid confusions with different date format functions returns parsed date
virtual const char * get_param_as_string (size_t index) const
 returns param value as string NB!!! return value can be allocated on a temporary allocator
virtual const wchar_tget_param_as_wstring (size_t index) const
 returns param value as wide string NB!!! return value can be allocated on a temporary allocator
virtual const ub1_tget_param_as_binary (size_t index, size_t &len) const
 returns param value as binary NB!!! return value can be allocated on a temporary allocator
virtual const ub1_tget_param_as_binary_ptr (size_t index) const
 returns param value as binary pointer the format of buffer is as following first size_t bytes the length of the rest of buffer, which contains the raw byte data NB!!! return value can be allocated on a temporary allocator
virtual bool set_param_as_null (size_t index, db_param_type in_out, dbtypes type)
 sets parameter as null
virtual bool set_param_as_bool (size_t index, db_param_type in_out, bool val)
 sets parameter as boolean
virtual bool set_param_as_char (size_t index, db_param_type in_out, sb1_t val)
 sets parameter as char
virtual bool set_param_as_byte (size_t index, db_param_type in_out, ub1_t val)
 sets parameter as byte
virtual bool set_param_as_short (size_t index, db_param_type in_out, sb2_t val)
 sets parameter as short
virtual bool set_param_as_word (size_t index, db_param_type in_out, ub2_t val)
 sets parameter as word
virtual bool set_param_as_long (size_t index, db_param_type in_out, sb4_t val)
 sets parameter as long
virtual bool set_param_as_dword (size_t index, db_param_type in_out, ub4_t val)
 sets parameter as dword
virtual bool set_param_as_float (size_t index, db_param_type in_out, float val)
 sets parameter as float
virtual bool set_param_as_double (size_t index, db_param_type in_out, double val)
 sets parameter as double
virtual bool set_param_as_long64 (size_t index, db_param_type in_out, sb8_t val)
 sets parameter as long64
virtual bool set_param_as_dword64 (size_t index, db_param_type in_out, ub8_t val)
 sets parameter as dword64
virtual bool set_param_as_guid (size_t index, db_param_type in_out, const guid_t &val)
 sets parameter as guid
virtual bool set_param_as_numeric (size_t index, db_param_type in_out, const char *val, char delimeter)
 sets parameter as numeric -1223456.7894 - delimeter here "." -1223456,7894 - delimeter here ","
virtual bool set_param_as_decimal (size_t index, db_param_type in_out, const char *val, char delimeter)
 sets parameter as decimal
virtual bool set_param_as_date (size_t index, db_param_type in_out, ub4_t year, ub1_t month, ub1_t day, ub1_t hour, ub1_t minute, ub1_t second, ub2_t millisec)
 sets parameter as date date from A.C. year > 0
virtual bool set_param_as_string (size_t index, db_param_type in_out, const char *val, size_t len, size_t max_len=0)
 sets parameter as string
virtual bool set_param_as_string_ptr (size_t index, const char *val)
 sets parameter as string pointer to avoid copying already allocated memory, the only pointer can be used be careful! the caller is responsible for the life time of the provided pointer, which has to be valid until the sql statment is executed.
virtual bool set_param_as_wstring (size_t index, db_param_type in_out, const wchar_t *val, size_t len, size_t max_len=0)
 sets parameter as wide string
virtual bool set_param_as_wstring_ptr (size_t index, const wchar_t *val)
 sets parameter as wide string pointer to avoid copying already allocated memory, the only pointer can be used be careful! the caller is responsible for the life time of tee provided pointer, which has to be valid until the sql statment is executed.
virtual bool set_param_as_binary (size_t index, db_param_type in_out, const ub1_t *val, size_t len, size_t max_len=0)
 sets parameter as binary val points to the valid buffer of raw byte of "len" length
virtual bool set_param_as_binary_ptr (size_t index, const ub1_t *val)
 sets parameter as binary pointer to avoid copying already allocated huge memory, only the pointer can be used be careful! the caller is responsible for the life time of the provided pointer, which has to be valid until the sql statment is executed. it is supposed to workonly for input parameters, not for output or input/output ones the format of the buffer must be as follows first size_t bytes the length of the rest of buffer, which contains the raw byte data
virtual size_t get_column_count () const
 gets column count
virtual dbtypes get_column_type (size_t index) const
 returns the terimber db type
virtual const char * get_column_name (size_t index) const
 returns the name
virtual bool get_column_nullable (size_t index) const
 returns the nullable - database specific
virtual size_t get_column_scale (size_t index) const
 returns the scale
virtual size_t get_column_precision (size_t index) const
 returns the precision
virtual size_t get_column_max_length (size_t index) const
 returns the length of parameter (only for output binders)
virtual size_t get_row_count () const
 gets row count
virtual void reset () const
 resets internal cursor next to the last element
virtual bool next () const
 tries to find the next row, after reset it goes to the first row
virtual bool prev () const
 tries to find the previous row
virtual bool get_value_is_null (size_t index) const
 checks if value is null returns param value
virtual bool get_value_as_bool (size_t index) const
 gets value as boolean
virtual sb1_t get_value_as_char (size_t index) const
 gets value as char
virtual ub1_t get_value_as_byte (size_t index) const
 gets value as byte
virtual sb2_t get_value_as_short (size_t index) const
 gets value as short
virtual ub2_t get_value_as_word (size_t index) const
 gets value as word
virtual sb4_t get_value_as_long (size_t index) const
 gets value as long
virtual ub4_t get_value_as_dword (size_t index) const
 gets value as dword
virtual float get_value_as_float (size_t index) const
 gets value as float
virtual double get_value_as_double (size_t index) const
 gets value as double
virtual sb8_t get_value_as_long64 (size_t index) const
 gets value as long64
virtual ub8_t get_value_as_dword64 (size_t index) const
 gets value as dword64
virtual bool get_value_as_guid (size_t index, guid_t &val) const
 gets value as guid for high performance we are using reference
virtual const char * get_value_as_numeric (size_t index, char delimeter) const
 gets value as numeric delimeter defines the desirable delimeter sign
virtual const char * get_value_as_decimal (size_t index, char delimeter) const
 gets value as decimal delimeter defines the desirable delimeter sign
virtual bool get_value_as_date (size_t index, ub4_t &year, ub1_t &month, ub1_t &day, ub1_t &hour, ub1_t &minute, ub1_t &second, ub2_t &millisec, ub1_t &wday, ub2_t &yday) const
 gets value as date to avoid confusions with different date format functions returns parsed date
virtual const char * get_value_as_string (size_t index) const
 gets value as string NB!!! return value can be allocated on a temporary allocator
virtual const wchar_tget_value_as_wstring (size_t index) const
 gets value as wide string NB!!! return value can be allocated on a temporary allocator
virtual const ub1_tget_value_as_binary (size_t index, size_t &len) const
 gets value as binary returns pointer to the raw bytes size of bytes is put to len
virtual const ub1_tget_value_as_binary_ptr (size_t index) const
 gets value as binary pointer for reusing only the format of buffer is as following first size_t bytes the length of the rest of buffer, which contains the raw byte data
virtual bool is_open_sql () const
 checks if sql is open
virtual bool open_sql (bool async, const char *sql)
 executes parameterized sql statement with recordset result
virtual bool exec_sql (bool async, const char *sql)
 executes parameterized sql statement without result
virtual bool open_proc (bool async, const char *name)
 executes stored procedure with recordset result
virtual bool exec_proc (bool async, const char *name)
 executes stored procedure without result
virtual bool fetch_data (bool async, size_t start_row, size_t num_rows, bool forward)
 fetches data and returns recordset
virtual bool close_sql ()
 close sql - free allocated resources
virtual bool interrupt_request ()
 interrupts asychronous request
virtual bool set_quote (char quote)
 the syntax of sql statement with binders must be understandable for internal sql processor therefore it should look like select * from table where pk = :pk here ':' char is an identificator of the parameter with the name "pk" function set_quote allows to change this identificator to the preferable one
virtual void set_callback (async_db_notify *target)
 sets the callback function for asynchronous actions
virtual void remove_callback (async_db_notify *target)
 removes the callback function for asynchronous actions
virtual bool param_bulk_store ()
 current set of parameters previously set by set_param_* functions will be moved to the bulk parameters list the current parameters set will have the same values, but will not participate in bulk operations moreover if the next call set_param_* function will change the type - all bulk parameters will be deleted.
virtual bool param_bulk_remove ()
 removes the last stored parameter
virtual bool param_bulk_remove_all ()
 removes all

Static Public Member Functions

static vt_types convert_types (dbtypes type)
 converts db terimber type into virtual terimber type

Protected Types

enum  action {
  ACTION_NONE = 0, ACTION_OPEN_SQL, ACTION_OPEN_PROC, ACTION_EXEC_SQL,
  ACTION_EXEC_PROC, ACTION_FETCH, ACTION_OPEN_SQL_ASYNC, ACTION_OPEN_PROC_ASYNC,
  ACTION_EXEC_SQL_ASYNC, ACTION_EXEC_PROC_ASYNC, ACTION_FETCH_ASYNC
}
 predifined actions More...

Protected Member Functions

 dbserver_impl (size_t ident)
 constructor
virtual ~dbserver_impl ()
 destructor
virtual void v_connect (bool trusted_connection, const char *connection_string)=0
 establishes connection to db
virtual void v_disconnect ()=0
 closes connection
virtual void v_start_transaction ()=0
 starts transaction
virtual void v_commit ()=0
 commits transaction
virtual void v_rollback ()=0
 rolls back transaction
virtual bool v_is_connect_alive ()=0
 checks if the connection is alive
bool _is_connect () const
 inline functions
bool _is_in_transaction () const
 checks the transaction state
bool _is_open_sql () const
 checks open status
void _get_number_params ()
 gets number params in query
void _rebind_params ()
 rebinds all params
void _bind_params ()
 binds all params
void _bind_columns ()
 binds all columns
void _get_columns_info ()
 gets columns info
virtual void v_before_execute ()=0
 pure virtual functions
virtual void v_after_execute ()=0
 calls additional function after executing the sql statement
virtual void v_execute ()=0
 executes SQL expression
virtual void v_close ()=0
 closes opened query
virtual void v_fetch ()=0
 fetches block of rows
virtual void v_replace_quote ()=0
 replaces quote to the available sign for native drive
virtual void v_bind_one_param (size_t index)=0
 binds one param by index
virtual void v_before_bind_columns ()=0
 before bind columns sometimes we got db specific
virtual void v_bind_one_column (size_t index)=0
 binds one column by index
virtual size_t v_get_number_columns ()=0
 gets number columns in query
virtual void v_convert_one_value (size_t row, size_t col, terimber_db_value &val)=0
 converts one field value to variant buffer
virtual void v_get_one_column_info (size_t index)=0
 gets one column info from native driver
virtual void v_form_sql_string ()=0
 forms SQL expression depending on type selected and native driver
virtual void v_rebind_one_param (size_t index)=0
 rebinds one param for input/output or output params
virtual void v_interrupt_async ()=0
 terminates asynchronous action
virtual dbtypes v_native_type_to_client_type (size_t native_type)=0
 converts types
bool v_has_job (size_t ident, void *user_data)
 checks for job
void v_do_job (size_t ident, void *user_data)
 does the real job
virtual void _notify_async (bool noerrors, size_t ident)
 notifies subscribers
action get_action () const
 returns current action
module_state get_state () const
 returns the current state

Protected Attributes

mem_pool_t _manager
 memory allocator pool
byte_allocator_temp_allocator
 temporary memory allocator
mutex _mtx
 multithreaded mutex
size_t _ident
 server ident
size_t _code
 code of the last error
string_t _error
 last error description
byte_allocator_columns_allocator
 columns allocator
byte_allocator_data_allocator
 data allocator
byte_allocator_bulk_allocator
 bulk params allocator
byte_allocator _sql_allocator
 sql allocator
string_t _sql
 SQL statement.
char _quote
 quote
params_t _params
 parameters
bulk_params_t _bulk_params
 bulk parameters
binders_t _cols
 column
recordset_list_t _data
 output recodset
size_t _start_row
 start row for fetching
size_t _requested_rows
 rows to fetch
size_t _fetched_rows
 actually fetched rows
bool _forward
 fetching direction
size_t _bulk_rows
 bulk rows for select

Private Types

typedef list< async_db_notify * > async_db_notify_list_t
 list of callback pointers

Private Member Functions

void _set_connect ()
 sets the connect state
void _set_disconnect ()
 sets the disconnect state
void _set_in_transaction ()
 sets the transaction state on
void _set_out_transaction ()
 sets the transaction state off
void _set_open ()
 sets the open state
void _set_close ()
 sets the close state
void _set_action (action action_)
 sets action
void _set_state (module_state state)
 sets a new state
void _check_connect ()
 makes sure the connection is established
void _check_disconnect ()
 makes sure the connection is closed
void _check_in_transaction ()
 makes sure the transaction is on
void _check_out_transaction ()
 makes sure the transaction is off
void _check_state ()
 checks if the state is OK
void _check_open () const
 checks open state; must be open or exception will be thrown
void _check_close () const
 checks close state; must be closed or exception will be thrown
void _check_action () const
 checks action state; must be none or exception will be thrown
bool _is_asynchronous_action () const
 checks asynchronous action
void _process_sql (const char *sql)
 processes sql statement
void _start_thread ()
 starts thread for asynchronous actions
terimber_xml_value get_param_as_value (size_t index, vt_types type) const
 converts parameter value (if required)
terimber_xml_value get_value_as_value (size_t index, vt_types type) const
 converts column value (if required)
recordset_list_t::iterator get_iter_end () const
 returns end iterator
recordset_list_t::iterator get_iter_begin () const
 returns begin iterator

Private Attributes

bool _connection
 connection state
bool _transaction
 transaction state
bool _trusted
 trusted connecton flag
string_t _connect_string
 connection string
volatile module_state _state
 server state
volatile action _action
 server action
volatile bool _is_open
 open flag
thread _thread
 thread
async_db_notify_list_t _list_callback
 list of callbacks
recordset_list_t::iterator _iter
 recordset part

Classes

class  callback_finder
 class help to find callback More...
class  callback_fire
 class help the stl algorithm for_each to fire events More...


Detailed Description

implements most of the methods of the dbserver interface

Definition at line 323 of file db.h.


Member Typedef Documentation

list of callback pointers

Definition at line 328 of file db.h.


Member Enumeration Documentation

enum dbserver_impl::action [protected]

predifined actions

Enumerator:
ACTION_NONE  nothing to do
ACTION_OPEN_SQL  open sql like --select * from table--
ACTION_OPEN_PROC  open rowset through stored procedure
ACTION_EXEC_SQL  execute sql statment like -- insert into t_names(name) values('John');
ACTION_EXEC_PROC  execute sql statment like -- exec sp_find_id(:id);
ACTION_FETCH  fetch data
ACTION_OPEN_SQL_ASYNC  open sql asynchronousally
ACTION_OPEN_PROC_ASYNC  open proc asynchronousally
ACTION_EXEC_SQL_ASYNC  execute sql asynchronousally
ACTION_EXEC_PROC_ASYNC  execute proc asynchronousally
ACTION_FETCH_ASYNC  fetch data asynchronousally

Definition at line 375 of file db.h.


Constructor & Destructor Documentation

dbserver_impl::dbserver_impl ( size_t  ident  )  [protected]

constructor

Parameters:
ident  server ident

Definition at line 396 of file db.cpp.

References _bulk_allocator, _columns_allocator, _data_allocator, _manager, _temp_allocator, and pool< C >::loan_object().

dbserver_impl::~dbserver_impl (  )  [protected, virtual]


Member Function Documentation

size_t dbserver_impl::get_ident (  )  const [virtual]

returns current ident

base methods

Implements dbserver.

Definition at line 440 of file db.cpp.

References _ident.

bool dbserver_impl::is_ready (  )  const [virtual]

returns current state for asynchronous actions

Implements dbserver.

Definition at line 446 of file db.cpp.

References get_state(), and STATE_OK.

size_t dbserver_impl::get_code (  )  const [virtual]

returns error code

Implements dbserver.

Definition at line 452 of file db.cpp.

References _code.

const char * dbserver_impl::get_error (  )  const [virtual]

returns error description, NULL will be returned if there are no errors

Implements dbserver.

Definition at line 458 of file db.cpp.

References _error.

bool dbserver_impl::connect ( bool  trusted_connection,
const char *  connect_string 
) [virtual]

establishes db connection the syntax of the connection string depends on db server type

db connection methods

Parameters:
trusted_connection  trusted connection flag
connect_string  connection string

Implements dbserver.

Definition at line 468 of file db.cpp.

References _check_disconnect(), _connect_string, _set_connect(), _trusted, DB_CATCH_DB, DB_TRY, en_log_info, terimber_log::format_logging(), and v_connect().

bool dbserver_impl::disconnect (  )  [virtual]

bool dbserver_impl::start_transaction (  )  [virtual]

starts transaction

Implements dbserver.

Definition at line 497 of file db.cpp.

References _check_out_transaction(), _set_in_transaction(), DB_CATCH_DB, DB_TRY, and v_start_transaction().

bool dbserver_impl::commit (  )  [virtual]

commits transaction

Implements dbserver.

Definition at line 508 of file db.cpp.

References _check_in_transaction(), _set_out_transaction(), DB_CATCH_DB, DB_TRY, and v_commit().

bool dbserver_impl::rollback (  )  [virtual]

rolls back transaction

Implements dbserver.

Definition at line 519 of file db.cpp.

References _check_in_transaction(), _set_out_transaction(), DB_CATCH_DB, DB_TRY, and v_rollback().

bool dbserver_impl::is_connect (  )  const [virtual]

returns the connection status

Implements dbserver.

Definition at line 530 of file db.cpp.

References _is_connect().

bool dbserver_impl::is_in_transaction (  )  const [virtual]

returns the transaction status

Implements dbserver.

Definition at line 537 of file db.cpp.

References _is_in_transaction().

bool dbserver_impl::is_connect_alive (  )  [virtual]

checks if ythe connection is alive or not

Implements dbserver.

Definition at line 544 of file db.cpp.

References v_is_connect_alive().

bool dbserver_impl::resize_params ( size_t  size  )  [virtual]

resizes the parameters

sql methods

Parameters:
size  number of parameters

Implements dbserver.

Definition at line 557 of file db.cpp.

References _bulk_params, _code, _error, _params, list< T >::clear(), base_list< T >::empty(), exception::get_code(), vector< T >::resize(), base_vector< T >::size(), and exception::what().

size_t dbserver_impl::get_param_count (  )  const [virtual]

gets parameter count

Implements dbserver.

Definition at line 584 of file db.cpp.

References _params, and base_vector< T >::size().

dbtypes dbserver_impl::get_param_type ( size_t  index  )  const [virtual]

returns the virtual db terimber type

Parameters:
index  parameter index

Implements dbserver.

Definition at line 593 of file db.cpp.

References _params, db_unknown, and base_vector< T >::size().

db_param_type dbserver_impl::get_param_in_out ( size_t  index  )  const [virtual]

returns the in/out

Parameters:
index  parameter index

Implements dbserver.

Definition at line 602 of file db.cpp.

References _params, db_param_unknown, and base_vector< T >::size().

bool dbserver_impl::get_param_is_null ( size_t  index  )  const [virtual]

returns the nullable - database specific

Parameters:
index  parameter index

Implements dbserver.

Definition at line 611 of file db.cpp.

References _params, and base_vector< T >::size().

bool dbserver_impl::get_param_as_bool ( size_t  index  )  const [virtual]

returns param value as boolean

if index out of range then zero will be return the best practice to check type before call gets value functions

Parameters:
index  parameter index

Implements dbserver.

Definition at line 621 of file db.cpp.

References _terimber_xml_value_::boolVal, get_param_as_value(), and vt_bool.

sb1_t dbserver_impl::get_param_as_char ( size_t  index  )  const [virtual]

returns param value as char

Parameters:
index  parameter index

Implements dbserver.

Definition at line 627 of file db.cpp.

References _terimber_xml_value_::cVal, get_param_as_value(), and vt_sb1.

ub1_t dbserver_impl::get_param_as_byte ( size_t  index  )  const [virtual]

returns param value as byte

Parameters:
index  parameter index

Implements dbserver.

Definition at line 633 of file db.cpp.

References _terimber_xml_value_::bVal, get_param_as_value(), and vt_ub1.

sb2_t dbserver_impl::get_param_as_short ( size_t  index  )  const [virtual]

returns param value as short

Parameters:
index  parameter index

Implements dbserver.

Definition at line 639 of file db.cpp.

References get_param_as_value(), _terimber_xml_value_::iVal, and vt_sb2.

ub2_t dbserver_impl::get_param_as_word ( size_t  index  )  const [virtual]

returns param value as word

Parameters:
index  parameter index

Implements dbserver.

Definition at line 645 of file db.cpp.

References get_param_as_value(), _terimber_xml_value_::uiVal, and vt_ub2.

sb4_t dbserver_impl::get_param_as_long ( size_t  index  )  const [virtual]

returns param value as long

Parameters:
index  parameter index

Implements dbserver.

Definition at line 651 of file db.cpp.

References get_param_as_value(), _terimber_xml_value_::lVal, and vt_sb4.

ub4_t dbserver_impl::get_param_as_dword ( size_t  index  )  const [virtual]

returns param value as dword

Parameters:
index  parameter index

Implements dbserver.

Definition at line 657 of file db.cpp.

References get_param_as_value(), _terimber_xml_value_::ulVal, and vt_ub4.

float dbserver_impl::get_param_as_float ( size_t  index  )  const [virtual]

returns param value as float

Parameters:
index  parameter index

Implements dbserver.

Definition at line 663 of file db.cpp.

References _terimber_xml_value_::fltVal, get_param_as_value(), and vt_float.

double dbserver_impl::get_param_as_double ( size_t  index  )  const [virtual]

returns param value as double

Parameters:
index  parameter index

Implements dbserver.

Definition at line 669 of file db.cpp.

References _terimber_xml_value_::dblVal, get_param_as_value(), and vt_double.

sb8_t dbserver_impl::get_param_as_long64 ( size_t  index  )  const [virtual]

returns param value as long64

Parameters:
index  parameter index

Implements dbserver.

Definition at line 680 of file db.cpp.

References get_param_as_value(), _terimber_xml_value_::intVal, and vt_sb8.

ub8_t dbserver_impl::get_param_as_dword64 ( size_t  index  )  const [virtual]

returns param value as dword64

Parameters:
index  parameter index

Implements dbserver.

Definition at line 691 of file db.cpp.

References get_param_as_value(), _terimber_xml_value_::uintVal, and vt_ub8.

bool dbserver_impl::get_param_as_guid ( size_t  index,
guid_t val 
) const [virtual]

returns param value as guid for high performance we are using reference

Parameters:
index  parameter index
val  [out] value

Implements dbserver.

Definition at line 703 of file db.cpp.

References get_param_as_value(), _terimber_xml_value_::guidVal, and vt_guid.

const char * dbserver_impl::get_param_as_numeric ( size_t  index,
char  delimeter 
) const [virtual]

returns param value as numeric delimeter defines the desirable delimeter sign

Parameters:
index  parameter index
delimeter  delimeter

Implements dbserver.

Definition at line 717 of file db.cpp.

References _temp_allocator, byte_allocator::allocate(), _terimber_xml_value_::bufVal, numeric::format(), get_param_as_value(), numeric::is_zero(), numeric::parse_orcl(), numeric::precision(), numeric::scale(), numeric::sign(), and vt_numeric.

Referenced by get_param_as_decimal().

const char * dbserver_impl::get_param_as_decimal ( size_t  index,
char  delimeter 
) const [virtual]

returns param value as decimal delimeter defines the desirable delimeter sign

Parameters:
index  parameter index
delimeter  delimeter

Implements dbserver.

Definition at line 737 of file db.cpp.

References get_param_as_numeric().

bool dbserver_impl::get_param_as_date ( size_t  index,
ub4_t year,
ub1_t month,
ub1_t day,
ub1_t hour,
ub1_t minute,
ub1_t second,
ub2_t millisec,
ub1_t wday,
ub2_t yday 
) const [virtual]

returns param value as date to avoid confusions with different date format functions returns parsed date

Parameters:
index  parameter index
year  [out] year [0-1000000] from 1 A.D.
month  [out] month [1-12]
day  [out] day [1-31]
hour  [out] hour [0-23]
minute  [out] minute [0-59]
second  [out] second [0-59]
millisec  [out] millisecond [0-999]
wday  [out] day of week [1-7]
yday  [out] day of year [1-366]

Implements dbserver.

Definition at line 744 of file db.cpp.

References date::convert_from(), get_param_as_value(), _terimber_xml_value_::intVal, and vt_date.

const char * dbserver_impl::get_param_as_string ( size_t  index  )  const [virtual]

returns param value as string NB!!! return value can be allocated on a temporary allocator

Parameters:
index  parameter index

Implements dbserver.

Definition at line 759 of file db.cpp.

References get_param_as_value(), _terimber_xml_value_::strVal, and vt_string.

const wchar_t * dbserver_impl::get_param_as_wstring ( size_t  index  )  const [virtual]

returns param value as wide string NB!!! return value can be allocated on a temporary allocator

Parameters:
index  parameter index

Implements dbserver.

Definition at line 766 of file db.cpp.

References get_param_as_value(), vt_wstring, and _terimber_xml_value_::wstrVal.

const ub1_t * dbserver_impl::get_param_as_binary ( size_t  index,
size_t &  len 
) const [virtual]

returns param value as binary NB!!! return value can be allocated on a temporary allocator

Parameters:
index  parameter index
len  [out] the binary length

Implements dbserver.

Definition at line 773 of file db.cpp.

References _terimber_xml_value_::bufVal, get_param_as_value(), and vt_binary.

const ub1_t * dbserver_impl::get_param_as_binary_ptr ( size_t  index  )  const [virtual]

returns param value as binary pointer the format of buffer is as following first size_t bytes the length of the rest of buffer, which contains the raw byte data NB!!! return value can be allocated on a temporary allocator

Parameters:
index  parameter index

Implements dbserver.

Definition at line 784 of file db.cpp.

References _terimber_xml_value_::bufVal, get_param_as_value(), and vt_binary.

bool dbserver_impl::set_param_as_null ( size_t  index,
db_param_type  in_out,
dbtypes  type 
) [virtual]

sets parameter as null

sets parameter values

Parameters:
index  parameter index
in_out  in/out type
type  db type

Implements dbserver.

Definition at line 792 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_bool ( size_t  index,
db_param_type  in_out,
bool  val 
) [virtual]

sets parameter as boolean

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 806 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_bool, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_char ( size_t  index,
db_param_type  in_out,
sb1_t  val 
) [virtual]

sets parameter as char

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 820 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_sb1, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_byte ( size_t  index,
db_param_type  in_out,
ub1_t  val 
) [virtual]

sets parameter as byte

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 834 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_ub1, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_short ( size_t  index,
db_param_type  in_out,
sb2_t  val 
) [virtual]

sets parameter as short

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 848 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_sb2, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_word ( size_t  index,
db_param_type  in_out,
ub2_t  val 
) [virtual]

sets parameter as word

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 862 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_ub2, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_long ( size_t  index,
db_param_type  in_out,
sb4_t  val 
) [virtual]

sets parameter as long

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 876 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_sb4, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_dword ( size_t  index,
db_param_type  in_out,
ub4_t  val 
) [virtual]

sets parameter as dword

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 890 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_sb4, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_float ( size_t  index,
db_param_type  in_out,
float  val 
) [virtual]

sets parameter as float

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 904 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_float, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_double ( size_t  index,
db_param_type  in_out,
double  val 
) [virtual]

sets parameter as double

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 918 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_double, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_long64 ( size_t  index,
db_param_type  in_out,
sb8_t  val 
) [virtual]

sets parameter as long64

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 932 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_sb8, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_dword64 ( size_t  index,
db_param_type  in_out,
ub8_t  val 
) [virtual]

sets parameter as dword64

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 946 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_ub8, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_guid ( size_t  index,
db_param_type  in_out,
const guid_t val 
) [virtual]

sets parameter as guid

Parameters:
index  parameter index
in_out  in/out type
val  value

Implements dbserver.

Definition at line 960 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_guid, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_numeric ( size_t  index,
db_param_type  in_out,
const char *  val,
char  delimeter 
) [virtual]

sets parameter as numeric -1223456.7894 - delimeter here "." -1223456,7894 - delimeter here ","

Parameters:
index  parameter index
in_out  in/out type
val  value
delimeter  delimeter

Implements dbserver.

Definition at line 980 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_decimal, db_numeric, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_decimal ( size_t  index,
db_param_type  in_out,
const char *  val,
char  delimeter 
) [virtual]

sets parameter as decimal

Parameters:
index  parameter index
in_out  in/out type
val  value
delimeter  delimeter

Implements dbserver.

Definition at line 994 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_decimal, db_numeric, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_date ( size_t  index,
db_param_type  in_out,
ub4_t  year,
ub1_t  month,
ub1_t  day,
ub1_t  hour,
ub1_t  minute,
ub1_t  second,
ub2_t  millisec 
) [virtual]

sets parameter as date date from A.C. year > 0

Parameters:
index  parameter index
in_out  in/out type
year  year [0-1000000]
month  month [1-12]
day  day [1-31]
hour  hour [0-23]
minute  minute [0-59]
second  second [0-59]
millisec  millisec [0-999]

Implements dbserver.

Definition at line 1009 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_date, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_string ( size_t  index,
db_param_type  in_out,
const char *  val,
size_t  len,
size_t  max_len = 0 
) [virtual]

sets parameter as string

Parameters:
index  parameter index
in_out  in/out type
val  value
len  string length, -1 for zero terminated string
max_len  optional max length, only for output parameter

Implements dbserver.

Definition at line 1025 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_string, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_string_ptr ( size_t  index,
const char *  val 
) [virtual]

sets parameter as string pointer to avoid copying already allocated memory, the only pointer can be used be careful! the caller is responsible for the life time of the provided pointer, which has to be valid until the sql statment is executed.

Parameters:
index  parameter index
val  value

Implements dbserver.

Definition at line 1045 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_string, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_wstring ( size_t  index,
db_param_type  in_out,
const wchar_t val,
size_t  len,
size_t  max_len = 0 
) [virtual]

sets parameter as wide string

Parameters:
index  parameter index
in_out  in/out type
val  value
len  string length, -1 for zero terminated string
max_len  optional max length, only for output parameter

Implements dbserver.

Definition at line 1061 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_wstring, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_wstring_ptr ( size_t  index,
const wchar_t val 
) [virtual]

sets parameter as wide string pointer to avoid copying already allocated memory, the only pointer can be used be careful! the caller is responsible for the life time of tee provided pointer, which has to be valid until the sql statment is executed.

Parameters:
index  parameter index
val  value

Implements dbserver.

Definition at line 1082 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_wstring, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_binary ( size_t  index,
db_param_type  in_out,
const ub1_t val,
size_t  len,
size_t  max_len = 0 
) [virtual]

sets parameter as binary val points to the valid buffer of raw byte of "len" length

Parameters:
index  parameter index
in_out  in/out type
val  value
len  binary length
max_len  optional max length, only for output parameter

Implements dbserver.

Definition at line 1098 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_binary, base_list< T >::empty(), and base_vector< T >::size().

bool dbserver_impl::set_param_as_binary_ptr ( size_t  index,
const ub1_t val 
) [virtual]

sets parameter as binary pointer to avoid copying already allocated huge memory, only the pointer can be used be careful! the caller is responsible for the life time of the provided pointer, which has to be valid until the sql statment is executed. it is supposed to workonly for input parameters, not for output or input/output ones the format of the buffer must be as follows first size_t bytes the length of the rest of buffer, which contains the raw byte data

Parameters:
index  parameter index
val  value

Implements dbserver.

Definition at line 1121 of file db.cpp.

References _bulk_params, _params, list< T >::clear(), db_binary, base_list< T >::empty(), and base_vector< T >::size().

size_t dbserver_impl::get_column_count (  )  const [virtual]

gets column count

internal columns access

Implements dbserver.

Definition at line 1143 of file db.cpp.

References _cols, and base_vector< T >::size().

dbtypes dbserver_impl::get_column_type ( size_t  index  )  const [virtual]

returns the terimber db type

Implements dbserver.

Definition at line 1151 of file db.cpp.

References _cols, base_vector< T >::begin(), db_unknown, and base_vector< T >::size().

const char * dbserver_impl::get_column_name ( size_t  index  )  const [virtual]

returns the name

Implements dbserver.

Definition at line 1160 of file db.cpp.

References _cols, base_vector< T >::begin(), and base_vector< T >::size().

bool dbserver_impl::get_column_nullable ( size_t  index  )  const [virtual]

returns the nullable - database specific

Implements dbserver.

Definition at line 1170 of file db.cpp.

References _cols, base_vector< T >::begin(), and base_vector< T >::size().

size_t dbserver_impl::get_column_scale ( size_t  index  )  const [virtual]

returns the scale

Implements dbserver.

Definition at line 1180 of file db.cpp.

References _cols, base_vector< T >::begin(), and base_vector< T >::size().

size_t dbserver_impl::get_column_precision ( size_t  index  )  const [virtual]

returns the precision

Implements dbserver.

Definition at line 1190 of file db.cpp.

References _cols, base_vector< T >::begin(), and base_vector< T >::size().

size_t dbserver_impl::get_column_max_length ( size_t  index  )  const [virtual]

returns the length of parameter (only for output binders)

Implements dbserver.

Definition at line 1200 of file db.cpp.

References _cols, base_vector< T >::begin(), and base_vector< T >::size().

size_t dbserver_impl::get_row_count (  )  const [virtual]

gets row count

rowset navigation methods

Implements dbserver.

Definition at line 1214 of file db.cpp.

References _fetched_rows.

void dbserver_impl::reset (  )  const [virtual]

resets internal cursor next to the last element

Implements dbserver.

Definition at line 1223 of file db.cpp.

References _iter, and get_iter_end().

bool dbserver_impl::next (  )  const [virtual]

tries to find the next row, after reset it goes to the first row

Implements dbserver.

Definition at line 1232 of file db.cpp.

References _iter, get_iter_begin(), and get_iter_end().

bool dbserver_impl::prev (  )  const [virtual]

tries to find the previous row

Implements dbserver.

Definition at line 1246 of file db.cpp.

References _iter, get_iter_begin(), and get_iter_end().

bool dbserver_impl::get_value_is_null ( size_t  index  )  const [virtual]

checks if value is null returns param value

const version of current row if index is out of range then zero will be returned the best practice is to check type before call gets value functions

Parameters:
index  column index

Implements dbserver.

Definition at line 1258 of file db.cpp.

References _cols, _iter, get_iter_end(), and base_vector< T >::size().

bool dbserver_impl::get_value_as_bool ( size_t  index  )  const [virtual]

gets value as boolean

Parameters:
index  column index

Implements dbserver.

Definition at line 1264 of file db.cpp.

References _terimber_xml_value_::boolVal, get_value_as_value(), and vt_bool.

sb1_t dbserver_impl::get_value_as_char ( size_t  index  )  const [virtual]

gets value as char

Parameters:
index  column index

Implements dbserver.

Definition at line 1270 of file db.cpp.

References _terimber_xml_value_::cVal, get_value_as_value(), and vt_sb1.

ub1_t dbserver_impl::get_value_as_byte ( size_t  index  )  const [virtual]

gets value as byte

Parameters:
index  column index

Implements dbserver.

Definition at line 1276 of file db.cpp.

References _terimber_xml_value_::bVal, get_value_as_value(), and vt_ub1.

sb2_t dbserver_impl::get_value_as_short ( size_t  index  )  const [virtual]

gets value as short

Parameters:
index  column index

Implements dbserver.

Definition at line 1282 of file db.cpp.

References get_value_as_value(), _terimber_xml_value_::iVal, and vt_sb2.

ub2_t dbserver_impl::get_value_as_word ( size_t  index  )  const [virtual]

gets value as word

Parameters:
index  column index

Implements dbserver.

Definition at line 1288 of file db.cpp.

References get_value_as_value(), _terimber_xml_value_::uiVal, and vt_ub2.

sb4_t dbserver_impl::get_value_as_long ( size_t  index  )  const [virtual]

gets value as long

Parameters:
index  column index

Implements dbserver.

Definition at line 1294 of file db.cpp.

References get_value_as_value(), _terimber_xml_value_::lVal, and vt_sb4.

ub4_t dbserver_impl::get_value_as_dword ( size_t  index  )  const [virtual]

gets value as dword

Parameters:
index  column index

Implements dbserver.

Definition at line 1300 of file db.cpp.

References get_value_as_value(), _terimber_xml_value_::ulVal, and vt_ub4.

float dbserver_impl::get_value_as_float ( size_t  index  )  const [virtual]

gets value as float

Parameters:
index  column index

Implements dbserver.

Definition at line 1306 of file db.cpp.

References _terimber_xml_value_::fltVal, get_value_as_value(), and vt_float.

double dbserver_impl::get_value_as_double ( size_t  index  )  const [virtual]

gets value as double

Parameters:
index  column index

Implements dbserver.

Definition at line 1312 of file db.cpp.

References _terimber_xml_value_::dblVal, get_value_as_value(), and vt_double.

sb8_t dbserver_impl::get_value_as_long64 ( size_t  index  )  const [virtual]

gets value as long64

Parameters:
index  column index

Implements dbserver.

Definition at line 1323 of file db.cpp.

References get_value_as_value(), _terimber_xml_value_::intVal, and vt_sb8.

ub8_t dbserver_impl::get_value_as_dword64 ( size_t  index  )  const [virtual]

gets value as dword64

Parameters:
index  column index

Implements dbserver.

Definition at line 1334 of file db.cpp.

References get_value_as_value(), _terimber_xml_value_::uintVal, and vt_ub8.

bool dbserver_impl::get_value_as_guid ( size_t  index,
guid_t val 
) const [virtual]

gets value as guid for high performance we are using reference

Parameters:
index  column index
val  [out] value

Implements dbserver.

Definition at line 1346 of file db.cpp.

References get_value_as_value(), _terimber_xml_value_::guidVal, and vt_guid.

const char * dbserver_impl::get_value_as_numeric ( size_t  index,
char  delimeter 
) const [virtual]

gets value as numeric delimeter defines the desirable delimeter sign

Parameters:
index  column index
delimeter  delimeter

Implements dbserver.

Definition at line 1359 of file db.cpp.

References _temp_allocator, byte_allocator::allocate(), _terimber_xml_value_::bufVal, numeric::format(), get_value_as_value(), numeric::is_zero(), numeric::parse_orcl(), numeric::precision(), numeric::scale(), numeric::sign(), and vt_numeric.

Referenced by get_value_as_decimal().

const char * dbserver_impl::get_value_as_decimal ( size_t  index,
char  delimeter 
) const [virtual]

gets value as decimal delimeter defines the desirable delimeter sign

Parameters:
index  column index
delimeter  delimeter

Implements dbserver.

Definition at line 1385 of file db.cpp.

References get_value_as_numeric().

bool dbserver_impl::get_value_as_date ( size_t  index,
ub4_t year,
ub1_t month,
ub1_t day,
ub1_t hour,
ub1_t minute,
ub1_t second,
ub2_t millisec,
ub1_t wday,
ub2_t yday 
) const [virtual]

gets value as date to avoid confusions with different date format functions returns parsed date

Parameters:
index  column index
year  [out] year [0-1000000] from 1 A.D.
month  [out] month [1-12]
day  [out] day [1-31]
hour  [out] hour [0-23]
minute  [out] minute [0-59]
second  [out] second [0-59]
millisec  [out] millisecond [0-999]
wday  [out] day of week [1-7]
yday  [out] day of year [1-366]

Implements dbserver.

Definition at line 1392 of file db.cpp.

References date::convert_from(), get_value_as_value(), _terimber_xml_value_::intVal, and vt_date.

const char * dbserver_impl::get_value_as_string ( size_t  index  )  const [virtual]

gets value as string NB!!! return value can be allocated on a temporary allocator

Parameters:
index  column index

Implements dbserver.

Definition at line 1408 of file db.cpp.

References get_value_as_value(), _terimber_xml_value_::strVal, and vt_string.

const wchar_t * dbserver_impl::get_value_as_wstring ( size_t  index  )  const [virtual]

gets value as wide string NB!!! return value can be allocated on a temporary allocator

Parameters:
index  column index

Implements dbserver.

Definition at line 1415 of file db.cpp.

References get_value_as_value(), vt_wstring, and _terimber_xml_value_::wstrVal.

const ub1_t * dbserver_impl::get_value_as_binary ( size_t  index,
size_t &  len 
) const [virtual]

gets value as binary returns pointer to the raw bytes size of bytes is put to len

Parameters:
index  column index
len  [out] binary length

Implements dbserver.

Definition at line 1423 of file db.cpp.

References _terimber_xml_value_::bufVal, get_value_as_value(), and vt_binary.

const ub1_t * dbserver_impl::get_value_as_binary_ptr ( size_t  index  )  const [virtual]

gets value as binary pointer for reusing only the format of buffer is as following first size_t bytes the length of the rest of buffer, which contains the raw byte data

Parameters:
index  column index

Implements dbserver.

Definition at line 1435 of file db.cpp.

References _terimber_xml_value_::bufVal, get_value_as_value(), and vt_binary.

bool dbserver_impl::is_open_sql (  )  const [virtual]

checks if sql is open

checks the state of sql request

Implements dbserver.

Definition at line 1445 of file db.cpp.

References _is_open_sql().

bool dbserver_impl::open_sql ( bool  async,
const char *  sql 
) [virtual]

executes parameterized sql statement with recordset result

Parameters:
async  asychronous executing flag
sql  SQL statement (select)

Implements dbserver.

Definition at line 1453 of file db.cpp.

References _bind_params(), _check_action(), _check_close(), _check_state(), _get_columns_info(), _get_number_params(), _process_sql(), _set_action(), _set_open(), _start_thread(), ACTION_NONE, ACTION_OPEN_SQL, ACTION_OPEN_SQL_ASYNC, DB_CATCH, DB_TRY, and v_execute().

bool dbserver_impl::exec_sql ( bool  async,
const char *  sql 
) [virtual]

executes parameterized sql statement without result

Parameters:
async  asychronous executing flag
sql  SQL statement (DDL, DML except select)

Implements dbserver.

Definition at line 1479 of file db.cpp.

References _bind_params(), _check_action(), _check_close(), _check_state(), _get_number_params(), _process_sql(), _rebind_params(), _set_action(), _set_open(), _start_thread(), ACTION_EXEC_SQL, ACTION_EXEC_SQL_ASYNC, ACTION_NONE, DB_CATCH, DB_TRY, and v_execute().

bool dbserver_impl::open_proc ( bool  async,
const char *  name 
) [virtual]

executes stored procedure with recordset result

Parameters:
async  asychronous executing flag
name  stored procedure name

Implements dbserver.

Definition at line 1505 of file db.cpp.

References _bind_params(), _check_action(), _check_close(), _check_state(), _get_columns_info(), _get_number_params(), _process_sql(), _rebind_params(), _set_action(), _set_open(), _start_thread(), ACTION_NONE, ACTION_OPEN_PROC, ACTION_OPEN_PROC_ASYNC, DB_CATCH, DB_TRY, and v_execute().

bool dbserver_impl::exec_proc ( bool  async,
const char *  name 
) [virtual]

executes stored procedure without result

Parameters:
async  asychronous executing flag
name  stored procedure name

Implements dbserver.

Definition at line 1532 of file db.cpp.

References _bind_params(), _check_action(), _check_close(), _check_state(), _get_number_params(), _process_sql(), _rebind_params(), _set_action(), _set_open(), _start_thread(), ACTION_EXEC_PROC, ACTION_EXEC_PROC_ASYNC, ACTION_NONE, DB_CATCH, DB_TRY, and v_execute().

bool dbserver_impl::fetch_data ( bool  async,
size_t  start_row,
size_t  num_rows,
bool  forward 
) [virtual]

fetches data and returns recordset

/ defines the start row, number of rows and fetch direction

Parameters:
async  asychronous executing flag
start_row  start row, 0 means current
num_rows  rows to fetch
forward  direction

Implements dbserver.

Definition at line 1559 of file db.cpp.

References _bind_columns(), _check_open(), _check_state(), _data, _data_allocator, _fetched_rows, _forward, _iter, _requested_rows, _set_action(), _start_row, _start_thread(), _temp_allocator, ACTION_FETCH, ACTION_FETCH_ASYNC, base_list< T >::clear(), DB_CATCH, DB_TRY, get_iter_end(), byte_allocator::reset(), and v_fetch().

bool dbserver_impl::interrupt_request (  )  [virtual]

interrupts asychronous request

Implements dbserver.

Definition at line 1619 of file db.cpp.

References _set_action(), _set_state(), _thread, ACTION_NONE, thread::cancel_job(), get_state(), STATE_INTERRUPTED, STATE_OK, STATE_WORKING, v_close(), and v_interrupt_async().

bool dbserver_impl::set_quote ( char  quote  )  [virtual]

the syntax of sql statement with binders must be understandable for internal sql processor therefore it should look like select * from table where pk = :pk here ':' char is an identificator of the parameter with the name "pk" function set_quote allows to change this identificator to the preferable one

Parameters:
quote  quote sign

Implements dbserver.

Definition at line 1646 of file db.cpp.

References _mtx, and _quote.

void dbserver_impl::set_callback ( async_db_notify target  )  [virtual]

sets the callback function for asynchronous actions

Parameters:
target  callback pointer

Implements dbserver.

Definition at line 1654 of file db.cpp.

References _list_callback, _mtx, and algorithm::push_back_if().

void dbserver_impl::remove_callback ( async_db_notify target  )  [virtual]

removes the callback function for asynchronous actions

Parameters:
target  callback pointer

Implements dbserver.

Definition at line 1661 of file db.cpp.

References _list_callback, _mtx, and algorithm::remove_if().

bool dbserver_impl::param_bulk_store (  )  [virtual]

current set of parameters previously set by set_param_* functions will be moved to the bulk parameters list the current parameters set will have the same values, but will not participate in bulk operations moreover if the next call set_param_* function will change the type - all bulk parameters will be deleted.

bulk parameter operations - must be supported by SQL server

Implements dbserver.

Definition at line 1885 of file db.cpp.

References _bulk_allocator, _bulk_params, _params, base_list< T >::end(), list< T >::push_back(), list< T >::size(), and base_vector< T >::size().

bool dbserver_impl::param_bulk_remove (  )  [virtual]

bool dbserver_impl::param_bulk_remove_all (  )  [virtual]

vt_types dbserver_impl::convert_types ( dbtypes  type  )  [inline, static]

virtual void dbserver_impl::v_connect ( bool  trusted_connection,
const char *  connection_string 
) [protected, pure virtual]

establishes connection to db

must be overriden database specific

Parameters:
trusted_connection  trusted connection flag
connection_string  connection string

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by connect().

virtual void dbserver_impl::v_disconnect (  )  [protected, pure virtual]

closes connection

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by disconnect().

virtual void dbserver_impl::v_start_transaction (  )  [protected, pure virtual]

starts transaction

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by start_transaction().

virtual void dbserver_impl::v_commit (  )  [protected, pure virtual]

commits transaction

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by commit().

virtual void dbserver_impl::v_rollback (  )  [protected, pure virtual]

rolls back transaction

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by rollback().

virtual bool dbserver_impl::v_is_connect_alive (  )  [protected, pure virtual]

checks if the connection is alive

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by is_connect_alive().

bool dbserver_impl::_is_connect (  )  const [inline, protected]

bool dbserver_impl::_is_in_transaction (  )  const [inline, protected]

checks the transaction state

Definition at line 1117 of file db.h.

References _mtx, and _transaction.

Referenced by _check_in_transaction(), _check_out_transaction(), and is_in_transaction().

bool dbserver_impl::_is_open_sql (  )  const [inline, protected]

void dbserver_impl::_set_connect (  )  [inline, private]

sets the connect state

Definition at line 1134 of file db.h.

References _connection, and _mtx.

Referenced by connect().

void dbserver_impl::_set_disconnect (  )  [inline, private]

sets the disconnect state

Definition at line 1142 of file db.h.

References _connection, and _mtx.

Referenced by disconnect().

void dbserver_impl::_set_in_transaction (  )  [inline, private]

sets the transaction state on

Definition at line 1150 of file db.h.

References _mtx, and _transaction.

Referenced by start_transaction().

void dbserver_impl::_set_out_transaction (  )  [inline, private]

sets the transaction state off

Definition at line 1158 of file db.h.

References _mtx, and _transaction.

Referenced by commit(), and rollback().

void dbserver_impl::_set_open (  )  [inline, private]

sets the open state

Definition at line 1166 of file db.h.

References _is_open, and _mtx.

Referenced by exec_proc(), exec_sql(), open_proc(), open_sql(), and v_do_job().

void dbserver_impl::_set_close (  )  [inline, private]

sets the close state

Definition at line 1174 of file db.h.

References _is_open, and _mtx.

Referenced by close_sql().

void dbserver_impl::_set_action ( action  action_  )  [inline, private]

sets action

Parameters:
action_  new action

Definition at line 1182 of file db.h.

References _action, and _mtx.

Referenced by close_sql(), exec_proc(), exec_sql(), fetch_data(), interrupt_request(), open_proc(), open_sql(), and v_do_job().

void dbserver_impl::_set_state ( module_state  state  )  [inline, private]

sets a new state

Parameters:
state  new state

Definition at line 1191 of file db.h.

References _mtx, and _state.

Referenced by _start_thread(), close_sql(), interrupt_request(), and v_do_job().

void dbserver_impl::_get_number_params (  )  [protected]

gets number params in query

Definition at line 1669 of file db.cpp.

References v_form_sql_string(), and v_replace_quote().

Referenced by exec_proc(), exec_sql(), open_proc(), and open_sql().

void dbserver_impl::_rebind_params (  )  [protected]

rebinds all params

Definition at line 1691 of file db.cpp.

References _params, base_vector< T >::size(), v_after_execute(), and v_rebind_one_param().

Referenced by exec_proc(), exec_sql(), open_proc(), and v_do_job().

void dbserver_impl::_bind_params (  )  [protected]

binds all params

Definition at line 1678 of file db.cpp.

References _params, base_vector< T >::size(), v_before_execute(), and v_bind_one_param().

Referenced by exec_proc(), exec_sql(), open_proc(), and open_sql().

void dbserver_impl::_bind_columns (  )  [protected]

binds all columns

Definition at line 1706 of file db.cpp.

References _bulk_rows, _cols, base_vector< T >::size(), v_before_bind_columns(), and v_bind_one_column().

Referenced by fetch_data().

void dbserver_impl::_get_columns_info (  )  [protected]

virtual void dbserver_impl::v_before_execute (  )  [protected, pure virtual]

pure virtual functions

allocates resources before executing sql statement

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _bind_params().

virtual void dbserver_impl::v_after_execute (  )  [protected, pure virtual]

calls additional function after executing the sql statement

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _rebind_params().

virtual void dbserver_impl::v_execute (  )  [protected, pure virtual]

executes SQL expression

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by exec_proc(), exec_sql(), open_proc(), open_sql(), and v_do_job().

virtual void dbserver_impl::v_close (  )  [protected, pure virtual]

closes opened query

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by close_sql(), and interrupt_request().

virtual void dbserver_impl::v_fetch (  )  [protected, pure virtual]

fetches block of rows

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by fetch_data(), and v_do_job().

virtual void dbserver_impl::v_replace_quote (  )  [protected, pure virtual]

replaces quote to the available sign for native drive

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _get_number_params().

virtual void dbserver_impl::v_bind_one_param ( size_t  index  )  [protected, pure virtual]

binds one param by index

Parameters:
index  parameter index

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _bind_params().

virtual void dbserver_impl::v_before_bind_columns (  )  [protected, pure virtual]

before bind columns sometimes we got db specific

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _bind_columns().

virtual void dbserver_impl::v_bind_one_column ( size_t  index  )  [protected, pure virtual]

binds one column by index

Parameters:
index  parameter index

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _bind_columns().

virtual size_t dbserver_impl::v_get_number_columns (  )  [protected, pure virtual]

gets number columns in query

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _get_columns_info().

virtual void dbserver_impl::v_convert_one_value ( size_t  row,
size_t  col,
terimber_db_value val 
) [protected, pure virtual]

converts one field value to variant buffer

Parameters:
row  row index
col  column index
val  [out] value

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

virtual void dbserver_impl::v_get_one_column_info ( size_t  index  )  [protected, pure virtual]

gets one column info from native driver

Parameters:
index  column index

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _get_columns_info().

virtual void dbserver_impl::v_form_sql_string (  )  [protected, pure virtual]

forms SQL expression depending on type selected and native driver

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _get_number_params().

virtual void dbserver_impl::v_rebind_one_param ( size_t  index  )  [protected, pure virtual]

rebinds one param for input/output or output params

Parameters:
index  parameter index

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _rebind_params().

virtual void dbserver_impl::v_interrupt_async (  )  [protected, pure virtual]

terminates asynchronous action

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by interrupt_request().

virtual dbtypes dbserver_impl::v_native_type_to_client_type ( size_t  native_type  )  [protected, pure virtual]

converts types

Parameters:
native_type  SQL native type

Implemented in orcl_dbserver, odbc_dbserver, and mysql_dbserver.

Referenced by _get_columns_info().

bool dbserver_impl::v_has_job ( size_t  ident,
void *  user_data 
) [protected, virtual]

checks for job

overrides function for employer class

Parameters:
ident  thread ident
user_data  user defined data

Implements terimber_thread_employer.

Definition at line 1778 of file db.cpp.

References ACTION_EXEC_PROC_ASYNC, ACTION_EXEC_SQL_ASYNC, ACTION_FETCH_ASYNC, ACTION_OPEN_PROC_ASYNC, ACTION_OPEN_SQL_ASYNC, get_action(), get_state(), and STATE_WORKING.

void dbserver_impl::v_do_job ( size_t  ident,
void *  user_data 
) [protected, virtual]

void dbserver_impl::_notify_async ( bool  noerrors,
size_t  ident 
) [protected, virtual]

notifies subscribers

Parameters:
noerrors  error flag
ident  server ident

Definition at line 1858 of file db.cpp.

References _list_callback, _mtx, and algorithm::for_each().

Referenced by v_do_job().

module_state dbserver_impl::get_state (  )  const [inline, protected]

returns the current state

Definition at line 1328 of file db.h.

References _mtx, and _state.

Referenced by _check_state(), interrupt_request(), is_ready(), v_do_job(), orcl_dbserver::v_fetch(), odbc_dbserver::v_fetch(), mysql_dbserver::v_fetch(), and v_has_job().

void dbserver_impl::_check_connect (  )  [inline, private]

makes sure the connection is established

Definition at line 1338 of file db.h.

References _is_connect(), exception::_throw(), and ex_not_connect.

Referenced by disconnect().

void dbserver_impl::_check_disconnect (  )  [inline, private]

makes sure the connection is closed

Definition at line 1346 of file db.h.

References _is_connect(), exception::_throw(), and ex_already_connect.

Referenced by connect().

void dbserver_impl::_check_in_transaction (  )  [inline, private]

makes sure the transaction is on

Definition at line 1354 of file db.h.

References _is_in_transaction(), exception::_throw(), and ex_not_transaction.

Referenced by commit(), and rollback().

void dbserver_impl::_check_out_transaction (  )  [inline, private]

makes sure the transaction is off

Definition at line 1362 of file db.h.

References _is_in_transaction(), exception::_throw(), and ex_already_transaction.

Referenced by start_transaction().

void dbserver_impl::_check_state (  )  [inline, private]

checks if the state is OK

Definition at line 1370 of file db.h.

References exception::_throw(), ex_invalid, get_state(), and STATE_OK.

Referenced by close_sql(), exec_proc(), exec_sql(), fetch_data(), open_proc(), and open_sql().

void dbserver_impl::_check_open (  )  const [inline, private]

checks open state; must be open or exception will be thrown

Definition at line 1378 of file db.h.

References _is_open_sql(), exception::_throw(), and ex_not_sql_open.

Referenced by close_sql(), and fetch_data().

void dbserver_impl::_check_close (  )  const [inline, private]

checks close state; must be closed or exception will be thrown

Definition at line 1386 of file db.h.

References _is_open_sql(), exception::_throw(), and ex_already_sql_open.

Referenced by exec_proc(), exec_sql(), open_proc(), and open_sql().

void dbserver_impl::_check_action (  )  const [inline, private]

checks action state; must be none or exception will be thrown

Definition at line 1394 of file db.h.

References exception::_throw(), ACTION_NONE, ex_sql_in_action, and get_action().

Referenced by exec_proc(), exec_sql(), open_proc(), and open_sql().

bool dbserver_impl::_is_asynchronous_action (  )  const [private]

checks asynchronous action

Definition at line 1865 of file db.cpp.

References ACTION_EXEC_PROC_ASYNC, ACTION_EXEC_SQL_ASYNC, ACTION_FETCH_ASYNC, ACTION_OPEN_PROC_ASYNC, ACTION_OPEN_SQL_ASYNC, and get_action().

void dbserver_impl::_process_sql ( const char *  sql  )  [private]

processes sql statement

Parameters:
sql  SQL statement

Definition at line 1760 of file db.cpp.

References _sql.

Referenced by exec_proc(), exec_sql(), open_proc(), and open_sql().

void dbserver_impl::_start_thread (  )  [private]

starts thread for asynchronous actions

Definition at line 1766 of file db.cpp.

References _set_state(), _thread, thread::assign_job(), thread::get_state(), thread::start(), STATE_WORKING, THREAD_CLOSE, and thread::wakeup().

Referenced by exec_proc(), exec_sql(), fetch_data(), open_proc(), and open_sql().

recordset_list_t::iterator dbserver_impl::get_iter_end (  )  const [inline, private]

returns end iterator

Definition at line 1451 of file db.h.

References _data.

Referenced by close_sql(), fetch_data(), get_value_as_value(), get_value_is_null(), next(), prev(), and reset().

recordset_list_t::iterator dbserver_impl::get_iter_begin (  )  const [inline, private]

returns begin iterator

Definition at line 1458 of file db.h.

References _data.

Referenced by next(), and prev().


Member Data Documentation

memory allocator pool

Definition at line 1064 of file db.h.

Referenced by dbserver_impl(), and ~dbserver_impl().

size_t dbserver_impl::_ident [protected]

server ident

Definition at line 1067 of file db.h.

Referenced by get_ident(), and v_do_job().

size_t dbserver_impl::_code [protected]

code of the last error

Definition at line 1068 of file db.h.

Referenced by get_code(), resize_params(), and v_do_job().

last error description

Definition at line 1069 of file db.h.

Referenced by get_error(), resize_params(), and v_do_job().

connection state

Definition at line 1198 of file db.h.

Referenced by _is_connect(), _set_connect(), and _set_disconnect().

transaction state

Definition at line 1199 of file db.h.

Referenced by _is_in_transaction(), _set_in_transaction(), and _set_out_transaction().

bool dbserver_impl::_trusted [private]

trusted connecton flag

Definition at line 1200 of file db.h.

Referenced by connect(), and disconnect().

connection string

Definition at line 1201 of file db.h.

Referenced by connect(), and disconnect().

bulk params allocator

Definition at line 1425 of file db.h.

Referenced by dbserver_impl(), param_bulk_remove(), param_bulk_remove_all(), param_bulk_store(), and ~dbserver_impl().

sql allocator

Definition at line 1426 of file db.h.

Referenced by close_sql().

size_t dbserver_impl::_start_row [protected]

start row for fetching

Definition at line 1433 of file db.h.

Referenced by close_sql(), fetch_data(), orcl_dbserver::v_fetch(), odbc_dbserver::v_fetch(), and mysql_dbserver::v_fetch().

size_t dbserver_impl::_requested_rows [protected]

rows to fetch

Definition at line 1434 of file db.h.

Referenced by fetch_data(), orcl_dbserver::v_fetch(), odbc_dbserver::v_fetch(), and mysql_dbserver::v_fetch().

size_t dbserver_impl::_fetched_rows [protected]

actually fetched rows

Definition at line 1435 of file db.h.

Referenced by close_sql(), fetch_data(), get_row_count(), orcl_dbserver::v_fetch(), odbc_dbserver::v_fetch(), and mysql_dbserver::v_fetch().

bool dbserver_impl::_forward [protected]

fetching direction

Definition at line 1436 of file db.h.

Referenced by close_sql(), fetch_data(), and odbc_dbserver::v_fetch().

volatile module_state dbserver_impl::_state [private]

server state

Definition at line 1439 of file db.h.

Referenced by _set_state(), and get_state().

volatile action dbserver_impl::_action [private]

server action

Definition at line 1440 of file db.h.

Referenced by _set_action(), and get_action().

volatile bool dbserver_impl::_is_open [private]

open flag

Definition at line 1441 of file db.h.

Referenced by _is_open_sql(), _set_close(), and _set_open().

list of callbacks

Definition at line 1443 of file db.h.

Referenced by _notify_async(), remove_callback(), and set_callback().

recordset_list_t::iterator dbserver_impl::_iter [mutable, private]

recordset part

current iterator for recordset

Definition at line 1447 of file db.h.

Referenced by close_sql(), fetch_data(), get_value_as_value(), get_value_is_null(), next(), prev(), and reset().


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


© Copyright Terimber 2003-.