📄 otlv4.h
字号:
strcat(var_info,">, datatype in otl_stream_read_iterator::get(): "); strcat(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); 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; }}#if defined(OTL_UNICODE) || defined(_MSC_VER)inline void otl_strcpy (unsigned char* trg, unsigned char* src){ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src); while(*c2){ *c1++=*c2++; } *c1=0;}#elseinline void otl_strcpy(unsigned char* trg,unsigned char* src){ strcpy(OTL_RCAST(char*,trg),OTL_RCAST(const char*,src));}#endif#if defined(OTL_UNICODE) && !defined(OTL_ODBC)inline void otl_strcpy2( unsigned char* trg, unsigned char* src, const int max_src_len){ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src); int src_len=OTL_SCAST(int,*OTL_SCAST(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, 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; ++klen; n=n/10; }while(n!=0); *c=0; if(negative){ *c1='-'; ++c1; } for(int j=klen-1;j>=0;--j){ *c1=buf[j]; ++c1; } *c1=0; return c1;}inline void otl_var_info_col(const int pos, const int ftype, const int type_code, char* var_info){ char buf1[128]; char buf2[128]; char name[128]; otl_itoa(pos,name); strcpy(buf1,otl_var_type_name(ftype)); strcpy(buf2,otl_var_type_name(type_code)); strcpy(var_info,"Column: "); strcat(var_info,name); strcat(var_info,"<"); strcat(var_info,buf1); strcat(var_info,">, datatype in operator <</>>: "); strcat(var_info,buf2);}inline void otl_var_info_col2(const int pos, const int ftype, char* var_info){ char buf1[128]; char name[128]; otl_itoa(pos,name); strcpy(buf1,otl_var_type_name(ftype)); strcpy(var_info,"Column: "); strcat(var_info,name); strcat(var_info,"<"); strcat(var_info,buf1); strcat(var_info,">");}inline void otl_var_info_col3(const int pos, const int ftype, const char* col_name, char* var_info){ char buf1[128]; char name[128]; otl_itoa(pos,name); strcpy(buf1,otl_var_type_name(ftype)); strcpy(var_info,"Column: "); strcat(var_info,name); strcat(var_info," / "); strcat(var_info,col_name); strcat(var_info," <"); strcat(var_info,buf1); strcat(var_info,">");}class otl_pl_tab_generic{public: unsigned char* p_v; short* p_null; int elem_size; int tab_size; int tab_len; int vtype; otl_pl_tab_generic() { elem_size=0; tab_size=0; tab_len=0; p_v=0; p_null=0; vtype=0; } virtual ~otl_pl_tab_generic(){} unsigned char* val(int ndx=0) { return p_v+(ndx*elem_size); } int is_null(int ndx=0) { return p_null[ndx]!=0; } void set_null(int ndx=0) { p_null[ndx]=1; } void set_non_null(int ndx=0) { p_null[ndx]=0; } void init_generic(void) {int i; memset(p_v,0,elem_size*tab_len); for(i=0;i<tab_len;++i) p_null[i]=0; } int len() { return tab_len; } void set_len(int new_len=0) { tab_len=new_len; }};#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)template<OTL_TYPE_NAME T,const int T_type>inline int otl_numeric_convert_T(const int ftype,const void* val,T& n){ if(ftype==T_type){ n=*OTL_RCAST(T*,OTL_CCAST(void*,val)); return 1; }else return 0;}template<OTL_TYPE_NAME T>inline int otl_numeric_convert_T2(const int ftype,const void* val,T& n){ int rc=1; switch(ftype){ case otl_var_double: n=OTL_PCONV(T,double,val); break; case otl_var_short: n=OTL_PCONV(T,short,val); break; case otl_var_int: n=OTL_PCONV(T,int,val); break; case otl_var_unsigned_int: n=OTL_PCONV(T,unsigned int,val); break; case otl_var_long_int: n=OTL_PCONV(T,long int,val); break; case otl_var_float: n=OTL_PCONV(T,float,val); break;#if defined(OTL_BIGINT) case otl_var_bigint: n=OTL_PCONV(T,OTL_BIGINT,val); break;#endif default: rc=0; break; } return rc; }#elsetemplate<OTL_TYPE_NAME T>inline int otl_numeric_convert_T(const int ftype,const void* val,T& n){ int rc=1; switch(ftype){ case otl_var_double: n=OTL_PCONV(T,double,val); break; case otl_var_short: n=OTL_PCONV(T,short,val); break; case otl_var_int: n=OTL_PCONV(T,int,val); break; case otl_var_unsigned_int: n=OTL_PCONV(T,unsigned int,val); break; case otl_var_long_int: n=OTL_PCONV(T,long int,val); break; case otl_var_float: n=OTL_PCONV(T,float,val); break;#if defined(OTL_BIGINT) case otl_var_bigint: n=OTL_PCONV(T,OTL_BIGINT,val); break;#endif default: rc=0; break; } return rc; }#endif#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)class otl_ltstr{public: bool operator()(const OTL_STRING_CONTAINER& s1, const OTL_STRING_CONTAINER& s2) const {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -