library/src/databases/sqlite/BP-DBSqlite.cc
// This returns a bpcalloced string representation of a query parameter.  Result
// must be free'd.  This is mainly used when displaying results.
This returns a bpcalloced string representation of a query parameter.  Result
must be free'd.  This is mainly used when displaying results.
This returns a bpcalloced string representation of a query parameter . Result must be free ' d . This is mainly used when displaying results .
char * BP_SQLiteConvertParameterToCStringForDisplay(P_BP_SQLITE_QUERY_PARAM param)
{
	if(!param)
		return NULL;
	char *ret_val = NULL;
	float tmp_float = 0;
	switch(param->type)
	{
		case 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);
			sprintf(ret_val, "%i", param->data);
			break;
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_REAL:
			memcpy(&tmp_float, param->data, sizeof(float));
			break;
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_TEXT:
			ret_val = bpstrdup((char *) param->data);
			break;
		case BP_DB_SQLITE_QUERY_PARAM_TYPE_BLOB:
			ret_val = BP_BufferToHexString((char *) param->data, param->data_size);
			break;
		default:
			break;
	}
	return ret_val;
}
char * BP_SQLiteConvertParameterToCStringForDisplay ( P_BP_SQLITE_QUERY_PARAM param ) { if ( ! param ) return NULL ; char * ret_val = NULL ; float tmp_float = 0 ; switch ( param -> type ) { case BP_DB_SQLITE_QUERY_PARAM_TYPE_UNSET : 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 ) ; sprintf ( ret_val , " " , param -> data ) ; break ; case BP_DB_SQLITE_QUERY_PARAM_TYPE_REAL : memcpy ( & tmp_float , param -> data , sizeof ( float ) ) ; break ; case BP_DB_SQLITE_QUERY_PARAM_TYPE_TEXT : ret_val = bpstrdup ( ( char * ) param -> data ) ; break ; case BP_DB_SQLITE_QUERY_PARAM_TYPE_BLOB : ret_val = BP_BufferToHexString ( ( char * ) param -> data , param -> data_size ) ; break ; default : break ; } return ret_val ; }
This returns a bpcalloced string representation of a query parameter.
This returns a bpcalloced string representation of a query parameter .
// ensure we have a parameter // return value // create a float value (8byte ieee) // switch on parameter type // return null if no conversion can occur