📄 otlv4.h
字号:
#define OTL_CONST_EXCEPTION#define OTL_THROWS_OTL_EXCEPTION#define OTL_NO_THROW#define OTL_TYPE_NAME class#endif#define OTL_PCONV(_to,_from,_val) \OTL_SCAST(_to,*OTL_RCAST(_from*,OTL_CCAST(void*,_val)))#if defined(OTL_ACE)#include <ace/SString.h>#include <ace/Array.h>#include <ace/Functor.h>#include <ace/RB_Tree.h>#define OTL_USER_DEFINED_STRING_CLASS_ON#define USER_DEFINED_STRING_CLASS ACE_TString#define OTL_VALUE_TEMPLATE_ONconst int otl_tmpl_vector_default_size=16;template<OTL_TYPE_NAME T>class otl_tmpl_vector: public ACE_Array<T>{public: otl_tmpl_vector(const int init_size=otl_tmpl_vector_default_size) : ACE_Array<T>(init_size==0?otl_tmpl_vector_default_size:init_size) { _length=0; } ~otl_tmpl_vector(){} int capacity(void) const { return this->max_size(); } int size(void) const { return _length; } void clear(void) { _length=0; } void resize(const int new_size, const T& t=T()) { ACE_Array<T>::size(new_size); if(new_size>_length){ for(int i=_length;i<new_size;++i) (*this)[i]=t; } _length=new_size; } void push_back(const T& elem) { int curr_max_size=this->max_size(); if(_length==curr_max_size) ACE_Array<T>::size(curr_max_size*2); ++_length; (*this)[_length-1]=elem; } void pop_back(void) { if(_length>0) --_length; }protected: int _length; };#endif#if defined(OTL_STLPORT)#if defined(__STLPORT_STD)#define OTL_STLPORT_NAMESPACE __STLPORT_STD#else#if defined(_STLP_USE_OWN_NAMESPACE)#define OTL_STLPORT_NAMESPACE _STL#else#define OTL_STLPORT_NAMESPACE std#endif#endif#define OTL_STL#endif#if defined(OTL_VALUE_TEMPLATE_ON) && !defined(OTL_STL) && !defined(OTL_ACE)#define STD_NAMESPACE_PREFIX#if (defined(_MSC_VER)&&(_MSC_VER>=1300))||defined(OTL_ANSI_CPP)#include <iostream>using namespace std;#else#include <iostream.h>#endif#endif#if defined(OTL_USER_DEFINED_STRING_CLASS_ON)#if defined(OTL_STL)#error OTL_STL cannot be used in combination with OTL_USER_DEFINED_STRING_CLASS_ON#endif#if defined(USER_DEFINED_STRING_CLASS)#define OTL_STRING_CONTAINER USER_DEFINED_STRING_CLASS#define STD_NAMESPACE_PREFIX#else#error USER_DEFINED_STRING_CLASS macro needs to be defined before including otlv4.h#endif#endif#if defined(OTL_STL)#if defined(_MSC_VER)#if (_MSC_VER >= 1200)#pragma warning (disable:4786) #pragma warning (disable:4290)#pragma warning (disable:4996)#endif#endif#if defined(OTL_STL_NOSTD_NAMESPACE)#ifndef OTL_STRING_CONTAINER#define OTL_STRING_CONTAINER string#endif#define STD_NAMESPACE_PREFIX#else#ifndef OTL_STRING_CONTAINER#if defined(OTL_STLPORT)#define OTL_STRING_CONTAINER OTL_STLPORT_NAMESPACE ::string#else#define OTL_STRING_CONTAINER std::string#endif#endif#if defined(OTL_STLPORT)#define STD_NAMESPACE_PREFIX OTL_STLPORT_NAMESPACE ::#else#define STD_NAMESPACE_PREFIX std::#endif#endif#include <string>#include <iterator>#include <vector>#if defined(OTL_UNCAUGHT_EXCEPTION_ON)#include <exception>#endif#ifndef OTL_STL_NOSTD_NAMESPACE#include <iostream>#else#if defined(_MSC_VER) && (_MSC_VER >= 1300)#include <iostream>using namespace std;#else#include <iostream.h>#endif#endif#endif//======================= END OF CONFIGURATION ==============================// ====== COMMON NON-TEMPLATE OBJECTS: CONSTANTS, CLASSES, ETC. ===========#if defined(OTL_ORA8)const int otl_var_list_size=1024;#elseconst int otl_var_list_size=512;#endifconst int otl_error_code_0=32000;#define otl_error_msg_0 "Incompatible data types in stream operation"const int otl_error_code_1=32004;#define otl_error_msg_1 "No input variables have been defined in SQL statement"const int otl_error_code_2=32003;#define otl_error_msg_2 "Not all input variables have been initialized"const int otl_error_code_3=32001;#define otl_error_msg_3 "Row must be full for flushing output stream"const int otl_error_code_4=32005;#define otl_error_msg_4 "Input string value is too large to fit into the buffer"const int otl_error_code_5=32006;#define otl_error_msg_5 "Input otl_long_string is too large to fit into the buffer"const int otl_error_code_6=32007;#define otl_error_msg_6 "PL/SQL table size is too large (>32767)"const int otl_error_code_7=32008;#define otl_error_msg_7 "Writing CLOB/BLOB in stream mode: actual size is greater than specified"const int otl_error_code_8=32009;#define otl_error_msg_8 "Closing CLOB/BLOB in stream mode: actual size is not equal to specified size"const int otl_error_code_9=32010;#define otl_error_msg_9 "CLOB/BLOB stream is not open for writing"const int otl_error_code_10=32011;#define otl_error_msg_10 "CLOB/BLOB stream is not open for reading"const int otl_error_code_11=32012;#define otl_error_msg_11 "First session must be started with session_begin()"const int otl_error_code_12=32013;#define otl_error_msg_12 "Invalid bind variable declaration"const int otl_error_code_13=32014;#define otl_error_msg_13 "No stored procedure was found"const int otl_error_code_14=32015;#define otl_error_msg_14 "Unsupported data type: "const int otl_error_code_15=32016;#define otl_error_msg_15 "Unsupported procedure type"const int otl_error_code_16=32017;#define otl_error_msg_16 "Stream buffer size can't be > 1 in this case"const int otl_error_code_17=32018;#define otl_error_msg_17 \"ODBC / DB2 CLI function name is not recognized. " \"It should be one of the following: SQLTables, SQLColumns, " \"SQLProcedures, SQLColumnPrivileges, SQLTablePrivileges, " \"SQLPrimaryKeys, SQLProcedureColumns, SQLForeignKeys"const int otl_error_code_18=32019;#define otl_error_msg_18 \"otl_stream::operator>>() should have been called " \"before otl_stream::operator int()"const int otl_error_code_19=32020;#define otl_error_msg_19 \"otl_stream_read_iterator: otl_stream is not open"const int otl_error_code_20=32021;#define otl_error_msg_20 \"otl_stream_read_iterator: PL/SQL table and 'refcur' " \"parameters are not supported"const int otl_error_code_21=32022;#define otl_error_msg_21 \"otl_stream_read_iterator: otl_stream cannot be described" const int otl_error_code_22=32023;#define otl_error_msg_22 \"otl_stream_read_iterator: position is out of range" const int otl_error_code_23=32024;#define otl_error_msg_23 \"otl_stream_read_iterator: incompatible types in get()" const int otl_error_code_24=32025;#define otl_error_msg_24 \"otl_stream::operator int() is not supported in the LOB stream mode"const int otl_error_code_25=32026;#define otl_error_msg_25 \"otl_stream_read_iterator: get(otl_lob_stream*&) function " \"can only be used if otl_stream::set_lob_stream_mode(true) had been called " \"before the iterator was attached to the stream"const int otl_error_code_26=32027;#define otl_error_msg_26 \"otl_stream_read_iterator: variable name is not recognized " const int otl_error_code_27=32028;#define otl_error_msg_27 "Unsupported column data type" const int otl_error_code_28=32029;#define otl_error_msg_28 \"RAW value cannot be read with otl_lob_stream, use otl_long_string instead" const int otl_error_code_29=32030;#define otl_error_msg_29 \"otl_stream is already open" const int otl_error_code_30=32031;#define otl_error_msg_30 \"otl_connect is already connected" const int otl_error_code_31=32032;#define otl_error_msg_31 \"SELECT otl_stream buffer size for TimesTen should be in [1..128] range" const int otl_error_code_32=32033;#define otl_error_msg_32 \"otl_connect object needs to be connected to DB before using otl_subscriber" const int otl_oracle_date_size=7;const int otl_explicit_select=0;const int otl_implicit_select=1;const int otl_input_param=0;const int otl_output_param=1;const int otl_inout_param=2;const unsigned int otl_all_num2str=1;const unsigned int otl_all_date2str=2;const int otl_num_str_size=60;const int otl_date_str_size=60;class otl_select_struct_override{public: short int* col_ndx; short int* col_type; int* col_size; int len; unsigned int all_mask; bool lob_stream_mode; otl_select_struct_override() { container_size_=otl_var_list_size; col_ndx=new short int[container_size_]; col_type=new short int[container_size_]; col_size=new int[container_size_]; reset(); } void reset(void) { len=0; all_mask=0; lob_stream_mode=false; } ~otl_select_struct_override() { delete[] col_ndx; delete[] col_type; delete[] col_size; } void add_override(const int andx, const int atype, const int asize=0) { if(len==otl_var_list_size){ int temp_container_size=container_size_; container_size_*=2; short int* temp_col_ndx=new short int[container_size_]; short int* temp_col_type=new short int[container_size_]; int* temp_col_size=new int[container_size_]; memcpy(temp_col_ndx,col_ndx,sizeof(short int)*temp_container_size); memcpy(temp_col_type,col_type,sizeof(short int)*temp_container_size); memcpy(temp_col_size,col_size,sizeof(int)*temp_container_size); delete[] col_ndx; delete[] col_type; delete[] col_size; col_ndx=temp_col_ndx; col_type=temp_col_type; col_size=temp_col_size; } ++len; col_ndx[len-1]=OTL_SCAST(short,andx); col_type[len-1]=OTL_SCAST(short,atype); col_size[len-1]=asize; } int find(const int ndx) { int i; for(i=0;i<len;++i) if(ndx==col_ndx[i]) return i; return -1; } void set_all_column_types(const unsigned int amask=0) { all_mask=amask; } int getLen(void){return len;}protected: int container_size_; };inline int otl_decimal_degree(unsigned int num){ int n=0; while(num!=0){ ++n; num/=10; } return n;}inline bool otl_isspace(char c){ return c==' '||c=='\t'||c=='\n'|| c=='\r'||c=='\f'||c=='\v';}inline char otl_to_upper(char c){ return OTL_SCAST(char,toupper(c));}inline unsigned int otl_to_fraction(unsigned int fraction,int frac_prec){ if(fraction==0||frac_prec==0)return fraction; int degree_diff=9-frac_prec; for(int i=0;i<degree_diff;++i) fraction*=10; return fraction;}inline unsigned int otl_from_fraction(unsigned int fraction,int frac_prec){ if(fraction==0||frac_prec==0)return fraction; int degree_diff=9-frac_prec; for(int i=0;i<degree_diff;++i) fraction/=10; return fraction;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -