library/src/utility/BP-StringUtilities.cc
// returns the longest line in a buffer deliniated by the supplied deliniator
returns the longest line in a buffer deliniated by the supplied deliniator
returns the longest line in a buffer deliniated by the supplied deliniator
size_t BP_GetLongestLineInBuffer(char *buff, size_t buff_len, unsigned char deliniator)
{
	if(!buff | !buff_len || !deliniator)
		return 0;
	char separator[2];
	BP_ZERO_STACK(separator);
	separator[0] = (unsigned char) deliniator;
	char ** exploded = BP_ExplodeBufferBin(buff, buff_len, (char*) &separator, 1, BP_GIGABYTE);
	if(!exploded)
		return 0;
	size_t last_line    = 0;
	size_t longest_line = 0;
	size_t n = 0;
	for(; exploded[n]; n++)
	{
		last_line = bpstrlen(exploded[n]);
		if(last_line > longest_line)
			longest_line = last_line;
	}
	BP_DestroyPointerArray((void **) exploded, n);
	bpfree(exploded);
	return longest_line;
}
size_t BP_GetLongestLineInBuffer ( char * buff , size_t buff_len , unsigned char deliniator ) { if ( ! buff | ! buff_len || ! deliniator ) return 0 ; char separator [ 2 ] ; BP_ZERO_STACK ( separator ) ; separator [ 0 ] = ( unsigned char ) deliniator ; char * * exploded = BP_ExplodeBufferBin ( buff , buff_len , ( char * ) & separator , 1 , BP_GIGABYTE ) ; if ( ! exploded ) return 0 ; size_t last_line = 0 ; size_t longest_line = 0 ; size_t n = 0 ; for ( ; exploded [ n ] ; n ++ ) { last_line = bpstrlen ( exploded [ n ] ) ; if ( last_line > longest_line ) longest_line = last_line ; } BP_DestroyPointerArray ( ( void * * ) exploded , n ) ; bpfree ( exploded ) ; return longest_line ; }
returns the longest line in a buffer deliniated by the supplied deliniator
returns the longest line in a buffer deliniated by the supplied deliniator
// ensure we have parameters // create separator as stack data // set index to the supplied deliniator // try to explode the number of lines in the buffer // ensure we've exploded // iterative line counters // count number of exploded lines // destroy the allocated data // destroy the pointer container // return the count