library/src/utility/BP-StringFormattingSessions.cc
// attempt to add a row group to a string formatting session
attempt to add a row group to a string formatting session
attempt to add a row group to a string formatting session
BP_ERROR_T BP_AddRowToRowGroupSFSession
(
	P_BP_SF_SESSION sfs,
	char * row_group_identifier,
	char * new_row_identifier,
	P_BP_STRING_ROW_BORDER_SET border_set
)
{
	if(!sfs || !row_group_identifier || !new_row_identifier)
		return ERR_FAILURE;
	if(!sfs->tq)
		return ERR_FAILURE;
	BP_SFS_SEARCH_QUERY search_query;
	BP_ZERO_STACK(search_query);
	search_query.row_group_id = row_group_identifier;
	P_BP_SFS_SEARCH_RESULTS sfs_search_results = BP_SearchStringFormattingSession
	(
			sfs,
			&search_query
	);
	if(!sfs_search_results)
		return ERR_FAILURE;
	if(!sfs_search_results->result_n || !sfs_search_results->results)
		return ERR_FAILURE;
	if(!sfs_search_results->results[0].row_group)
		return ERR_FAILURE;
	%%
	%%
	P_BP_SFS_STRING_ROW_GROUP row_group = sfs_search_results->results[0].row_group;
	row_group->row_n++;
	row_group->rows = (P_BP_SFS_STRING_ROW *) tq_realloc
	(
			sfs->tq,
			row_group->rows,
			sizeof(P_BP_SFS_STRING_ROW) * (row_group->row_n + 1),
			BPLN
	);
	if(!row_group->rows)
		return ERR_FAILURE;
	row_group->rows[row_group->row_n-1] = (P_BP_SFS_STRING_ROW) tq_calloc
	(
			sfs->tq,
			sizeof(BP_SFS_STRING_ROW),
			1,
			BPLN
	);
	P_BP_SFS_STRING_ROW new_row = row_group->rows[row_group->row_n-1];
	if(border_set)
	{
		new_row->border_set.border_left  = tq_strdup(sfs->tq, border_set->border_left, BPLN);
		new_row->border_set.border_right = tq_strdup(sfs->tq, border_set->border_right, BPLN);
		new_row->border_set.border_top_enabled           = border_set->border_top_enabled;
		new_row->border_set.border_top_char              = tq_strdup(sfs->tq, border_set->border_top_char,   BPLN);
		new_row->border_set.border_top_left_corner       = tq_strdup(sfs->tq, border_set->border_top_left_corner, BPLN);
		new_row->border_set.border_top_right_corner      = tq_strdup(sfs->tq, border_set->border_top_right_corner, BPLN);
		new_row->border_set.border_bottom_enabled        = border_set->border_bottom_enabled;
		new_row->border_set.border_bottom_char           = tq_strdup(sfs->tq, border_set->border_bottom_char,         BPLN);
		new_row->border_set.border_bottom_left_corner    = tq_strdup(sfs->tq, border_set->border_bottom_left_corner,  BPLN);
		new_row->border_set.border_bottom_right_corner   = tq_strdup(sfs->tq, border_set->border_bottom_right_corner, BPLN);
	}
	else
	{
		new_row->border_set.border_left  = tq_strdup(sfs->tq, "", BPLN);
		new_row->border_set.border_right = tq_strdup(sfs->tq, "", BPLN);
		new_row->border_set.border_top_enabled           = BP_FALSE;
		new_row->border_set.border_top_char              = tq_strdup(sfs->tq, " ",   BPLN);
		new_row->border_set.border_top_left_corner       = tq_strdup(sfs->tq, "   ", BPLN);
		new_row->border_set.border_top_right_corner      = tq_strdup(sfs->tq, "   ", BPLN);
		new_row->border_set.border_bottom_enabled        = BP_FALSE;
		new_row->border_set.border_bottom_char           = tq_strdup(sfs->tq, " ",   BPLN);
		new_row->border_set.border_bottom_left_corner    = tq_strdup(sfs->tq, "   ", BPLN);
		new_row->border_set.border_bottom_right_corner   = tq_strdup(sfs->tq, "   ", BPLN);
	}
	new_row->row_identifier = tq_strdup(sfs->tq, new_row_identifier, BPLN);
	new_row->row_identifier_len = bpstrlen(new_row_identifier);
	new_row->row_group = row_group;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_AddRowToRowGroupSFSession ( P_BP_SF_SESSION sfs , char * row_group_identifier , char * new_row_identifier , P_BP_STRING_ROW_BORDER_SET border_set ) { if ( ! sfs || ! row_group_identifier || ! new_row_identifier ) return ERR_FAILURE ; if ( ! sfs -> tq ) return ERR_FAILURE ; BP_SFS_SEARCH_QUERY search_query ; BP_ZERO_STACK ( search_query ) ; search_query . row_group_id = row_group_identifier ; P_BP_SFS_SEARCH_RESULTS sfs_search_results = BP_SearchStringFormattingSession ( sfs , & search_query ) ; if ( ! sfs_search_results ) return ERR_FAILURE ; if ( ! sfs_search_results -> result_n || ! sfs_search_results -> results ) return ERR_FAILURE ; if ( ! sfs_search_results -> results [ 0 ] . row_group ) return ERR_FAILURE ; P_BP_SFS_STRING_ROW_GROUP row_group = sfs_search_results -> results [ 0 ] . row_group ; row_group -> row_n ++ ; row_group -> rows = ( P_BP_SFS_STRING_ROW * ) tq_realloc ( sfs -> tq , row_group -> rows , sizeof ( P_BP_SFS_STRING_ROW ) * ( row_group -> row_n + 1 ) , BPLN ) ; if ( ! row_group -> rows ) return ERR_FAILURE ; row_group -> rows [ row_group -> row_n - 1 ] = ( P_BP_SFS_STRING_ROW ) tq_calloc ( sfs -> tq , sizeof ( BP_SFS_STRING_ROW ) , 1 , BPLN ) ; P_BP_SFS_STRING_ROW new_row = row_group -> rows [ row_group -> row_n - 1 ] ; if ( border_set ) { new_row -> border_set . border_left = tq_strdup ( sfs -> tq , border_set -> border_left , BPLN ) ; new_row -> border_set . border_right = tq_strdup ( sfs -> tq , border_set -> border_right , BPLN ) ; new_row -> border_set . border_top_enabled = border_set -> border_top_enabled ; new_row -> border_set . border_top_char = tq_strdup ( sfs -> tq , border_set -> border_top_char , BPLN ) ; new_row -> border_set . border_top_left_corner = tq_strdup ( sfs -> tq , border_set -> border_top_left_corner , BPLN ) ; new_row -> border_set . border_top_right_corner = tq_strdup ( sfs -> tq , border_set -> border_top_right_corner , BPLN ) ; new_row -> border_set . border_bottom_enabled = border_set -> border_bottom_enabled ; new_row -> border_set . border_bottom_char = tq_strdup ( sfs -> tq , border_set -> border_bottom_char , BPLN ) ; new_row -> border_set . border_bottom_left_corner = tq_strdup ( sfs -> tq , border_set -> border_bottom_left_corner , BPLN ) ; new_row -> border_set . border_bottom_right_corner = tq_strdup ( sfs -> tq , border_set -> border_bottom_right_corner , BPLN ) ; } else { new_row -> border_set . border_left = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row -> border_set . border_right = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row -> border_set . border_top_enabled = BP_FALSE ; new_row -> border_set . border_top_char = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row -> border_set . border_top_left_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row -> border_set . border_top_right_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row -> border_set . border_bottom_enabled = BP_FALSE ; new_row -> border_set . border_bottom_char = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row -> border_set . border_bottom_left_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_row -> border_set . border_bottom_right_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; } new_row -> row_identifier = tq_strdup ( sfs -> tq , new_row_identifier , BPLN ) ; new_row -> row_identifier_len = bpstrlen ( new_row_identifier ) ; new_row -> row_group = row_group ; return ERR_SUCCESS ; }
attempt to add a row group to a string formatting session
attempt to add a row group to a string formatting session
// ensure we have parameters // ensure we have a tail queue allocator // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Search for Row Group %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // create/zero out search query // set row group id // attempt to search for the row // ensure the stars line up // ensure that we have found our row group // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add Row to Row Group %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // create reference for added readability // increment the row count // attempt to reallocate the row to // contain space for the new pointer. // add new row // create row reference for readability // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add Border Info %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set left and right borders // border top items // border bottom items // default border is just spaces/padding // set left and right borders // border top items // border bottom items // set the row identifier // set identifier length // now set the row group // return indicating success