NCBI C++ ToolKit
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CQuery::CField Class Reference

Search Toolkit Book for CQuery::CField

Class representing value in result set or output parameter of stored procedure. More...

#include <dbapi/simple/sdbapi.hpp>

+ Collaboration diagram for CQuery::CField:

Public Member Functions

 CField (const CField &f)
 
 ~CField ()
 
string AsString (void) const
 Get value as UTF-8 string. More...
 
unsigned char AsByte (void) const
 Get value as single byte. More...
 
short AsShort (void) const
 Get value as short integer. More...
 
Int4 AsInt4 (void) const
 Get value as 4-byte integer. More...
 
Int8 AsInt8 (void) const
 Get value as 8-byte integer. More...
 
float AsFloat (void) const
 Get value as float. More...
 
double AsDouble (void) const
 Get value as double. More...
 
bool AsBool (void) const
 Get value as bool. More...
 
CTime AsDateTime (void) const
 Get value as CTime. More...
 
CNcbiIstreamAsIStream (void) const
 Get value as input stream. More...
 
const vector< unsigned char > & AsVector (void) const
 Get value as vector of bytes. More...
 
bool IsNull (void) const
 Check if value is NULL. More...
 
CNcbiOstreamGetOStream (size_t blob_size, TBlobOStreamFlags flags=0) const
 Get a blob output stream, on top of a cloned connection. More...
 
CNcbiOstreamGetOStream (size_t blob_size, EAllowLog log_it) const
 
CBlobBookmark GetBookmark (void) const
 Get bookmark for the blob. More...
 

Private Member Functions

void x_Detach (void)
 
 CField (CQueryImpl *q, unsigned int col_num)
 Create field for particular column number in result set. More...
 
 CField (CQueryImpl *q, CVariant *v, ESP_ParamType param_type)
 Create field for particular parameter in the query. More...
 

Private Attributes

CRef< CQueryFieldImplm_Impl
 

Friends

class CQueryImpl
 
class CQueryFieldImpl
 
class CRow
 

Detailed Description

Class representing value in result set or output parameter of stored procedure.

Definition at line 257 of file sdbapi.hpp.

Constructor & Destructor Documentation

◆ CField() [1/3]

CQuery::CField::CField ( const CField f)

Definition at line 2559 of file sdbapi.cpp.

◆ ~CField()

CQuery::CField::~CField ( )

Definition at line 2591 of file sdbapi.cpp.

◆ CField() [2/3]

CQuery::CField::CField ( CQueryImpl q,
unsigned int  col_num 
)
inlineprivate

Create field for particular column number in result set.

Definition at line 2574 of file sdbapi.cpp.

References eSDB_BinaryMax, eSDB_Image, eSDB_StringMax, eSDB_StringMaxUCS2, eSDB_Text, eSDB_TextUCS2, CQueryImpl::GetColumnType(), CQuery::m_Impl, and CRef< C, Locker >::Reset().

◆ CField() [3/3]

CQuery::CField::CField ( CQueryImpl q,
CVariant v,
ESP_ParamType  param_type 
)
inlineprivate

Create field for particular parameter in the query.

Definition at line 2564 of file sdbapi.cpp.

References CVariant::GetType(), CDB_Object::IsBlobType(), CQuery::m_Impl, and CRef< C, Locker >::Reset().

Member Function Documentation

◆ AsBool()

bool CQuery::CField::AsBool ( void  ) const

Get value as bool.

If underlying database type is string or text then attempt to convert it to integer will be made. If the value cannot be converted to integer or resulting integer is not equal to 0 or 1 (also if underlying type is integer and it's not equal to 0 or 1) exception will be thrown.

Definition at line 3726 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsByte()

unsigned char CQuery::CField::AsByte ( void  ) const

Get value as single byte.

If underlying database type is string or text then attempt to convert it to byte will be made. If the value cannot be converted to integer or resulting integer cannot fit into byte exception will be thrown.

Definition at line 3678 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsDateTime()

CTime CQuery::CField::AsDateTime ( void  ) const

Get value as CTime.

If underlying database type is string or text then attempt to convert it to CTime will be made. If the value cannot be converted to CTime exception will be thrown.

Definition at line 3734 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsDouble()

double CQuery::CField::AsDouble ( void  ) const

Get value as double.

If underlying database type is string or text then attempt to convert it to double will be made. If the value cannot be converted to double exception will be thrown.

Definition at line 3718 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsFloat()

float CQuery::CField::AsFloat ( void  ) const

Get value as float.

If underlying database type is string or text then attempt to convert it to double will be made. If the value cannot be converted to double exception will be thrown.

Definition at line 3710 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsInt4()

Int4 CQuery::CField::AsInt4 ( void  ) const

Get value as 4-byte integer.

If underlying database type is string or text then attempt to convert it to integer will be made. If the value cannot be converted to integer or resulting integer cannot fit into 4 bytes exception will be thrown.

Definition at line 3694 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsInt8()

Int8 CQuery::CField::AsInt8 ( void  ) const

Get value as 8-byte integer.

If underlying database type is string or text then attempt to convert it to integer will be made. If the value cannot be converted to integer exception will be thrown.

Definition at line 3702 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsIStream()

CNcbiIstream & CQuery::CField::AsIStream ( void  ) const

Get value as input stream.

Only Text and Image data can be read via stream. Returned stream should be read completely before any other field is attempted to be read.

Definition at line 3789 of file sdbapi.cpp.

References CQuery::m_Impl.

◆ AsShort()

short CQuery::CField::AsShort ( void  ) const

Get value as short integer.

If underlying database type is string or text then attempt to convert it to byte will be made. If the value cannot be converted to integer or resulting integer cannot fit into short data type exception will be thrown.

Definition at line 3686 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsString()

string CQuery::CField::AsString ( void  ) const

Get value as UTF-8 string.

Any underlying database type will be converted to a string using the variable-width UTF-8 encoding.

See also
CUtf8::AsBasicString, CUtf8::AsSingleByteString

Definition at line 3670 of file sdbapi.cpp.

References CQuery::m_Impl, s_ConvertValue(), and rapidjson::value.

◆ AsVector()

const vector< unsigned char > & CQuery::CField::AsVector ( void  ) const

Get value as vector of bytes.

Only Text and Image data can be read as vector. Returned vector should be read completely before any other field is attempted to be read.

Definition at line 3765 of file sdbapi.cpp.

References CQuery::m_Impl.

◆ GetBookmark()

CBlobBookmark CQuery::CField::GetBookmark ( void  ) const

Get bookmark for the blob.

This bookmark can be used to change blob data later when all results from this query are processed.

NOTE: You won't be able to write a blob using this method if its value is set to NULL in the database. To use this method you should pre-set blob value to empty string or anything else of your choice. Blob value should be set before the query execution, i.e. query should return non-NULL value. Setting non-NULL value after query execution won't work.

Deprecated:
Please use CDatabase::NewBookmark instead.
See also
CDatabase::NewBookmark

Definition at line 3878 of file sdbapi.cpp.

References CQuery::m_Impl.

◆ GetOStream() [1/2]

CNcbiOstream & CQuery::CField::GetOStream ( size_t  blob_size,
EAllowLog  log_it 
) const

Definition at line 3844 of file sdbapi.cpp.

References CQuery::eDisableLog, and fBOS_SkipLogging.

◆ GetOStream() [2/2]

CNcbiOstream & CQuery::CField::GetOStream ( size_t  blob_size,
TBlobOStreamFlags  flags = 0 
) const

Get a blob output stream, on top of a cloned connection.

The original connection should NOT have an active transaction.

NOTE: You won't be able to write a blob using this method if its value is set to NULL in the database. To use this method you should pre-set blob value to empty string or anything else of your choice.

Parameters
blob_sizeblob_size is the size of the BLOB to be written.
flags
See also
EBlobOStreamFlags.
Parameters
log_itEnables transaction log for BLOB (enabled by default). Make sure you have enough log segment space, or disable it.
Deprecated:
Please use CBlobBookmark::GetOStream instead.
See also
CBlobBookmark::GetOStream

Definition at line 3838 of file sdbapi.cpp.

References flags, and CQuery::m_Impl.

◆ IsNull()

bool CQuery::CField::IsNull ( void  ) const

Check if value is NULL.

Definition at line 3795 of file sdbapi.cpp.

References CQuery::m_Impl.

◆ x_Detach()

void CQuery::CField::x_Detach ( void  )
private

Friends And Related Function Documentation

◆ CQueryFieldImpl

friend class CQueryFieldImpl
friend

Definition at line 369 of file sdbapi.hpp.

◆ CQueryImpl

friend class CQueryImpl
friend

Definition at line 368 of file sdbapi.hpp.

◆ CRow

friend class CRow
friend

Definition at line 370 of file sdbapi.hpp.

Member Data Documentation

◆ m_Impl

CRef<CQueryFieldImpl> CQuery::CField::m_Impl
private

Definition at line 379 of file sdbapi.hpp.


The documentation for this class was generated from the following files:
Modified on Wed Jun 12 11:17:55 2024 by modify_doxy.py rev. 669887