⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 otlv4.h

📁 一个跨平台的数据库操作库文件,可以轻松在linux和windows下进行数据库读写以及其他的操作,支持多种数据库,代码包含很多example,初学者很容易上手. OTL 是 Oracle, Odbc
💻 H
📖 第 1 页 / 共 5 页
字号:
  virtual ~otl_long_unicode_string(){}    OTL_CHAR& operator[](int ndx)  {    return OTL_RCAST(OTL_CHAR*,v)[ndx];  }  virtual void null_terminate_string(const int alen)  {    (*this)[alen]=0;  }};#endifinline const char* otl_var_type_name(const int ftype){  const char* const_CHAR="CHAR";  const char* const_DOUBLE="DOUBLE";  const char* const_FLOAT="FLOAT";  const char* const_INT="INT";  const char* const_UNSIGNED_INT="UNSIGNED INT";  const char* const_SHORT_INT="SHORT INT";  const char* const_LONG_INT="LONG INT";  const char* const_TIMESTAMP="TIMESTAMP";  const char* const_DB2DATE="DB2DATE";  const char* const_DB2TIME="DB2TIME";  const char* const_TZ_TIMESTAMP="TIMESTAMP WITH TIME ZONE";  const char* const_LTZ_TIMESTAMP="TIMESTAMP WITH LOCAL TIME ZONE";  const char* const_BIGINT="BIGINT";  const char* const_VARCHAR_LONG="VARCHAR LONG";  const char* const_RAW_LONG="RAW LONG";  const char* const_CLOB="CLOB";  const char* const_BLOB="BLOB";  const char* const_RAW="RAW";  const char* const_UNKNOWN="UNKNOWN";  const char* const_LONG_STRING="otl_long_string()";  const char* const_LOB_STREAM="otl_lob_stream*&";  const char* const_USER_DEFINED="User-defined type (object type, VARRAY, Nested Table)";    switch(ftype){  case otl_var_char:    return const_CHAR;  case otl_var_double:    return const_DOUBLE;  case otl_var_float:    return const_FLOAT;  case otl_var_int:    return const_INT;  case otl_var_unsigned_int:    return const_UNSIGNED_INT;  case otl_var_short:    return const_SHORT_INT;  case otl_var_long_int:    return const_LONG_INT;  case otl_var_timestamp:    return const_TIMESTAMP;  case otl_var_db2date:    return const_DB2DATE;  case otl_var_db2time:    return const_DB2TIME;  case otl_var_tz_timestamp:    return const_TZ_TIMESTAMP;  case otl_var_ltz_timestamp:    return const_LTZ_TIMESTAMP;  case otl_var_bigint:    return const_BIGINT;  case otl_var_varchar_long:    return const_VARCHAR_LONG;  case otl_var_raw_long:    return const_RAW_LONG;  case otl_var_clob:    return const_CLOB;  case otl_var_blob:    return const_BLOB;  case otl_var_raw:    return const_RAW;  case otl_var_long_string:    return const_LONG_STRING;  case otl_var_lob_stream:    return const_LOB_STREAM;  case 108:    return const_USER_DEFINED; default:  return const_UNKNOWN; }}inline void otl_var_info_var(const char* name, const int ftype, const int type_code, char* var_info,#if defined(_MSC_VER)#if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz#else const size_t /*var_info_sz*/#endif#else const size_t /*var_info_sz*/#endif){char buf1[128]; char buf2[128]; OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code)); OTL_STRCPY_S(var_info,var_info_sz,"Variable: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info,var_info_sz,">, datatype in operator <</>>: "); OTL_STRCAT_S(var_info,var_info_sz,buf2);}inline void otl_var_info_var2(const char* name, const int ftype, char* var_info,#if defined(_MSC_VER)#if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz#else const size_t /*var_info_sz*/#endif#else const size_t /*var_info_sz*/#endif){char buf1[128]; OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(var_info,var_info_sz,"Variable: "); OTL_STRCPY_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info,var_info_sz,">");}inline void otl_var_info_var3(const char* name, const int ftype, const int type_code, char* var_info,#if defined(_MSC_VER)#if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz#else const size_t /*var_info_sz*/#endif#else const size_t /*var_info_sz*/#endif){char buf1[128]; char buf2[128]; OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code)); OTL_STRCPY_S(var_info,var_info_sz,"Variable: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info,              var_info_sz,              ">, datatype in otl_stream_read_iterator::get(): "); OTL_STRCAT_S(var_info,var_info_sz,buf2);}inline void otl_var_info_var4(const char* name, const int ftype, const int type_code, char* var_info,#if defined(_MSC_VER)#if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz#else const size_t /*var_info_sz*/#endif#else const size_t /*var_info_sz*/#endif){char buf1[128]; char buf2[128]; OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code)); OTL_STRCPY_S(var_info,var_info_sz,"Variable: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info,              sizeof(var_info),              ">, datatype in otl_stream_read_iterator::get(): "); OTL_STRCAT_S(var_info,sizeof(var_info),buf2);}inline void otl_strcpy(  unsigned char* trg,  unsigned char* src,  int& overflow,  const int inp_size=0,  const int actual_inp_size=-1){  OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);  const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src);  int out_size=0;  overflow=0;  if(actual_inp_size!=-1){    while(out_size<inp_size-1 && out_size<actual_inp_size){      *c1++=*c2++;      ++out_size;    }    *c1=0;    if(out_size==inp_size-1 && out_size<actual_inp_size)      overflow=1;  }else{    while(*c2 && out_size<inp_size-1){      *c1++=*c2++;      ++out_size;    }    *c1=0;    if(*c2 && out_size==inp_size-1)      overflow=1;  }}#if defined(OTL_UNICODE) || (defined(_MSC_VER) && (_MSC_VER >= 1400))inline void otl_strcpy (unsigned char* trg,  const unsigned char* src){ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src); while(*c2){  *c1++=*c2++; } *c1=0;}#elseinline void otl_strcpy(unsigned char* trg,const unsigned char* src){  strcpy(OTL_RCAST(char*,trg),OTL_RCAST(const char*,src));}#endifinline void otl_strcat(char* trg,const char* src){  while(*trg)++trg;  while(*src){    *trg=*src;    ++trg;    ++src;  }  *trg=0;}#if defined(OTL_UNICODE) && !defined(OTL_ODBC)inline void otl_strcpy2(  unsigned char* trg,  const unsigned char* src,  const int max_src_len){ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src); int src_len=OTL_SCAST(int,*OTL_SCAST(const unsigned short*,c2)); int len=0; ++c2; while(*c2&&len<max_src_len&&len<src_len){  *c1++=*c2++;  ++len; } *c1=0;#elseinline void otl_strcpy2(  unsigned char* trg,  const unsigned char* src,  const int /* max_src_len */){ otl_strcpy(trg,src);#endif}#if defined(OTL_UNICODE)inline void otl_memcpy(  unsigned char* trg,  unsigned char* src,  const int src_len,  const int ftype){  if(ftype==otl_var_raw_long||ftype==otl_var_raw){    memcpy(trg,src,src_len);    return;  }  OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);  OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src);  int len=0;  while(len<src_len){    *c1++=*c2++;    ++len;  }#elseinline void otl_memcpy(  unsigned char* trg,  unsigned char* src,  const int src_len,  const int /* ftype */){ memcpy(trg,src,src_len);#endif}#if defined(OTL_UNICODE) && !defined(OTL_ODBC)inline void otl_strcpy3(  unsigned char* trg,  unsigned char* src,  const int max_src_len,  int& overflow,  const int inp_size=0){ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src); int len=0; int src_len=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c2)); ++c2; int out_size=0; overflow=0; while(len<src_len&&len<max_src_len&&out_size<inp_size-1){  *c1++=*c2++;  ++out_size;  ++len; } *c1=0; if(len<src_len&&out_size==inp_size-1)  overflow=1;#elseinline void otl_strcpy3(  unsigned char* trg,  unsigned char* src,  const int /* max_src_len */,  int& overflow,  const int inp_size=0){ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src); int out_size=0; overflow=0; while(*c2&&out_size<inp_size-1){  *c1++=*c2++;  ++out_size; } *c1=0; if(*c2&&out_size==inp_size-1)  overflow=1;#endif}inline void otl_strcpy4(  unsigned char* trg,  unsigned char* src,  int& overflow,  const int inp_size=0,  const int actual_inp_size=-1){#if  defined(OTL_UNICODE) && !defined(OTL_ODBC)  OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);  OTL_CHAR* bc1=c1;  ++c1;  OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src);  int out_size=0;  overflow=0;  if(actual_inp_size!=-1){    while(out_size<inp_size-1 && out_size<actual_inp_size){      *c1++=*c2++;      ++out_size;    }    *OTL_RCAST(unsigned short*,bc1)=OTL_SCAST(unsigned short,out_size);    if(out_size==inp_size-1 && out_size<actual_inp_size)      overflow=1;  }else{    while(*c2&&out_size<inp_size-1){     *c1++=*c2++;     ++out_size;    }    *OTL_RCAST(unsigned short*,bc1)=OTL_SCAST(unsigned short,out_size);    if(*c2&&out_size==inp_size-1)      overflow=1;  }#else  OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);  OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src);  int out_size=0;  overflow=0;  if(actual_inp_size!=-1){    while(out_size<inp_size-1 && out_size<actual_inp_size){      *c1++=*c2++;      ++out_size;    }    *c1=0;    if(out_size==inp_size-1 && out_size<actual_inp_size)      overflow=1;  }else{    while(*c2&&out_size<inp_size-1){      *c1++=*c2++;      ++out_size;    }    *c1=0;    if(*c2&&out_size==inp_size-1)      overflow=1;  }#endif}inline char* otl_itoa(int i,char* a){  const char* digits="0123456789";  int n=i;  int k;  char buf[64];  char* c=buf;  char *c1=a;  int klen=0;  char digit=' ';  bool negative=false;  if(n<0){    n=-n;    negative=true;  }  do{    if(n>=10)      k=n%10;    else      k=n;    digit=digits[k];    *c=digit;    ++c;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -