@ -100,13 +100,20 @@ public:
TextStreamBase & operator < < ( wchar_t ) ;
TextStreamBase & operator < < ( int ) ;
TextStreamBase & operator < < ( long ) ;
TextStreamBase & operator < < ( long long ) ;
TextStreamBase & operator < < ( unsigned int ) ;
TextStreamBase & operator < < ( unsigned long ) ;
TextStreamBase & operator < < ( unsigned long long ) ;
TextStreamBase & operator < < ( double ) ;
TextStreamBase & operator < < ( const void * ) ; // printing a pointer
TextStreamBase & operator < < ( const PT : : Space & space ) ;
TextStreamBase & operator < < ( const PT : : Date & date ) ;
// min width for integer output
// if the output value has less digits then first zeroes are added
// (0 turn off)
TextStreamBase & int_min_width ( size_t min_width ) ;
template < typename arg_char_type , size_t arg_stack_size , size_t arg_heap_block_size >
TextStreamBase & operator < < ( const TextStreamBase < arg_char_type , arg_stack_size , arg_heap_block_size > & arg ) ;
@ -118,10 +125,13 @@ public:
TextStreamBase & write ( const char * format , double val ) ;
TextStreamBase & write ( const wchar_t * format , double val ) ;
TextStreamBase & fill_up_if_needed ( wchar_t fill_up_char , size_t existing_length ) ;
/*
raw access
*/
int radix ;
size_t min_width_for_integers ;
buffer_type buffer ;
} ;
@ -133,13 +143,15 @@ public:
template < typename char_type , size_t stack_size , size_t heap_block_size >
TextStreamBase < char_type , stack_size , heap_block_size > : : TextStreamBase ( )
{
radix = 10 ;
clear ( ) ;
}
template < typename char_type , size_t stack_size , size_t heap_block_size >
void TextStreamBase < char_type , stack_size , heap_block_size > : : clear ( )
{
radix = 10 ;
min_width_for_integers = 0 ;
buffer . clear ( ) ;
}
@ -323,20 +335,31 @@ template<typename char_type, size_t stack_size, size_t heap_block_size>
TextStreamBase < char_type , stack_size , heap_block_size > &
TextStreamBase < char_type , stack_size , heap_block_size > : : operator < < ( int v )
{
return operator < < ( static_cast < long > ( v ) ) ;
return operator < < ( static_cast < long long > ( v ) ) ;
}
template < typename char_type , size_t stack_size , size_t heap_block_size >
TextStreamBase < char_type , stack_size , heap_block_size > &
TextStreamBase < char_type , stack_size , heap_block_size > : : operator < < ( long v )
{
return operator < < ( static_cast < long long > ( v ) ) ;
}
template < typename char_type , size_t stack_size , size_t heap_block_size >
TextStreamBase < char_type , stack_size , heap_block_size > &
TextStreamBase < char_type , stack_size , heap_block_size > : : operator < < ( long long v )
{
char_type buf [ 50 ] ;
size_t len = sizeof ( buf ) / sizeof ( char_type ) ;
size_t lenout ;
if ( Toa ( v , buf , len , radix , & lenout ) )
{
fill_up_if_needed ( ' 0 ' , lenout ) ;
buffer . append ( buf , lenout ) ;
}
return * this ;
}
@ -346,20 +369,31 @@ template<typename char_type, size_t stack_size, size_t heap_block_size>
TextStreamBase < char_type , stack_size , heap_block_size > &
TextStreamBase < char_type , stack_size , heap_block_size > : : operator < < ( unsigned int v )
{
return operator < < ( static_cast < unsigned long > ( v ) ) ;
return operator < < ( static_cast < unsigned long long > ( v ) ) ;
}
template < typename char_type , size_t stack_size , size_t heap_block_size >
TextStreamBase < char_type , stack_size , heap_block_size > &
TextStreamBase < char_type , stack_size , heap_block_size > : : operator < < ( unsigned long v )
{
return operator < < ( static_cast < unsigned long long > ( v ) ) ;
}
template < typename char_type , size_t stack_size , size_t heap_block_size >
TextStreamBase < char_type , stack_size , heap_block_size > &
TextStreamBase < char_type , stack_size , heap_block_size > : : operator < < ( unsigned long long v )
{
char_type buf [ 50 ] ;
size_t len = sizeof ( buf ) / sizeof ( char_type ) ;
size_t lenout ;
if ( Toa ( v , buf , len , radix , & lenout ) )
{
fill_up_if_needed ( ' 0 ' , lenout ) ;
buffer . append ( buf , lenout ) ;
}
return * this ;
}
@ -387,7 +421,8 @@ size_t lenout;
buf [ 0 ] = ' 0 ' ;
buf [ 1 ] = ' x ' ;
if ( Toa ( reinterpret_cast < unsigned long > ( v ) , buf + 2 , len - 2 , 16 , & lenout ) )
// IMPROVE ME add some minimal width?
if ( Toa ( reinterpret_cast < unsigned long long > ( v ) , buf + 2 , len - 2 , 16 , & lenout ) )
buffer . append ( buf , lenout + 2 ) ;
return * this ;
@ -464,6 +499,32 @@ return *this;
template < typename char_type , size_t stack_size , size_t heap_block_size >
TextStreamBase < char_type , stack_size , heap_block_size > &
TextStreamBase < char_type , stack_size , heap_block_size > : : int_min_width ( size_t min_width )
{
min_width_for_integers = min_width ;
return * this ;
}
template < typename char_type , size_t stack_size , size_t heap_block_size >
TextStreamBase < char_type , stack_size , heap_block_size > &
TextStreamBase < char_type , stack_size , heap_block_size > : : fill_up_if_needed ( wchar_t fill_up_char , size_t existing_length )
{
if ( min_width_for_integers > 0 & & min_width_for_integers > existing_length )
{
for ( size_t i = existing_length ; i < min_width_for_integers ; + + i )
{
buffer . append ( fill_up_char ) ;
}
}
return * this ;
}
} // namespace