library/src/databases/bpdb/BP-DB.cc
// Attempts to convert INTEGER column result data to JSON data.
Attempts to convert INTEGER column result data to JSON data.
Attempts to convert INTEGER column result data to JSON data .
char * BP_DBMariadbConvertIntegerColumnResultDataToJSONData(MYSQL_BIND * col_bind_info, BPDB_MARIADB_COLUMN_TYPE type)
{
	if(!col_bind_info)
		return NULL;
	short  * short_ptr = NULL;
	unsigned short * ushort_ptr = NULL;
	long        * long_ptr = NULL;
	unsigned long ulong_ptr = NULL;
	long long        * longlong_ptr = NULL;
	unsigned long long ulonglong_ptr = NULL;
	float       * float_ptr  = NULL;
	double      * double_ptr = NULL;
	char int_out_buff[256] = {0};
	switch(type)
	{
		case BPDB_MARIADB_COLUMN_TYPE_UNSET:
			break;
		case BPDB_MARIADB_COLUMN_TYPE_BIT:
			short_ptr = (short *) col_bind_info->buffer;
			sprintf(int_out_buff, "%i", *short_ptr);
			break;
		case BPDB_MARIADB_COLUMN_TYPE_TINYINT:
			short_ptr = (short *) col_bind_info->buffer;
			sprintf(int_out_buff, "%i", *short_ptr);
			break;
		case BPDB_MARIADB_COLUMN_TYPE_SMALLINT:
			short_ptr = (short *) col_bind_info->buffer;
			sprintf(int_out_buff, "%i", *short_ptr);
			break;
		case BPDB_MARIADB_COLUMN_TYPE_MEDIUMINT:
			long_ptr = (long *) col_bind_info->buffer;
			sprintf(int_out_buff, "%i", *long_ptr);
			break;
		case BPDB_MARIADB_COLUMN_TYPE_INT:
			long_ptr = (long *) col_bind_info->buffer;
			sprintf(int_out_buff, "%i", *long_ptr);
			break;
		case BPDB_MARIADB_COLUMN_TYPE_BIGINT:
			longlong_ptr = (long long *) col_bind_info->buffer;
			sprintf(int_out_buff, "%i", *longlong_ptr);
			break;
		case BPDB_MARIADB_COLUMN_TYPE_DECIMAL:
			float_ptr = (float *) col_bind_info->buffer;
			sprintf(int_out_buff, "%lf", *float_ptr);
			break;
		case BPDB_MARIADB_COLUMN_TYPE_FLOAT:
			float_ptr = (float *) col_bind_info->buffer;
			sprintf(int_out_buff, "%lf", *float_ptr);
			break;
		case BPDB_MARIADB_COLUMN_TYPE_DOUBLE:
			double_ptr = (double *) col_bind_info->buffer;
			sprintf(int_out_buff, "%llf", *double_ptr);
			break;
		default:
			break;
	}
	if(bpstrlen(int_out_buff))
	{
		return bpstrdup(int_out_buff);
	}
	return NULL;
}
char * BP_DBMariadbConvertIntegerColumnResultDataToJSONData ( MYSQL_BIND * col_bind_info , BPDB_MARIADB_COLUMN_TYPE type ) { if ( ! col_bind_info ) return NULL ; short * short_ptr = NULL ; unsigned short * ushort_ptr = NULL ; long * long_ptr = NULL ; unsigned long ulong_ptr = NULL ; long long * longlong_ptr = NULL ; unsigned long long ulonglong_ptr = NULL ; float * float_ptr = NULL ; double * double_ptr = NULL ; char int_out_buff [ 256 ] = { 0 } ; switch ( type ) { case BPDB_MARIADB_COLUMN_TYPE_UNSET : break ; case BPDB_MARIADB_COLUMN_TYPE_BIT : short_ptr = ( short * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * short_ptr ) ; break ; case BPDB_MARIADB_COLUMN_TYPE_TINYINT : short_ptr = ( short * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * short_ptr ) ; break ; case BPDB_MARIADB_COLUMN_TYPE_SMALLINT : short_ptr = ( short * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * short_ptr ) ; break ; case BPDB_MARIADB_COLUMN_TYPE_MEDIUMINT : long_ptr = ( long * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * long_ptr ) ; break ; case BPDB_MARIADB_COLUMN_TYPE_INT : long_ptr = ( long * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * long_ptr ) ; break ; case BPDB_MARIADB_COLUMN_TYPE_BIGINT : longlong_ptr = ( long long * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * longlong_ptr ) ; break ; case BPDB_MARIADB_COLUMN_TYPE_DECIMAL : float_ptr = ( float * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * float_ptr ) ; break ; case BPDB_MARIADB_COLUMN_TYPE_FLOAT : float_ptr = ( float * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * float_ptr ) ; break ; case BPDB_MARIADB_COLUMN_TYPE_DOUBLE : double_ptr = ( double * ) col_bind_info -> buffer ; sprintf ( int_out_buff , " " , * double_ptr ) ; break ; default : break ; } if ( bpstrlen ( int_out_buff ) ) { return bpstrdup ( int_out_buff ) ; } return NULL ; }
Attempts to convert INTEGER column result data to JSON data.
Attempts to convert INTEGER column result data to JSON data .
// ensure we have bind info // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Declare Temporary Integer Ptr Types %%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // short/ushort // long/ulong // longlong/ulonglong // long floats for decimal types // create new out buffer /* begin numeric data types */ // if we have a buffer to return, return it // return NULL if we have no type match