library/src/utility/BP-StringFormattingSessions.cc
// attempt to add a column to a row group
attempt to add a column to a row group
attempt to add a column to a row group
BP_ERROR_T BP_AddColumnGroupToRowSFSession
(
	P_BP_SF_SESSION sfs,
	char *row_group_identifier,
	char *row_identifier,
	char *new_column_group_identifier,
	P_BP_STRING_ROW_BORDER_SET border_set
)
{
	if(!sfs)
		return ERR_FAILURE;
	if(!sfs->tq)
		return ERR_FAILURE;
	if(!row_group_identifier || !row_identifier || !new_column_group_identifier)
		return ERR_FAILURE;
	BP_SFS_SEARCH_QUERY search_query;
	BP_ZERO_STACK(search_query);
	search_query.row_group_id = row_group_identifier;
	search_query.row_id       = row_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;
	if(!sfs_search_results->results[0].row)
		return ERR_FAILURE;
	%%
	%%
	P_BP_SFS_STRING_ROW row = sfs_search_results->results[0].row;
	row->col_group_n++;
	row->col_groups = (P_BP_SFS_STRING_COLUMN_GROUP *) tq_realloc
	(
			sfs->tq,
			row->col_groups,
			sizeof(P_BP_SFS_STRING_COLUMN_GROUP) * (row->col_group_n + 1),
			BPLN
	);
	if(!row->col_groups)
		return ERR_FAILURE;
	row->col_groups[row->col_group_n-1] = (P_BP_SFS_STRING_COLUMN_GROUP) tq_calloc
	(
			sfs->tq,
			sizeof(BP_SFS_STRING_COLUMN_GROUP),
			1,
			BPLN
	);
	P_BP_SFS_STRING_COLUMN_GROUP new_column_group = row->col_groups[row->col_group_n-1];
	if(border_set)
	{
		new_column_group->border_set.border_left  = tq_strdup(sfs->tq, border_set->border_left, BPLN);
		new_column_group->border_set.border_right = tq_strdup(sfs->tq, border_set->border_right, BPLN);
		new_column_group->border_set.border_top_enabled           = border_set->border_top_enabled;
		new_column_group->border_set.border_top_char              = tq_strdup(sfs->tq, border_set->border_top_char,   BPLN);
		new_column_group->border_set.border_top_left_corner       = tq_strdup(sfs->tq, border_set->border_top_left_corner, BPLN);
		new_column_group->border_set.border_top_right_corner      = tq_strdup(sfs->tq, border_set->border_top_right_corner, BPLN);
		new_column_group->border_set.border_bottom_enabled        = border_set->border_bottom_enabled;
		new_column_group->border_set.border_bottom_char           = tq_strdup(sfs->tq, border_set->border_bottom_char,         BPLN);
		new_column_group->border_set.border_bottom_left_corner    = tq_strdup(sfs->tq, border_set->border_bottom_left_corner,  BPLN);
		new_column_group->border_set.border_bottom_right_corner   = tq_strdup(sfs->tq, border_set->border_bottom_right_corner, BPLN);
	}
	else
	{
		new_column_group->border_set.border_left  = tq_strdup(sfs->tq, "", BPLN);
		new_column_group->border_set.border_right = tq_strdup(sfs->tq, "", BPLN);
		new_column_group->border_set.border_top_enabled           = BP_FALSE;
		new_column_group->border_set.border_top_char              = tq_strdup(sfs->tq, " ",   BPLN);
		new_column_group->border_set.border_top_left_corner       = tq_strdup(sfs->tq, "   ", BPLN);
		new_column_group->border_set.border_top_right_corner      = tq_strdup(sfs->tq, "   ", BPLN);
		new_column_group->border_set.border_bottom_enabled        = BP_FALSE;
		new_column_group->border_set.border_bottom_char           = tq_strdup(sfs->tq, " ",   BPLN);
		new_column_group->border_set.border_bottom_left_corner    = tq_strdup(sfs->tq, "   ", BPLN);
		new_column_group->border_set.border_bottom_right_corner   = tq_strdup(sfs->tq, "   ", BPLN);
	}
	new_column_group->column_group_identifier = tq_strdup(sfs->tq, new_column_group_identifier, BPLN);
	new_column_group->column_group_identifier_len = bpstrlen(new_column_group_identifier);
	new_column_group->row = row;
	new_column_group->session = sfs;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_AddColumnGroupToRowSFSession ( P_BP_SF_SESSION sfs , char * row_group_identifier , char * row_identifier , char * new_column_group_identifier , P_BP_STRING_ROW_BORDER_SET border_set ) { if ( ! sfs ) return ERR_FAILURE ; if ( ! sfs -> tq ) return ERR_FAILURE ; if ( ! row_group_identifier || ! row_identifier || ! new_column_group_identifier ) return ERR_FAILURE ; BP_SFS_SEARCH_QUERY search_query ; BP_ZERO_STACK ( search_query ) ; search_query . row_group_id = row_group_identifier ; search_query . row_id = row_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 ; if ( ! sfs_search_results -> results [ 0 ] . row ) return ERR_FAILURE ; P_BP_SFS_STRING_ROW row = sfs_search_results -> results [ 0 ] . row ; row -> col_group_n ++ ; row -> col_groups = ( P_BP_SFS_STRING_COLUMN_GROUP * ) tq_realloc ( sfs -> tq , row -> col_groups , sizeof ( P_BP_SFS_STRING_COLUMN_GROUP ) * ( row -> col_group_n + 1 ) , BPLN ) ; if ( ! row -> col_groups ) return ERR_FAILURE ; row -> col_groups [ row -> col_group_n - 1 ] = ( P_BP_SFS_STRING_COLUMN_GROUP ) tq_calloc ( sfs -> tq , sizeof ( BP_SFS_STRING_COLUMN_GROUP ) , 1 , BPLN ) ; P_BP_SFS_STRING_COLUMN_GROUP new_column_group = row -> col_groups [ row -> col_group_n - 1 ] ; if ( border_set ) { new_column_group -> border_set . border_left = tq_strdup ( sfs -> tq , border_set -> border_left , BPLN ) ; new_column_group -> border_set . border_right = tq_strdup ( sfs -> tq , border_set -> border_right , BPLN ) ; new_column_group -> border_set . border_top_enabled = border_set -> border_top_enabled ; new_column_group -> border_set . border_top_char = tq_strdup ( sfs -> tq , border_set -> border_top_char , BPLN ) ; new_column_group -> border_set . border_top_left_corner = tq_strdup ( sfs -> tq , border_set -> border_top_left_corner , BPLN ) ; new_column_group -> border_set . border_top_right_corner = tq_strdup ( sfs -> tq , border_set -> border_top_right_corner , BPLN ) ; new_column_group -> border_set . border_bottom_enabled = border_set -> border_bottom_enabled ; new_column_group -> border_set . border_bottom_char = tq_strdup ( sfs -> tq , border_set -> border_bottom_char , BPLN ) ; new_column_group -> border_set . border_bottom_left_corner = tq_strdup ( sfs -> tq , border_set -> border_bottom_left_corner , BPLN ) ; new_column_group -> border_set . border_bottom_right_corner = tq_strdup ( sfs -> tq , border_set -> border_bottom_right_corner , BPLN ) ; } else { new_column_group -> border_set . border_left = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_column_group -> border_set . border_right = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_column_group -> border_set . border_top_enabled = BP_FALSE ; new_column_group -> border_set . border_top_char = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_column_group -> border_set . border_top_left_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_column_group -> border_set . border_top_right_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_column_group -> border_set . border_bottom_enabled = BP_FALSE ; new_column_group -> border_set . border_bottom_char = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_column_group -> border_set . border_bottom_left_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; new_column_group -> border_set . border_bottom_right_corner = tq_strdup ( sfs -> tq , " " , BPLN ) ; } new_column_group -> column_group_identifier = tq_strdup ( sfs -> tq , new_column_group_identifier , BPLN ) ; new_column_group -> column_group_identifier_len = bpstrlen ( new_column_group_identifier ) ; new_column_group -> row = row ; new_column_group -> session = sfs ; return ERR_SUCCESS ; }
attempt to add a column to a row group
attempt to add a column to a row group
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Search for Row %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 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/row // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add Column Group to Row %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 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 // set the session // return indicating success