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
00037 #ifndef DB1_VAL_H
00038 #define DB1_VAL_H
00039
00040 #include "db_con.h"
00041 #include <time.h>
00042 #include "../../str.h"
00043
00044
00051 typedef enum {
00052 DB1_INT,
00053 DB1_BIGINT,
00054 DB1_DOUBLE,
00055 DB1_STRING,
00056 DB1_STR,
00057 DB1_DATETIME,
00058 DB1_BLOB,
00059 DB1_BITMAP
00060 } db_type_t;
00061
00062
00077 typedef struct {
00078 db_type_t type;
00079 int nul;
00080 int free;
00082 union {
00083 int int_val;
00084 long long ll_val;
00085 double double_val;
00086 time_t time_val;
00087 const char* string_val;
00088 str str_val;
00089 str blob_val;
00090 unsigned int bitmap_val;
00091 } val;
00092 } db_val_t;
00093
00094
00103 #define VAL_TYPE(dv) ((dv)->type)
00104
00105
00111 #define VAL_NULL(dv) ((dv)->nul)
00112
00113
00119 #define VAL_FREE(dv) ((dv)->free)
00120
00121
00125 #define VAL_INT(dv) ((dv)->val.int_val)
00126
00127
00132 #define VAL_UINT(dv) ((unsigned int)(dv)->val.int_val)
00133
00134
00138 #define VAL_BIGINT(dv) ((dv)->val.ll_val)
00139
00140
00144 #define VAL_DOUBLE(dv) ((dv)->val.double_val)
00145
00146
00150 #define VAL_TIME(dv) ((dv)->val.time_val)
00151
00152
00156 #define VAL_STRING(dv) ((dv)->val.string_val)
00157
00158
00162 #define VAL_STR(dv) ((dv)->val.str_val)
00163
00164
00168 #define VAL_BLOB(dv) ((dv)->val.blob_val)
00169
00170
00174 #define VAL_BITMAP(dv) ((dv)->val.bitmap_val)
00175
00176
00188 int db_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
00189 const unsigned int _cpy);
00190
00191
00203 int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len);
00204
00205 #endif