NCBI C++ ToolKit
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CResultSet Class Reference

Search Toolkit Book for CResultSet

#include "rs_impl.hpp"
(Private to src/dbapi.)

+ Inheritance diagram for CResultSet:
+ Collaboration diagram for CResultSet:

Public Member Functions

 CResultSet (class CConnection *conn, CDB_Result *rs)
 
virtual ~CResultSet ()
 
void Init ()
 
virtual EDB_ResType GetResultType ()
 Get result type. More...
 
virtual bool Next ()
 Get next row. More...
 
virtual const CVariantGetVariant (const CDBParamVariant &param)
 Retrieve a CVariant class describing the data stored in a given column. More...
 
virtual void DisableBind (bool b)
 Disables column binding. More...
 
virtual void BindBlobToVariant (bool b)
 Bind blob to variant. More...
 
virtual size_t Read (void *buf, size_t size)
 Read unformatted data. More...
 
virtual bool WasNull ()
 Determine if last column was NULL. More...
 
virtual int GetColumnNo ()
 Get column number, currently available for Read() More...
 
virtual unsigned int GetTotalColumns ()
 Get total columns. More...
 
virtual void Close ()
 Close resultset. More...
 
virtual const IResultSetMetaDataGetMetaData (EOwnership ownership)
 Get Metadata. More...
 
virtual CNcbiIstreamGetBlobIStream (size_t buf_size)
 Get Blob input stream. More...
 
virtual CNcbiOstreamGetBlobOStream (size_t blob_size, TBlobOStreamFlags flags, size_t buf_size)
 Get Blob output stream. More...
 
virtual CNcbiOstreamGetBlobOStream (size_t blob_size, EAllowLog log_it, size_t buf_size)
 
virtual CNcbiOstreamGetBlobOStream (IConnection *conn, size_t blob_size, TBlobOStreamFlags flags, size_t buf_size)
 Get Blob output stream with explicit additional connection. More...
 
virtual CNcbiOstreamGetBlobOStream (IConnection *conn, size_t blob_size, EAllowLog log_it, size_t buf_size)
 
virtual IReaderGetBlobReader ()
 Get a Blob Reader. More...
 
virtual void Action (const CDbapiEvent &e)
 
CDB_ResultGetCDB_Result ()
 
void Invalidate ()
 
int GetTotalRows ()
 
- Public Member Functions inherited from CActiveObject
 CActiveObject ()
 
virtual ~CActiveObject ()
 
void AddListener (CActiveObject *obj)
 
void RemoveListener (CActiveObject *obj)
 
void Notify (const CDbapiEvent &e)
 
string GetIdent () const
 
- Public Member Functions inherited from IEventListener
virtual ~IEventListener ()
 
- Public Member Functions inherited from IResultSet
virtual ~IResultSet ()
 Destructor. More...
 

Protected Member Functions

int GetColNum (const string &name)
 
void CheckIdx (unsigned int idx)
 
bool IsBindBlob ()
 
bool IsDisableBind ()
 
void FreeResources ()
 
- Protected Member Functions inherited from CActiveObject
void SetIdent (const string &name)
 
TLListGetListenerList ()
 
- Protected Member Functions inherited from IEventListener
 IEventListener ()
 

Private Types

enum  ERowReadType { eReadUnknown , eReadVariant , eReadRaw }
 

Private Member Functions

CNcbiOstreamxGetBlobOStream (CDB_Connection *cdb_conn, size_t blob_size, TBlobOStreamFlags flags, size_t buf_size, bool destroy)
 
void x_CacheItems (int last_num)
 

Private Attributes

class CConnectionm_conn
 
CDB_Resultm_rs
 
CResultSetMetaDatam_metaData
 
vector< CVariantm_data
 
CRStreamm_istr
 
CWStreamm_ostr
 
int m_column
 
bool m_bindBlob
 
bool m_disableBind
 
bool m_wasNull
 
CxBlobReaderm_rd
 
int m_totalRows
 
int m_LastVariantNum
 
ERowReadType m_RowReadType
 

Additional Inherited Members

- Protected Types inherited from CActiveObject
typedef list< CActiveObject * > TLList
 

Detailed Description

Definition at line 52 of file rs_impl.hpp.

Member Enumeration Documentation

◆ ERowReadType

Enumerator
eReadUnknown 
eReadVariant 
eReadRaw 

Definition at line 160 of file rs_impl.hpp.

Constructor & Destructor Documentation

◆ CResultSet()

CResultSet::CResultSet ( class CConnection conn,
CDB_Result rs 
)

Definition at line 58 of file rs_impl.cpp.

References _ASSERT, _TRACE, Init(), m_rs, and CActiveObject::SetIdent().

◆ ~CResultSet()

CResultSet::~CResultSet ( )
virtual

Member Function Documentation

◆ Action()

void CResultSet::Action ( const CDbapiEvent e)
virtual

◆ BindBlobToVariant()

void CResultSet::BindBlobToVariant ( bool  b)
virtual

Bind blob to variant.

If this mode is true, BLOB data is returned as CVariant False by default.

Note
When binding of blobs to variant is disabled all columns in resultset placed after first blob column must be read with Read() method, GetVariant() method will always return NULL for these columns.
Parameters
Enablesblob binding when set to true.

Implements IResultSet.

Definition at line 184 of file rs_impl.cpp.

References b, and m_bindBlob.

◆ CheckIdx()

void CResultSet::CheckIdx ( unsigned int  idx)
protected

Definition at line 462 of file rs_impl.cpp.

References _ASSERT, NStr::IntToString(), m_data, NCBI_DBAPI_THROW, and NcbiCerr.

Referenced by GetVariant().

◆ Close()

void CResultSet::Close ( )
virtual

Close resultset.

Implements IResultSet.

Definition at line 399 of file rs_impl.cpp.

References FreeResources(), and CActiveObject::Notify().

◆ DisableBind()

void CResultSet::DisableBind ( bool  b)
virtual

Disables column binding.

Note
When binding is disabled all columns must be read with Read() method, GetVariant() method will always return NULL in this case.

False by default.

Parameters
Disablescolumn binding when set to true.

Implements IResultSet.

Definition at line 189 of file rs_impl.cpp.

References b, and m_disableBind.

◆ FreeResources()

void CResultSet::FreeResources ( )
protected

Definition at line 405 of file rs_impl.cpp.

References Invalidate(), m_istr, m_ostr, m_rd, and m_totalRows.

Referenced by Close(), and ~CResultSet().

◆ GetBlobIStream()

CNcbiIstream & CResultSet::GetBlobIStream ( size_t  buf_size)
virtual

Get Blob input stream.

Parameters
buf_sizebuf_size is the size of internal buffer, default 4096.

Implements IResultSet.

Definition at line 315 of file rs_impl.cpp.

References CRWStreambuf::fLogExceptions, CRWStreambuf::fOwnReader, and m_istr.

◆ GetBlobOStream() [1/4]

CNcbiOstream & CResultSet::GetBlobOStream ( IConnection conn,
size_t  blob_size,
EAllowLog  log_it,
size_t  buf_size 
)
virtual

Reimplemented from IResultSet.

Definition at line 332 of file rs_impl.cpp.

References conn, and IResultSet::GetBlobOStream().

◆ GetBlobOStream() [2/4]

CNcbiOstream & CResultSet::GetBlobOStream ( IConnection conn,
size_t  blob_size,
TBlobOStreamFlags  flags,
size_t  buf_size 
)
virtual

Get Blob output stream with explicit additional connection.

Parameters
connaddtional connection used for writing blob (the above method clones the existing connection implicitly)
blob_sizeblob_size is the size of the BLOB to be written.
flags
See also
EBlobOStreamFlags.
Parameters
buf_sizeThe size of internal buffer, default 4096.
Deprecated:
Please use IStatement::GetBlobOStream instead.
See also
IStatement::GetBlobOStream

Implements IResultSet.

Definition at line 357 of file rs_impl.cpp.

References _ASSERT, conn, flags, m_conn, and xGetBlobOStream().

◆ GetBlobOStream() [3/4]

CNcbiOstream & CResultSet::GetBlobOStream ( size_t  blob_size,
EAllowLog  log_it,
size_t  buf_size 
)
virtual

Reimplemented from IResultSet.

Definition at line 325 of file rs_impl.cpp.

References IResultSet::GetBlobOStream().

◆ GetBlobOStream() [4/4]

CNcbiOstream & CResultSet::GetBlobOStream ( size_t  blob_size,
TBlobOStreamFlags  flags,
size_t  buf_size 
)
virtual

Get Blob output stream.

The existing connection is cloned for writing blob.

Parameters
blob_sizeblob_size is the size of the BLOB to be written.
flags
See also
EBlobOStreamFlags.
Parameters
buf_sizeThe size of internal buffer, default 4096.
Deprecated:
Please use IStatement::GetBlobOStream instead.
See also
IStatement::GetBlobOStream

Implements IResultSet.

Definition at line 348 of file rs_impl.cpp.

References _ASSERT, CConnection::CloneCDB_Conn(), flags, m_conn, and xGetBlobOStream().

◆ GetBlobReader()

IReader * CResultSet::GetBlobReader ( )
virtual

Get a Blob Reader.

Parameters
Pointerto the Blob Reader.

Implements IResultSet.

Definition at line 340 of file rs_impl.cpp.

References m_rd.

◆ GetCDB_Result()

CDB_Result* CResultSet::GetCDB_Result ( )
inline

Definition at line 107 of file rs_impl.hpp.

References m_rs.

Referenced by CStatement::GetCDB_Result().

◆ GetColNum()

int CResultSet::GetColNum ( const string name)
protected

Definition at line 448 of file rs_impl.cpp.

References _ASSERT, NStr::Compare(), i, CDB_Result::ItemName(), m_rs, NCBI_DBAPI_THROW, and CDB_Result::NofItems().

Referenced by GetVariant().

◆ GetColumnNo()

int CResultSet::GetColumnNo ( )
virtual

Get column number, currently available for Read()

Returns
Returns current item number we can retrieve (1,2,...) using Read() Returns "0" if no more items left (or available) to read

Implements IResultSet.

Definition at line 303 of file rs_impl.cpp.

References _ASSERT, CDB_Result::CurrentItemNo(), and m_rs.

Referenced by CByteStreamBuf::underflow().

◆ GetMetaData()

const IResultSetMetaData * CResultSet::GetMetaData ( EOwnership  ownership)
virtual

Get Metadata.

Returns
Pointer to result metadata.

Implements IResultSet.

Definition at line 164 of file rs_impl.cpp.

References CActiveObject::AddListener(), eTakeOwnership, m_metaData, m_rs, and NULL.

◆ GetResultType()

EDB_ResType CResultSet::GetResultType ( )
virtual

Get result type.

See also
See in <dbapi/driver/interfaces.hpp> for the list of result types.

Implements IResultSet.

Definition at line 178 of file rs_impl.cpp.

References _ASSERT, m_rs, and CDB_Result::ResultType().

◆ GetTotalColumns()

unsigned int CResultSet::GetTotalColumns ( )
virtual

Get total columns.

Returns
Returns total number of columns in the resultset

Implements IResultSet.

Definition at line 309 of file rs_impl.cpp.

References _ASSERT, m_rs, and CDB_Result::NofItems().

◆ GetTotalRows()

int CResultSet::GetTotalRows ( )
inline

Definition at line 117 of file rs_impl.hpp.

References m_totalRows.

Referenced by CStatement::Action().

◆ GetVariant()

const CVariant & CResultSet::GetVariant ( const CDBParamVariant param)
virtual

Retrieve a CVariant class describing the data stored in a given column.

Note that the index supplied is one-based, not zero-based; the first column is column 1.

Parameters
paramColumn number (one-based) or name
Returns
All data (for BLOB data see below) is returned as CVariant.

Implements IResultSet.

Definition at line 128 of file rs_impl.cpp.

References CheckIdx(), eReadRaw, eReadUnknown, eReadVariant, GetColNum(), CDBParamVariant::GetName(), CDBParamVariant::GetPosition(), CDBParamVariant::IsPositional(), m_column, m_data, m_LastVariantNum, m_RowReadType, and x_CacheItems().

◆ Init()

void CResultSet::Init ( void  )

◆ Invalidate()

void CResultSet::Invalidate ( void  )
inline

Definition at line 111 of file rs_impl.hpp.

References m_rs, and m_totalRows.

Referenced by Action(), CStatement::CacheResultSet(), and FreeResources().

◆ IsBindBlob()

bool CResultSet::IsBindBlob ( )
inlineprotected

Definition at line 126 of file rs_impl.hpp.

References m_bindBlob.

◆ IsDisableBind()

bool CResultSet::IsDisableBind ( )
inlineprotected

Definition at line 130 of file rs_impl.hpp.

References m_disableBind.

Referenced by Next().

◆ Next()

bool CResultSet::Next ( )
virtual

Get next row.

NOTE: no results are fetched before first call to this function.

Implements IResultSet.

Definition at line 194 of file rs_impl.cpp.

References _TRACE, eReadRaw, eReadUnknown, CDB_Result::Fetch(), i, Init(), CDB_Object::IsBlobType(), IsDisableBind(), CDB_Result::ItemDataType(), m_column, m_data, m_istr, m_LastVariantNum, m_ostr, m_rd, m_RowReadType, m_rs, m_totalRows, CDB_Result::NofItems(), and CActiveObject::Notify().

◆ Read()

size_t CResultSet::Read ( void *  buf,
size_t  size 
)
virtual

Read unformatted data.

Reads unformatted data, returns bytes actually read. Advances to next column as soon as data is read from the previous one. Returns 0 when the column data is fully read Valid only when the column binding is off (see DisableBind())

Parameters
bufBuffer to read data.
sizeAmount of data to read.
Returns
Actual number of bytes read.

Implements IResultSet.

Definition at line 270 of file rs_impl.cpp.

References _ASSERT, _TRACE, buf, CDB_Result::CurrentItemNo(), eReadRaw, m_column, m_RowReadType, m_rs, m_wasNull, NCBI_DBAPI_THROW, CDB_Result::ReadItem(), ncbi::grid::netcache::search::fields::size, and x_CacheItems().

Referenced by CxBlobReader::Read(), and CByteStreamBuf::underflow().

◆ WasNull()

bool CResultSet::WasNull ( )
virtual

Determine if last column was NULL.

Valid only when the column binding is off.

Returns
Return true if the last column read was NULL.
See also
DisableBind().

Implements IResultSet.

Definition at line 297 of file rs_impl.cpp.

References m_wasNull.

◆ x_CacheItems()

void CResultSet::x_CacheItems ( int  last_num)
private

◆ xGetBlobOStream()

CNcbiOstream & CResultSet::xGetBlobOStream ( CDB_Connection cdb_conn,
size_t  blob_size,
TBlobOStreamFlags  flags,
size_t  buf_size,
bool  destroy 
)
private

Member Data Documentation

◆ m_bindBlob

bool CResultSet::m_bindBlob
private

Definition at line 153 of file rs_impl.hpp.

Referenced by BindBlobToVariant(), and IsBindBlob().

◆ m_column

int CResultSet::m_column
private

Definition at line 152 of file rs_impl.hpp.

Referenced by GetVariant(), Next(), and Read().

◆ m_conn

class CConnection* CResultSet::m_conn
private

Definition at line 146 of file rs_impl.hpp.

Referenced by GetBlobOStream().

◆ m_data

vector<CVariant> CResultSet::m_data
private

Definition at line 149 of file rs_impl.hpp.

Referenced by CheckIdx(), GetVariant(), Init(), Next(), and x_CacheItems().

◆ m_disableBind

bool CResultSet::m_disableBind
private

Definition at line 154 of file rs_impl.hpp.

Referenced by DisableBind(), and IsDisableBind().

◆ m_istr

CRStream* CResultSet::m_istr
private

Definition at line 150 of file rs_impl.hpp.

Referenced by FreeResources(), GetBlobIStream(), and Next().

◆ m_LastVariantNum

int CResultSet::m_LastVariantNum
private

Definition at line 158 of file rs_impl.hpp.

Referenced by GetVariant(), and Next().

◆ m_metaData

CResultSetMetaData* CResultSet::m_metaData
private

Definition at line 148 of file rs_impl.hpp.

Referenced by GetMetaData().

◆ m_ostr

CWStream* CResultSet::m_ostr
private

Definition at line 151 of file rs_impl.hpp.

Referenced by FreeResources(), Next(), and xGetBlobOStream().

◆ m_rd

CxBlobReader* CResultSet::m_rd
private

Definition at line 156 of file rs_impl.hpp.

Referenced by FreeResources(), GetBlobReader(), and Next().

◆ m_RowReadType

ERowReadType CResultSet::m_RowReadType
private

Definition at line 166 of file rs_impl.hpp.

Referenced by GetVariant(), Next(), and Read().

◆ m_rs

CDB_Result* CResultSet::m_rs
private

◆ m_totalRows

int CResultSet::m_totalRows
private

Definition at line 157 of file rs_impl.hpp.

Referenced by FreeResources(), GetTotalRows(), Invalidate(), and Next().

◆ m_wasNull

bool CResultSet::m_wasNull
private

Definition at line 155 of file rs_impl.hpp.

Referenced by Read(), and WasNull().


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:57:38 2024 by modify_doxy.py rev. 669887