library/src/databases/sqlite/BP-DBSqlite.cc
// This routine is used to convert metadata and raw data into a human readable
// c string suitable for display.
This routine is used to convert metadata and raw data into a human readable
c string suitable for display.
This routine is used to convert metadata and raw data into a human readable c string suitable for display .
char * BP_SQLiteConvertResultDataToCStringForDisplay
(
		P_BP_DB_SQLITE_RESULT_METADATA record_metadata,
		void * data
)
{
	if(!record_metadata)
		return NULL;
	if(!data)
		return NULL;
	char *ret_val = NULL;
	int data_as_int = 0;
	double tmp_double = 0;
	switch(record_metadata->type)
	{
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_UNSET:
			ret_val = bpstrdup("BP_DB_SQLITE_QUERY_PARAM_TYPE_UNSET");
			break;
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_NULL:
			ret_val = bpstrdup("NULL");
			break;
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_INTEGER:
			ret_val = (char *) bpcalloc(40, 1);
			memcpy(&data_as_int, data, sizeof(int));
			sprintf(ret_val, "%i", data_as_int);
			break;
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_REAL:
			memcpy(&tmp_double, data, sizeof(double));
			break;
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_TEXT:
			ret_val = bpstrndup((char *) data, record_metadata->data_size);
			break;
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_BLOB:
			ret_val = BP_BufferToHexString((char *) data, record_metadata->data_size);
			break;
		default:
			ret_val = bpstrdup("BADVAL");
			break;
	}
	return ret_val;
}
char * BP_SQLiteConvertResultDataToCStringForDisplay ( P_BP_DB_SQLITE_RESULT_METADATA record_metadata , void * data ) { if ( ! record_metadata ) return NULL ; if ( ! data ) return NULL ; char * ret_val = NULL ; int data_as_int = 0 ; double tmp_double = 0 ; switch ( record_metadata -> type ) { case BP_DB_SQLITE_QUERY_PARAM_TYPE_UNSET : ret_val = bpstrdup ( " " ) ; break ; case BP_DB_SQLITE_QUERY_PARAM_TYPE_NULL : ret_val = bpstrdup ( " " ) ; break ; case BP_DB_SQLITE_QUERY_PARAM_TYPE_INTEGER : ret_val = ( char * ) bpcalloc ( 40 , 1 ) ; memcpy ( & data_as_int , data , sizeof ( int ) ) ; sprintf ( ret_val , " " , data_as_int ) ; break ; case BP_DB_SQLITE_QUERY_PARAM_TYPE_REAL : memcpy ( & tmp_double , data , sizeof ( double ) ) ; break ; case BP_DB_SQLITE_QUERY_PARAM_TYPE_TEXT : ret_val = bpstrndup ( ( char * ) data , record_metadata -> data_size ) ; break ; case BP_DB_SQLITE_QUERY_PARAM_TYPE_BLOB : ret_val = BP_BufferToHexString ( ( char * ) data , record_metadata -> data_size ) ; break ; default : ret_val = bpstrdup ( " " ) ; break ; } return ret_val ; }
This routine is used to convert metadata and raw data into a human readable
c string suitable for display.
This routine is used to convert metadata and raw data into a human readable c string suitable for display .
// ensure we have metadata // check the retval // used for data to int conversion // create a float value (8byte ieee) // switch on record type // return null if no conversion can occur