src/Generic/common/LocatedString.cpp
/**
 * @param out the output stream to print to.
 * @param indent the number of spaces to indent each line.
 */
@param out the output stream to print to.
@param indent the number of spaces to indent each line.
@param out the output stream to print to . @param indent the number of spaces to indent each line .
void LocatedString::dumpDetails(std::ostream &out, int indent) const {
	char num_fmt[32];    
	char num_str[32];    
	char spc_fmt[32];    
	char spc_str[32];    
	char spc_fmt2[32];   
	char spc_str2[32];   
	int i = 0;
	int field_width = (int)log10((double)end<CharOffset>().value()) + 2;
	sprintf(num_fmt, "%%%dd", field_width);
	sprintf(spc_fmt, "%%%dc", (field_width - 1));
	sprintf(spc_str, spc_fmt, ' ');
	sprintf(spc_fmt2, "%%%dc", (field_width - 2));
	sprintf(spc_str2, spc_fmt2, ' ');
	while (i < length()) {
		int j = i;
		int width = 0;
		while ((j < length()) && (width < 70)) {
			char c = (char)_text[j];
			switch (c) {
				case '\t':
					out << spc_str2 << "\\t";
					break;
				case '\r':
					out << spc_str2 << "\\r";
					break;
				case '\n':
					out << spc_str2 << "\\n";
					break;
				default:
					wchar_t wstr[2];
					char str[100];
					wstr[0] = _text[j];
					wstr[1] = L'\0';
					wchar_t* strptr = wstr;
					StringTransliterator::transliterateToEnglish(str, strptr, 99);
					out << spc_str << str[0];
			}
			j++;
			width += field_width;
		}
		out << '\n';
		j = i;
		width = 0;
		while ((j < length()) && (width < 70)) {
			sprintf(num_str, num_fmt, start<CharOffset>(j).value());
			out << num_str;
			j++;
			width += field_width;
		}
		out << "\n";
		j = i;
		width = 0;
		while ((j < length()) && (width < 70)) {
			sprintf(num_str, num_fmt, start<EDTOffset>(j).value());
			out << num_str;
			j++;
			width += field_width;
		}
		out << "\n";
		j = i;
		width = 0;
		while ((j < length()) && (width < 70)) {
			sprintf(num_str, num_fmt, end<EDTOffset>(j).value());
			out << num_str;
			j++;
			width += field_width;
		}
		out << "\n\n";
		i = j;
	}
	out << '\n';
}
void LocatedString :: dumpDetails ( std :: ostream & out , int indent ) const { char num_fmt [ 32 ] ; char num_str [ 32 ] ; char spc_fmt [ 32 ] ; char spc_str [ 32 ] ; char spc_fmt2 [ 32 ] ; char spc_str2 [ 32 ] ; int i = 0 ; int field_width = ( int ) log10 ( ( double ) end < CharOffset > ( ) . value ( ) ) + 2 ; sprintf ( num_fmt , " " , field_width ) ; sprintf ( spc_fmt , " " , ( field_width - 1 ) ) ; sprintf ( spc_str , spc_fmt , ' ' ) ; sprintf ( spc_fmt2 , " " , ( field_width - 2 ) ) ; sprintf ( spc_str2 , spc_fmt2 , ' ' ) ; while ( i < length ( ) ) { int j = i ; int width = 0 ; while ( ( j < length ( ) ) && ( width < 70 ) ) { char c = ( char ) _text [ j ] ; switch ( c ) { case ' \t ' : out << spc_str2 << " \\ " ; break ; case ' \r ' : out << spc_str2 << " \\ " ; break ; case ' \n ' : out << spc_str2 << " \\ " ; break ; default : wchar_t wstr [ 2 ] ; char str [ 100 ] ; wstr [ 0 ] = _text [ j ] ; wstr [ 1 ] = L' \0 ' ; wchar_t * strptr = wstr ; StringTransliterator :: transliterateToEnglish ( str , strptr , 99 ) ; out << spc_str << str [ 0 ] ; } j ++ ; width += field_width ; } out << ' \n ' ; j = i ; width = 0 ; while ( ( j < length ( ) ) && ( width < 70 ) ) { sprintf ( num_str , num_fmt , start < CharOffset > ( j ) . value ( ) ) ; out << num_str ; j ++ ; width += field_width ; } out << " \n " ; j = i ; width = 0 ; while ( ( j < length ( ) ) && ( width < 70 ) ) { sprintf ( num_str , num_fmt , start < EDTOffset > ( j ) . value ( ) ) ; out << num_str ; j ++ ; width += field_width ; } out << " \n " ; j = i ; width = 0 ; while ( ( j < length ( ) ) && ( width < 70 ) ) { sprintf ( num_str , num_fmt , end < EDTOffset > ( j ) . value ( ) ) ; out << num_str ; j ++ ; width += field_width ; } out << " \n \n " ; i = j ; } out << ' \n ' ; }
@param out the output stream to print to.
@param out the output stream to print to .
// a dynamically-created printf-style format string for offset numbers
 // a right-aligned string containing an offset number
 // a dynamically-created printf-style format string for space characters
 // a string of (width - 1) spaces
 // a dynamically-created printf-style format string for space characters
 // a string of (width - 2) spaces
 // Based on the string width of the largest offset number, figure out
 // the string width of each character to print out.
 // Create the printf format string for printing out offset numbers
 // in exactly field_width characters.
 // Create a string containing (field_width - 1) adjacent space characters.
 // Create a string containing (field_width - 2) adjacent space characters.
 // Print the absolute offsets.
 // Create a string with the offset number right-aligned to the correct width.
 // Print the EDT begin offsets.
 // Create a string with the offset number right-aligned to the correct width.
 // Print the EDT end offsets.
 // Create a string with the offset number right-aligned to the correct width.
