NCBI C++ ToolKit
|
Search Toolkit Book for CResultSet
#include "rs_impl.hpp"
(Private to src/dbapi
.)
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 CVariant & | GetVariant (const CDBParamVariant ¶m) |
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 IResultSetMetaData * | GetMetaData (EOwnership ownership) |
Get Metadata. More... | |
virtual CNcbiIstream & | GetBlobIStream (size_t buf_size) |
Get Blob input stream. More... | |
virtual CNcbiOstream & | GetBlobOStream (size_t blob_size, TBlobOStreamFlags flags, size_t buf_size) |
Get Blob output stream. More... | |
virtual CNcbiOstream & | GetBlobOStream (size_t blob_size, EAllowLog log_it, size_t buf_size) |
virtual CNcbiOstream & | GetBlobOStream (IConnection *conn, size_t blob_size, TBlobOStreamFlags flags, size_t buf_size) |
Get Blob output stream with explicit additional connection. More... | |
virtual CNcbiOstream & | GetBlobOStream (IConnection *conn, size_t blob_size, EAllowLog log_it, size_t buf_size) |
virtual IReader * | GetBlobReader () |
Get a Blob Reader. More... | |
virtual void | Action (const CDbapiEvent &e) |
CDB_Result * | GetCDB_Result () |
void | Invalidate () |
int | GetTotalRows () |
![]() | |
CActiveObject () | |
virtual | ~CActiveObject () |
void | AddListener (CActiveObject *obj) |
void | RemoveListener (CActiveObject *obj) |
void | Notify (const CDbapiEvent &e) |
string | GetIdent () const |
![]() | |
virtual | ~IEventListener () |
![]() | |
virtual | ~IResultSet () |
Destructor. More... | |
Protected Member Functions | |
int | GetColNum (const string &name) |
void | CheckIdx (unsigned int idx) |
bool | IsBindBlob () |
bool | IsDisableBind () |
void | FreeResources () |
![]() | |
void | SetIdent (const string &name) |
TLList & | GetListenerList () |
![]() | |
IEventListener () | |
Private Types | |
enum | ERowReadType { eReadUnknown , eReadVariant , eReadRaw } |
Private Member Functions | |
CNcbiOstream & | xGetBlobOStream (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 CConnection * | m_conn |
CDB_Result * | m_rs |
CResultSetMetaData * | m_metaData |
vector< CVariant > | m_data |
CRStream * | m_istr |
CWStream * | m_ostr |
int | m_column |
bool | m_bindBlob |
bool | m_disableBind |
bool | m_wasNull |
CxBlobReader * | m_rd |
int | m_totalRows |
int | m_LastVariantNum |
ERowReadType | m_RowReadType |
Additional Inherited Members | |
![]() | |
typedef list< CActiveObject * > | TLList |
Definition at line 52 of file rs_impl.hpp.
|
private |
Enumerator | |
---|---|
eReadUnknown | |
eReadVariant | |
eReadRaw |
Definition at line 160 of file rs_impl.hpp.
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().
|
virtual |
Definition at line 117 of file rs_impl.cpp.
References _TRACE, FreeResources(), CActiveObject::GetIdent(), kEmptyStr, NCBI_CATCH_ALL_X, and CActiveObject::Notify().
|
virtual |
Reimplemented from CActiveObject.
Definition at line 419 of file rs_impl.cpp.
References _TRACE, CActiveObject::GetIdent(), CDbapiEvent::GetName(), CDbapiEvent::GetSource(), Invalidate(), m_rs, and CActiveObject::RemoveListener().
|
virtual |
Bind blob to variant.
If this mode is true, BLOB data is returned as CVariant False by default.
Enables | blob binding when set to true. |
Implements IResultSet.
Definition at line 184 of file rs_impl.cpp.
References b, and m_bindBlob.
|
protected |
Definition at line 462 of file rs_impl.cpp.
References _ASSERT, NStr::IntToString(), m_data, NCBI_DBAPI_THROW, and NcbiCerr.
Referenced by GetVariant().
|
virtual |
Close resultset.
Implements IResultSet.
Definition at line 399 of file rs_impl.cpp.
References FreeResources(), and CActiveObject::Notify().
|
virtual |
Disables column binding.
False by default.
Disables | column binding when set to true. |
Implements IResultSet.
Definition at line 189 of file rs_impl.cpp.
References b, and m_disableBind.
|
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().
|
virtual |
Get Blob input stream.
buf_size | buf_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.
|
virtual |
Reimplemented from IResultSet.
Definition at line 332 of file rs_impl.cpp.
References conn, and IResultSet::GetBlobOStream().
|
virtual |
Get Blob output stream with explicit additional connection.
conn | addtional connection used for writing blob (the above method clones the existing connection implicitly) |
blob_size | blob_size is the size of the BLOB to be written. |
flags |
buf_size | The size of internal buffer, default 4096. |
Implements IResultSet.
Definition at line 357 of file rs_impl.cpp.
References _ASSERT, conn, flags, m_conn, and xGetBlobOStream().
|
virtual |
Reimplemented from IResultSet.
Definition at line 325 of file rs_impl.cpp.
References IResultSet::GetBlobOStream().
|
virtual |
Get Blob output stream.
The existing connection is cloned for writing blob.
blob_size | blob_size is the size of the BLOB to be written. |
flags |
buf_size | The size of internal buffer, default 4096. |
Implements IResultSet.
Definition at line 348 of file rs_impl.cpp.
References _ASSERT, CConnection::CloneCDB_Conn(), flags, m_conn, and xGetBlobOStream().
|
virtual |
Get a Blob Reader.
Pointer | to the Blob Reader. |
Implements IResultSet.
Definition at line 340 of file rs_impl.cpp.
References m_rd.
|
inline |
Definition at line 107 of file rs_impl.hpp.
References m_rs.
Referenced by CStatement::GetCDB_Result().
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().
|
virtual |
Get column number, currently available for Read()
Implements IResultSet.
Definition at line 303 of file rs_impl.cpp.
References _ASSERT, CDB_Result::CurrentItemNo(), and m_rs.
Referenced by CByteStreamBuf::underflow().
|
virtual |
Get Metadata.
Implements IResultSet.
Definition at line 164 of file rs_impl.cpp.
References CActiveObject::AddListener(), eTakeOwnership, m_metaData, m_rs, and NULL.
|
virtual |
Get result type.
Implements IResultSet.
Definition at line 178 of file rs_impl.cpp.
References _ASSERT, m_rs, and CDB_Result::ResultType().
|
virtual |
Get total columns.
Implements IResultSet.
Definition at line 309 of file rs_impl.cpp.
References _ASSERT, m_rs, and CDB_Result::NofItems().
|
inline |
Definition at line 117 of file rs_impl.hpp.
References m_totalRows.
Referenced by CStatement::Action().
|
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.
param | Column number (one-based) or name |
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().
void CResultSet::Init | ( | void | ) |
Definition at line 85 of file rs_impl.cpp.
References _ASSERT, _TRACE, CVariant::Binary(), CVariant::Char(), eDB_Binary, eDB_Char, eDB_LongBinary, eDB_LongChar, i, CDB_Result::ItemDataType(), CDB_Result::ItemMaxSize(), CVariant::LongBinary(), CVariant::LongChar(), m_data, m_rs, CDB_Result::NofItems(), and type.
Referenced by CResultSet(), and Next().
|
inline |
Definition at line 111 of file rs_impl.hpp.
References m_rs, and m_totalRows.
Referenced by Action(), CStatement::CacheResultSet(), and FreeResources().
|
inlineprotected |
Definition at line 126 of file rs_impl.hpp.
References m_bindBlob.
|
inlineprotected |
|
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().
|
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())
buf | Buffer to read data. |
size | Amount of data to 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().
|
virtual |
Determine if last column was NULL.
Valid only when the column binding is off.
Implements IResultSet.
Definition at line 297 of file rs_impl.cpp.
References m_wasNull.
|
private |
Definition at line 253 of file rs_impl.cpp.
References CDB_Result::CurrentItemNo(), eDB_StatusResult, CDB_Result::GetBlobDescriptor(), CDB_Result::GetItem(), CVariant::GetNonNullData(), CDB_Object::IsBlobType(), CDB_Result::ItemDataType(), m_data, m_rs, CDB_Result::ResultType(), CVariant::SetBlobDescriptor(), and Truncate().
Referenced by GetVariant(), and Read().
|
private |
Definition at line 367 of file rs_impl.cpp.
References _ASSERT, destroy(), flags, CRWStreambuf::fOwnWriter, CDB_Result::GetBlobDescriptor(), m_ostr, m_rs, NCBI_DBAPI_THROW, NcbiCerr, NULL, and CDB_Result::ReadItem().
Referenced by GetBlobOStream().
|
private |
Definition at line 153 of file rs_impl.hpp.
Referenced by BindBlobToVariant(), and IsBindBlob().
|
private |
Definition at line 152 of file rs_impl.hpp.
Referenced by GetVariant(), Next(), and Read().
|
private |
Definition at line 146 of file rs_impl.hpp.
Referenced by GetBlobOStream().
|
private |
Definition at line 149 of file rs_impl.hpp.
Referenced by CheckIdx(), GetVariant(), Init(), Next(), and x_CacheItems().
|
private |
Definition at line 154 of file rs_impl.hpp.
Referenced by DisableBind(), and IsDisableBind().
|
private |
Definition at line 150 of file rs_impl.hpp.
Referenced by FreeResources(), GetBlobIStream(), and Next().
|
private |
Definition at line 158 of file rs_impl.hpp.
Referenced by GetVariant(), and Next().
|
private |
Definition at line 148 of file rs_impl.hpp.
Referenced by GetMetaData().
|
private |
Definition at line 151 of file rs_impl.hpp.
Referenced by FreeResources(), Next(), and xGetBlobOStream().
|
private |
Definition at line 156 of file rs_impl.hpp.
Referenced by FreeResources(), GetBlobReader(), and Next().
|
private |
Definition at line 166 of file rs_impl.hpp.
Referenced by GetVariant(), Next(), and Read().
|
private |
Definition at line 147 of file rs_impl.hpp.
Referenced by Action(), CResultSet(), GetCDB_Result(), GetColNum(), GetColumnNo(), GetMetaData(), GetResultType(), GetTotalColumns(), Init(), Invalidate(), Next(), Read(), x_CacheItems(), and xGetBlobOStream().
|
private |
Definition at line 157 of file rs_impl.hpp.
Referenced by FreeResources(), GetTotalRows(), Invalidate(), and Next().
|
private |
Definition at line 155 of file rs_impl.hpp.