StDbBuffer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
#ifndef STDBBUFFER_H
00046
#define STDBBUFFER_H
00047
#ifndef __CINT__
00048
#include "mysql.h"
00049
#include "mysql_com.h"
00050
#endif
00051
00052
#include "StDbBufferI.h"
00053
00054 enum myctype{
_char,
_uchar,
_short,
_ushort,
_int,
_uint,
_long,
_ulong,
_longlong,
_float,
_double,
_ascii,
_string};
00055
00056 const int mycsize[]={
sizeof(
char),
sizeof(
unsigned char),
sizeof(
short),
sizeof(
unsigned short),
sizeof(
int),
sizeof(
unsigned int),
sizeof(
long),
sizeof(
unsigned long),
sizeof(
long long),
sizeof(
float),
sizeof(
double),
sizeof(
char*),
sizeof(
char*)};
00057
00058
#if defined(__sun) && !defined(__i386) || defined(__hpux) || defined(__alpha) && !defined(linux)
00059
const int mycswapl[]={1,1,1,1,4,4,4,4,8,4,8,1,1};
00060
#else
00061 const int mycswapl[]={1,1,1,1,1,1,1,1,1,1,1,1};
00062
#endif
00063
00064 struct column {
00065 char*
name;
00066 enum myctype type;
00067 char *
val;
00068 unsigned length; };
00069
00070 enum BuffMode{
Auto,
Client,
Storage};
00071
00072 class StDbBuffer :
public StDbBufferI {
00073
00074
00075
private:
00076
00077 int mMax;
00078 int mCur;
00079 int mLast;
00080 column *
mCol;
00081 BuffMode mMode;
00082
00083
void zeroColumn(
int istart,
int iend);
00084
00085
public:
00086
00087 StDbBuffer(){
00088
mCur=0;
00089
mLast=-1;
00090
mMax=100;
00091
mCol=
new column[
mMax+1];
00092 zeroColumn(0,
mMax);
00093
mMode=
Storage;
00094 };
00095
00096 StDbBuffer(
unsigned int anum_fields,
column *acol){
00097
Init( anum_fields,acol);}
00098
00099 void Init(
unsigned int anum_fields,
column * acol){
00100
mCur=0;
00101
mLast=anum_fields;
00102
mCol=acol;};
00103
00104 ~StDbBuffer(){
Raz();
delete []
mCol; };
00105
00106 virtual void SetClientMode() {
mMode=
Client;};
00107 virtual void SetStorageMode() {
mMode=
Storage;};
00108 virtual bool IsClientMode() {
return (
mMode==
Client) ?
true :
false;};
00109 virtual bool IsStorageMode() {
return (
mMode==
Storage) ?
true :
false;};
00110
00111
void Raz();
00112
void Print();
00113
00114
virtual char**
WhatsIn();
00115
00116
virtual bool ReadScalar(
char &c,
const char *aName) ;
00117
virtual bool ReadScalar(
unsigned char &c,
const char *) ;
00118
virtual bool ReadScalar(
short &h,
const char *) ;
00119
virtual bool ReadScalar(
unsigned short &h,
const char *) ;
00120
virtual bool ReadScalar(
int &i,
const char *) ;
00121
virtual bool ReadScalar(
unsigned int &i,
const char *) ;
00122
virtual bool ReadScalar(
long &l,
const char *) ;
00123
virtual bool ReadScalar(
unsigned long &l,
const char *) ;
00124
virtual bool ReadScalar(
long long &l,
const char *) ;
00125
virtual bool ReadScalar(
float &f,
const char *) ;
00126
virtual bool ReadScalar(
double &d,
const char *) ;
00127
virtual bool ReadScalar(
char *&c,
const char *) ;
00128
00129
virtual bool WriteScalar(
const char c,
const char *) ;
00130
virtual bool WriteScalar(
const unsigned char c,
const char *) ;
00131
virtual bool WriteScalar(
const short h,
const char *) ;
00132
virtual bool WriteScalar(
const unsigned short h,
const char *) ;
00133
virtual bool WriteScalar(
const int i,
const char *) ;
00134
virtual bool WriteScalar(
const unsigned int i,
const char *) ;
00135
virtual bool WriteScalar(
const long l,
const char *) ;
00136
virtual bool WriteScalar(
const unsigned long l,
const char *) ;
00137
virtual bool WriteScalar(
const long long l,
const char *) ;
00138
virtual bool WriteScalar(
const float f,
const char *) ;
00139
virtual bool WriteScalar(
const double d,
const char *) ;
00140
virtual bool WriteScalar(
const char *c,
const char *);
00141
00142
virtual bool ReadArray(
char *&c,
int &len,
const char *);
00143
virtual bool ReadArray(
unsigned char *&c,
int &len,
const char *);
00144
virtual bool ReadArray(
short *&c,
int &len,
const char *);
00145
virtual bool ReadArray(
unsigned short *&c,
int &len,
const char *);
00146
virtual bool ReadArray(
int *&c,
int &len,
const char *);
00147
virtual bool ReadArray(
unsigned int *&c,
int &len,
const char *);
00148
virtual bool ReadArray(
long *&c,
int &len,
const char *);
00149
virtual bool ReadArray(
unsigned long *&c,
int &len,
const char *);
00150
virtual bool ReadArray(
long long *&c,
int &len,
const char *);
00151
virtual bool ReadArray(
float *&c,
int &len,
const char *);
00152
virtual bool ReadArray(
double *&c,
int &len,
const char *);
00153
virtual bool ReadArray(
char **&c,
int &len,
const char *);
00154
00155
virtual bool WriteArray(
char *c,
int len,
const char *);
00156
virtual bool WriteArray(
unsigned char *c,
int len,
const char *);
00157
virtual bool WriteArray(
short *c,
int len,
const char *);
00158
virtual bool WriteArray(
unsigned short *c,
int len,
const char *);
00159
virtual bool WriteArray(
int *c,
int len,
const char *);
00160
virtual bool WriteArray(
unsigned int *c,
int len,
const char *);
00161
virtual bool WriteArray(
long *c,
int len,
const char *);
00162
virtual bool WriteArray(
unsigned long *c,
int len,
const char *);
00163
virtual bool WriteArray(
long long *c,
int len,
const char *);
00164
virtual bool WriteArray(
float *c,
int len,
const char *);
00165
virtual bool WriteArray(
double *c,
int len,
const char *);
00166
virtual bool WriteArray(
char **c,
int len,
const char *);
00167
00168
00169
00170
protected:
00171
00172
00173
bool Find_Col (
const char *aName);
00174
void AddField(
const char *aName,
const myctype aTpe,
const void* aVal,
const int aLen);
00175
void ChangeField(
const myctype aTpe,
const void* aVal,
const int aLen);
00176
00177
00178
00179
bool WriteMem(
char *s,
void* aVal, myctype type);
00180
bool WriteMem(
unsigned char *s,
void* aVal, myctype type);
00181
bool WriteMem(
short *s,
void* aVal, myctype type);
00182
bool WriteMem(
unsigned short *s,
void* aVal, myctype type);
00183
bool WriteMem(
int *s,
void* aVal, myctype type);
00184
bool WriteMem(
unsigned int *s,
void* aVal, myctype type);
00185
bool WriteMem(
long *s,
void* aVal, myctype type);
00186
bool WriteMem(
unsigned long *s,
void* aVal, myctype type);
00187
bool WriteMem(
long long *s,
void* aVal, myctype type);
00188
bool WriteMem(
float *s,
void* aVal, myctype type);
00189
bool WriteMem(
double *s,
void* aVal, myctype type);
00190
bool WriteMem(
char **s,
void* aVal, myctype type);
00191
00192
void StrConv(
char* aVal,
char &s);
00193
void StrConv(
char* aVal,
unsigned char &s);
00194
void StrConv(
char* aVal,
short &s);
00195
void StrConv(
char* aVal,
unsigned short &s);
00196
void StrConv(
char* aVal,
int &s);
00197
void StrConv(
char* aVal,
unsigned int &s);
00198
void StrConv(
char* aVal,
long &s);
00199
void StrConv(
char* aVal,
unsigned long &s);
00200
void StrConv(
char* aVal,
long long &s);
00201
void StrConv(
char* aVal,
float &s);
00202
void StrConv(
char* aVal,
double &s);
00203
void StrConv(
char* aVal,
char* &s);
00204
00205
void MemSwapCpy(
char* where,
char* from,
int len,
int swaplen,BuffMode mode);
00206
00207
00208
00209
00210 };
00211
00212
00213
00214
#endif
00215
00216
00217
00218
00219
00220
Generated on Thu Aug 24 14:45:25 2006 for Doxygen by
1.3.7