OTL 4.0, OTL stream read iterator

OTL stream read iterator

This template class extends the OTL stream interface with more JDBC-like, conventional getter functions.
template<typename OTLStream, 
typename OTLException
#if !defined(OTL_ORA7)
// when any flavor of OTL but OTL_ORA7 is defined:
// OTL_ORA8, OTL_ORA8I, OTL_ORA9I, OTL_ORA10G,
// OTL_ORA10G_R2, OTL_ODBC, OTL_DB2_CLI
,typename OTLLobStream
#endif
>
class otl_stream_read_iterator{
public:
     otl_stream_read_iterator(); // default constructor
     ~otl_stream_read_iterator(); // destructor

     otl_stream_read_iterator(OTLStream& s);
// general-purpose constructor, attaches to otl_stream s
     void attach(OTLStream& s); // attaches to otl_stream s
void detach(void); // detaches from the otl_stream

bool next_row(void);
// reads the next row, returns true if the row was successfully fetched,
// false on the end-of-fetch-sequence.

const otl_var_desc* describe(int& var_desc_len);
// describes the output structure of the attached otl_stream.
// var_desc_len is the total number of elements
// in the output structure of the attached otl_stream.
// The same information can be obtained via
// otl_stream::describe_out_vars(), which
// this object is attached to.

// JDBC-like getter functions.
// pos is 1,2,... as in JDBC getXXX functions
void get(const int pos, char& c); // gets a char
void get(const int pos, unsigned char& c); // gets an unsigned char
void get(const int pos, char* s); // gets a null terminated char string
void get(const int pos, unsigned char* s); // gets a null terminated unsigned char string
void get(const int pos, int& n); // gets a signed 32-bit int
void get(const int pos, unsigned int& n); // gets a unsigned 32-bit int
void get(const int pos, short int& n); // gets a signed 16-bit int
void get(const int pos, long int& n); // gets a signed long 32-bit int
void get(const int pos, float& n); // gets a 4-byte floating point
void get(const int pos, double& n); // gets an 8-byte floating point
void get(const int pos, OTL_BIGINT& n); // gets a signed 64-bit int
void get(const int pos, OTL_STRING_CONTAINER& s);
// gets an std::string if #define OTL_STL is enabled.
// gets an std::string if #define OTL_STLPORT is enabled.
// gets an ACE_TString if #define OTL_ACE is enabled.
// VARCHAR, CHAR, LONG, TEXT, and CLOB values can be read by this function.
// gets a USER_DEFINED_STRING_CLASS instance if #define
// OTL_USER_DEFINED_STRING_CLASS_ON is enabled.

void get(const int pos, otl_long_string& s); // gets an otl_long_string
void get(const int pos, otl_long_string*& s);
// gets a pointer to otl_long_string. This is more optimal than the previous
// function, especially in the case of a large string.

#if !defined(OTL_ORA7)
// when any flavor of OTL but OTL_ORA7 is defined:
// OTL_ORA8, OTL_ORA8I, OTL_ORA9I, OTL_ORA10G,
// OTL_ORA10G_R2, OTL_ODBC, OTL_DB2_CLI

void get(const int pos, otl_lob_stream*& s);
// gets a pointer to otl_lob_stream. This function can be used if the otl_stream
// that the read iterator is attached to is in the LOB stream mode.

#endif

void get(const int pos, otl_datetime& s); // gets an otl_datetime

bool is_null(const int pos);
// returns true if the value at position "pos" is NULL.
// Otherwise, returns false.

#if defined(OTL_STL) || defined(OTL_STLPORT) || defined(OTL_ACE)

// The following functions are available
// only when #define OTL_STL or OTL_STLPORT or OTL_ACE is enabled.

// JDBC-like getter (by name) functions.
// var_name is a variable / column name from the list that can be retrieved by a call
// to the describe() function of this class. All variable names are case insensitive.
void get(const char* var_name, char& c); // gets a char
void get(const char* var_name, unsigned char& c); // gets an unsigned char
void get(const char* var_name, char* s); // gets a null terminated char string
void get(const char* var_name, unsigned char* s); // gets a null terminated unsigned char string
void get(const char* var_name, int& n); // gets a signed 32-bit int
void get(const char* var_name, unsigned int& n); // gets a unsigned 32-bit int
void get(const char* var_name, short int& n); // gets a signed 16-bit int
void get(const char* var_name, long int& n); // gets a signed long 32-bit int
void get(const char* var_name, float& n); // gets a 4-byte floating point
void get(const char* var_name, double& n); // gets an 8-byte floating point
void get(const char* var_name, OTL_BIGINT& n); // gets a signed 64-bit int
void get(const char* var_name, OTL_STRING_CONTAINER& s);
// gets an std::string if #define OTL_STL is enabled.
// VARCHAR, CHAR, LONG, TEXT, and CLOB values can be read by this function.

void get(const char* var_name, otl_long_string& s); // gets an otl_long_string
void get(const char* var_name, otl_long_string*& s);
// gets a pointer to otl_long_string. This is more optimal than the previous
// function, especially in the case of a large string.

#if !defined(OTL_ORA7)
// when any flavor of OTL but OTL_ORA7 is defined:
// OTL_ORA8, OTL_ORA8I, OTL_ORA9I, OTL_ORA10G,
// OTL_ORA10G_R2, OTL_ODBC, OTL_DB2_CLI

void get(const char* var_name, otl_lob_stream*& s);
// gets a pointer to otl_lob_stream. This function can be used if the otl_stream
// that the read iterator is attached to is in the LOB stream mode.

#endif

void get(const char* var_name, otl_datetime& s); // gets an otl_datetime

bool is_null(const char* pos);
// returns true if the value of the "var_name" variable is NULL.
// Otherwise, returns false.
#endif
}; // end of otl_stream_read_iterator

Prev NextContentsGo Home

Copyright © 1996, 2007, Sergei Kuchin, email: skuchin@ispwest.com, skuchin@gmail.com .

Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies.