Data Structures | Defines | Enumerations | Functions

db_val.h File Reference

Data structures that represents values in the database. More...

#include "db_con.h"
#include <time.h>
#include "../../str.h"
#include "db_con.h"
Include dependency graph for db_val.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

Defines

Enumerations

Functions


Detailed Description

This file defines data structures that represents values in the database. Several datatypes are recognized and converted by the database API. Available types: DB1_INT, DB1_DOUBLE, DB1_STRING, DB1_STR, DB1_DATETIME, DB1_BLOB and DB1_BITMAP It also provides some macros for convenient access to this values, and a function to convert a str to a value.

Definition in file db_val.h.


Define Documentation

#define VAL_FREE (   dv  )     ((dv)->free)

A non-zero flag means that the corresponding cell in the database contains data that must be freed from the DB API.

Definition at line 119 of file db_val.h.

Referenced by bdb_str2val(), db_free_row(), db_postgres_str2val(), and db_str2val().

#define VAL_NULL (   dv  )     ((dv)->nul)

A non-zero flag means that the corresponding cell in the database contains no data (a NULL value in MySQL terminology).

Definition at line 111 of file db_val.h.

Referenced by bdb_str2val(), db_free_row(), db_load_urecord_by_ruid(), db_postgres_replace(), db_str2val(), db_table_version(), db_val2str(), dbrow2info(), get_all_db_ucontacts(), is_user_in(), preload_udomain(), and testdb_udomain().

#define VAL_TYPE (   dv  )     ((dv)->type)

All macros expect a reference to a db_val_t variable as parameter. Use this macro if you need to set/get the type of the value.

Definition at line 103 of file db_val.h.

Referenced by bdb_str2val(), db_free_row(), db_mysql_val2str(), db_postgres_replace(), db_postgres_str2val(), db_postgres_val2str(), db_str2val(), db_table_version(), db_val2str(), is_user_in(), and testdb_udomain().


Enumeration Type Documentation

enum db_type_t

To distinguish among these types, the db_type_t enumeration is used. Every value of the enumeration represents one datatype that is recognized by the database API.

Enumerator:
DB1_INT 

represents an 32 bit integer number

DB1_BIGINT 

represents an 64 bit integer number

DB1_DOUBLE 

represents a floating point number

DB1_STRING 

represents a zero terminated const char*

DB1_STR 

represents a string of 'str' type

DB1_DATETIME 

represents date and time

DB1_BLOB 

represents a large binary object

DB1_BITMAP 

an one-dimensional array of 32 flags

Definition at line 51 of file db_val.h.


Function Documentation

int db_str2val ( const db_type_t  _t,
db_val_t _v,
const char *  _s,
const int  _l,
const unsigned int  _cpy 
)

Convert a str to a db value, does not copy strings if _cpy is zero

Parameters:
_t destination value type
_v destination value
_s source string
_l string length
_cpy when set to zero does not copy strings, otherwise copy strings
Returns:
0 on success, negative on error

Convert a str to a db value, copy strings if _cpy is not zero. Copying is not necessary if the result from the database client library is freed after the result inside the server is processed. If the result is freed earlier, e.g. because its saved inside some temporary storage, then it must be copied in order to be use it reliable.

Parameters:
_t destination value type
_v destination value
_s source string
_l string length
_cpy when set to zero does not copy strings, otherwise copy strings
Returns:
0 on success, negative on error

Definition at line 45 of file db_val.c.

References DB1_BIGINT, DB1_BITMAP, DB1_BLOB, DB1_DATETIME, DB1_DOUBLE, DB1_INT, DB1_STR, DB1_STRING, db_str2double(), db_str2int(), db_str2longlong(), db_str2time(), _str::s, VAL_BIGINT, VAL_BLOB, VAL_DOUBLE, VAL_FREE, VAL_INT, VAL_NULL, VAL_STR, VAL_STRING, VAL_TIME, and VAL_TYPE.

Here is the call graph for this function:

int db_val2str ( const db1_con_t _c,
const db_val_t _v,
char *  _s,
int *  _len 
)

Convert a numerical value to a string, used when converting result from a query. Implement common functionality needed from the databases, does parameter checking.

Parameters:
_c database connection
_v source value
_s target string
_len target string length
Returns:
0 on success, negative on error, 1 if value must be converted by other means

Definition at line 202 of file db_val.c.

References DB1_BIGINT, DB1_BITMAP, DB1_DATETIME, DB1_DOUBLE, DB1_INT, db_double2str(), db_int2str(), db_longlong2str(), db_time2str(), VAL_BIGINT, VAL_BITMAP, VAL_DOUBLE, VAL_INT, VAL_NULL, VAL_TIME, and VAL_TYPE.

Here is the call graph for this function: