metadata_cell_private.h File Reference

#include <sqlite3.h>
Include dependency graph for metadata_cell_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

G_BEGIN_DECLS int metadata_cell_set_value (metadata_cell *thiz, const sqlite3_value *value)
 Assign a sqlite3 value to a metadata_cell.

Function Documentation

G_BEGIN_DECLS int metadata_cell_set_value ( metadata_cell thiz,
const sqlite3_value *  value 
)

Assign a sqlite3 value to a metadata_cell.

File Name : metadata_cell_private.h

Description: Extension of metadata_cell.h for libermetadb internal use only. Copyright (C) 2008 iRex Technologies B.V. All rights reserved.---------------------------------------------------------------------------

Name : metadata_cell_set_value

Parameters:
thiz - the metadata_cell
[in] value - sqlite3_value to be assigned to this cell
Returns:
ER_OK or error code

--------------------------------------------------------------------------

Definition at line 153 of file metadata_cell.c.

References cp, ER_INVALID_PARAMETER, ER_OK, ERRORPRINTF, LOGPRINTF, metadata_cell_clear(), metadata_cell_set_blob(), metadata_cell_set_double(), metadata_cell_set_int64(), metadata_cell_set_null, and metadata_cell_set_text().

Referenced by metadata_table_set_value().

00154 {
00155     int           ret = ER_OK;  // return value
00156     gint64        i64;
00157     double        d;
00158     const char    *cp;
00159     gchar         *blob;
00160     int           len;
00161 
00162     LOGPRINTF("entry: thiz [%p] value [%p]", thiz, value);
00163     g_return_val_if_fail(thiz,  ER_INVALID_PARAMETER);
00164     g_return_val_if_fail(value, ER_INVALID_PARAMETER);
00165 
00166     sqlite3_value *val = (sqlite3_value*)value;  // const_cast
00167     int type = sqlite3_value_type(val);
00168     switch (type)
00169     {
00170         case SQLITE_INTEGER:
00171             i64 = sqlite3_value_int64(val);
00172             ret = metadata_cell_set_int64(thiz, i64);
00173             break;
00174 
00175         case SQLITE_FLOAT:
00176             d   = sqlite3_value_double(val);
00177             ret = metadata_cell_set_double(thiz, d);
00178             break;
00179 
00180         case SQLITE_TEXT:
00181             cp  = (const char*) sqlite3_value_text(val);
00182             ret = metadata_cell_set_text(thiz, cp);
00183             break;
00184 
00185         case SQLITE_BLOB:
00186             // note: metadata_cell_set_blob takes ownership of blob,
00187             //       so we must pass it a copy of the blob data
00188             len  = sqlite3_value_bytes(val);
00189             blob = g_malloc(len);
00190             g_assert(blob);
00191             memcpy(blob, sqlite3_value_blob(val), len);
00192             ret = metadata_cell_set_blob(thiz, blob, len);
00193             break;
00194 
00195         case SQLITE_NULL:
00196             metadata_cell_set_null(thiz);
00197             break;
00198 
00199         default:
00200             ERRORPRINTF("illegal return [%d] from sqlite3_value_type", type);
00201             metadata_cell_clear(thiz);
00202             ret= ER_INVALID_PARAMETER;
00203     }
00204 
00205     return ret;
00206 }

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  doxygen 1.6.2-20100208