📄 otlv4.h
字号:
#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// %%%//#define OTL_DEBUG//======================= 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_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;}#define OTL_NO_STM_TEXT "#No Stm Text available#"class otl_datetime{public: int year; int month; int day; int hour; int minute; int second; unsigned long fraction; int frac_precision;#if defined(OTL_ORA_TIMESTAMP) short int tz_hour; short int tz_minute;#endif otl_datetime() { year=1900; month=1; day=1; hour=0; minute=0; second=0; fraction=0; frac_precision=0;#if defined(OTL_ORA_TIMESTAMP) tz_hour=0; tz_minute=0;#endif } otl_datetime (const int ayear, const int amonth, const int aday, const int ahour, const int aminute, const int asecond, const unsigned long afraction=0, const int afrac_precision=0#if defined(OTL_ORA_TIMESTAMP) , const short int atz_hour=0, const short int atz_minute=0#endif ) { year=ayear; month=amonth; day=aday; hour=ahour; minute=aminute; second=asecond; fraction=afraction; frac_precision=afrac_precision;#if defined(OTL_ORA_TIMESTAMP) tz_hour=atz_hour; tz_minute=atz_minute;#endif } otl_datetime(const otl_datetime& dt) { copy(dt); } ~otl_datetime(){} otl_datetime& operator=(const otl_datetime& dt) { copy(dt); return *this; }protected: void copy(const otl_datetime& dt) { year=dt.year; month=dt.month; day=dt.day; hour=dt.hour; minute=dt.minute; second=dt.second; fraction=dt.fraction; frac_precision=dt.frac_precision;#if defined(OTL_ORA_TIMESTAMP) tz_hour=dt.tz_hour; tz_minute=dt.tz_minute;#endif }};class otl_oracle_date{public: unsigned char century; unsigned char year; unsigned char month; unsigned char day; unsigned char hour; unsigned char minute; unsigned char second; otl_oracle_date(){} ~otl_oracle_date(){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -