library/src/utility/BP-StringFormattingSessions.cc
// Generate the final output.  This output is stored in the session itself
// as:
//
// session->(char **)final_output_rows;
// session->(size_t)final_output_row_n;
//
// You should only ever have to call this routine when trying to generate
// finalized output.
Generate the final output.  This output is stored in the session itself
as.



You should only ever have to call this routine when trying to generate
finalized output.
Generate the final output . This output is stored in the session itself as . You should only ever have to call this routine when trying to generate finalized output .
BP_ERROR_T BP_GenerateFinalOutputSFSession(P_BP_SF_SESSION session)
{
	if(!session)
		return ERR_FAILURE;
	if(!session->tq)
		return ERR_FAILURE;
	if(BP_ColumnizeAllStringEntriesSFSession     (session) != ERR_SUCCESS)
		return ERR_FAILURE;
	if(BP_ColumnizeAllColumnEntriesSFSession     (session) != ERR_SUCCESS)
		return ERR_FAILURE;
	if(BP_ColumnizeAllColumnGroupEntriesSFSession(session) != ERR_SUCCESS)
		return ERR_FAILURE;
	if(BP_ColumnizeAllRowEntriesSFSession        (session) != ERR_SUCCESS)
		return ERR_FAILURE;
	if(BP_ColumnizeAllRowGroupEntriesSFSession   (session) != ERR_SUCCESS)
		return ERR_FAILURE;
	size_t row_group_n = 0;
	P_BP_GENERIC_STRING_COLUMNIZATION merged_columnizations         = NULL;
	P_BP_GENERIC_STRING_COLUMNIZATION merged_columnizations_colored = NULL;
	P_BP_GENERIC_STRING_COLUMNIZATION * columnizations         = (P_BP_GENERIC_STRING_COLUMNIZATION * ) bpcalloc(sizeof(P_BP_GENERIC_STRING_COLUMNIZATION) * (session->row_group_n+1), 1);
	P_BP_GENERIC_STRING_COLUMNIZATION * columnizations_colored = (P_BP_GENERIC_STRING_COLUMNIZATION * ) bpcalloc(sizeof(P_BP_GENERIC_STRING_COLUMNIZATION) * (session->row_group_n+1), 1);
	P_BP_GENERIC_STRING_COLUMNIZATION borderized_merged_columnizations         = NULL;
	P_BP_GENERIC_STRING_COLUMNIZATION borderized_merged_columnizations_colored = NULL;
	size_t col_idx = 0;
	for(row_group_n = 0; row_group_n < session->row_group_n; row_group_n++)
	{
		if(!session->row_groups[row_group_n])
			continue;
		if(!session->row_groups[row_group_n]->final_columnization)
			continue;
		columnizations        [col_idx] = session->row_groups[row_group_n]->final_columnization;
		columnizations_colored[col_idx] = session->row_groups[row_group_n]->final_columnization_colorized;
		col_idx++;
	}
	merged_columnizations         = BP_MergeGenericColumnizationsVertically(columnizations,         col_idx);
	merged_columnizations_colored = BP_MergeGenericColumnizationsVertically(columnizations_colored, col_idx);
	borderized_merged_columnizations         = BP_BorderizeStringColumnization(merged_columnizations,         &session->border_set);
	borderized_merged_columnizations_colored = BP_BorderizeStringColumnization(merged_columnizations_colored, &session->border_set);
	session->final_columnization           = BP_StoreColumnizationInTailQ(borderized_merged_columnizations,         session->tq, BP_TRUE);
	session->final_columnization_colorized = BP_StoreColumnizationInTailQ(borderized_merged_columnizations_colored, session->tq, BP_TRUE);
	BP_DestroyGenericColumnization(merged_columnizations,          BP_TRUE);
	BP_DestroyGenericColumnization(merged_columnizations_colored,  BP_TRUE);
	if(columnizations)
		bpfree(columnizations);
	if(columnizations_colored)
		bpfree(columnizations_colored);
	session->output_prepared_ok = BP_TRUE;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_GenerateFinalOutputSFSession ( P_BP_SF_SESSION session ) { if ( ! session ) return ERR_FAILURE ; if ( ! session -> tq ) return ERR_FAILURE ; if ( BP_ColumnizeAllStringEntriesSFSession ( session ) != ERR_SUCCESS ) return ERR_FAILURE ; if ( BP_ColumnizeAllColumnEntriesSFSession ( session ) != ERR_SUCCESS ) return ERR_FAILURE ; if ( BP_ColumnizeAllColumnGroupEntriesSFSession ( session ) != ERR_SUCCESS ) return ERR_FAILURE ; if ( BP_ColumnizeAllRowEntriesSFSession ( session ) != ERR_SUCCESS ) return ERR_FAILURE ; if ( BP_ColumnizeAllRowGroupEntriesSFSession ( session ) != ERR_SUCCESS ) return ERR_FAILURE ; size_t row_group_n = 0 ; P_BP_GENERIC_STRING_COLUMNIZATION merged_columnizations = NULL ; P_BP_GENERIC_STRING_COLUMNIZATION merged_columnizations_colored = NULL ; P_BP_GENERIC_STRING_COLUMNIZATION * columnizations = ( P_BP_GENERIC_STRING_COLUMNIZATION * ) bpcalloc ( sizeof ( P_BP_GENERIC_STRING_COLUMNIZATION ) * ( session -> row_group_n + 1 ) , 1 ) ; P_BP_GENERIC_STRING_COLUMNIZATION * columnizations_colored = ( P_BP_GENERIC_STRING_COLUMNIZATION * ) bpcalloc ( sizeof ( P_BP_GENERIC_STRING_COLUMNIZATION ) * ( session -> row_group_n + 1 ) , 1 ) ; P_BP_GENERIC_STRING_COLUMNIZATION borderized_merged_columnizations = NULL ; P_BP_GENERIC_STRING_COLUMNIZATION borderized_merged_columnizations_colored = NULL ; size_t col_idx = 0 ; for ( row_group_n = 0 ; row_group_n < session -> row_group_n ; row_group_n ++ ) { if ( ! session -> row_groups [ row_group_n ] ) continue ; if ( ! session -> row_groups [ row_group_n ] -> final_columnization ) continue ; columnizations [ col_idx ] = session -> row_groups [ row_group_n ] -> final_columnization ; columnizations_colored [ col_idx ] = session -> row_groups [ row_group_n ] -> final_columnization_colorized ; col_idx ++ ; } merged_columnizations = BP_MergeGenericColumnizationsVertically ( columnizations , col_idx ) ; merged_columnizations_colored = BP_MergeGenericColumnizationsVertically ( columnizations_colored , col_idx ) ; borderized_merged_columnizations = BP_BorderizeStringColumnization ( merged_columnizations , & session -> border_set ) ; borderized_merged_columnizations_colored = BP_BorderizeStringColumnization ( merged_columnizations_colored , & session -> border_set ) ; session -> final_columnization = BP_StoreColumnizationInTailQ ( borderized_merged_columnizations , session -> tq , BP_TRUE ) ; session -> final_columnization_colorized = BP_StoreColumnizationInTailQ ( borderized_merged_columnizations_colored , session -> tq , BP_TRUE ) ; BP_DestroyGenericColumnization ( merged_columnizations , BP_TRUE ) ; BP_DestroyGenericColumnization ( merged_columnizations_colored , BP_TRUE ) ; if ( columnizations ) bpfree ( columnizations ) ; if ( columnizations_colored ) bpfree ( columnizations_colored ) ; session -> output_prepared_ok = BP_TRUE ; return ERR_SUCCESS ; }
Generate the final output.
Generate the final output .
// ensure we have a session to work with // ensure the session has a tailqueue // declare merged values // allocat columnizations // declare borderized (final) values // set column index // add columnizations // set the columnizations // increase the col idx // borderize items // set merged data // destroy old data // destroy columnization stacks here // mark indicating that the output was prepared ok // return indicating success if we were able to generate data