Added formatted throw, and changed table overflow style.

This commit is contained in:
Can Bölük 2020-08-29 04:30:43 +02:00
parent d5fd957f87
commit 87a9a7529f
3 changed files with 22 additions and 3 deletions

View file

@ -47,6 +47,19 @@ namespace vtil
else logger::error( "Assertion failure, %s", string );
}
}
// A helper to throw formatted strings.
//
template<typename... params>
__forceinline static void fthrow [[noreturn]] ( const char* fmt, params&&... ps )
{
// Format error message.
//
throw std::runtime_error( format::str(
fmt,
format::fix_parameter<params>( std::forward<params>( ps ) )...
) );
}
};
// Declare assert macro.

View file

@ -125,7 +125,7 @@ namespace vtil::format
// Explicit percentage formatting.
//
template<FloatingPoint T = float>
template<FloatingPoint T = double>
struct percentage
{
T value = 0.0f;

View file

@ -182,8 +182,14 @@ namespace vtil::format
if ( table_overflow )
{
begl();
write( config.vertical_delimiter, ' ', '.', '.', '.' );
fill( ' ', line_length - 7 );
write( config.vertical_delimiter, ' ' );
std::string indicator = format::str( "... (%d more)", entry_count - string_entries.size() );
if ( indicator.size() > ( line_length - 4 ) )
indicator.resize( line_length - 4 );
write_n( indicator );
fill( ' ', line_length - 4 - indicator.size() );
write( config.vertical_delimiter, ' ' );
rendl();
}