00001 #ifndef CDB_NTUPLE_PRINT_DEFAULT_CONVERTER_HH
00002 #define CDB_NTUPLE_PRINT_DEFAULT_CONVERTER_HH
00003
00004
00005
00006
00007 #include "CdbBase/CdbCommon.hh"
00008
00009 #include "BbrStdUtils/BbrIOStreamUtils.hh"
00010
00011 #include <iostream>
00012 #include <iomanip>
00013
00014 #include <string>
00015
00016
00017
00018
00019
00020
00021 template < class T >
00022 struct CdbNTuplePrintDefaultConverter {
00023 static void convertAndPrint( std::ostream& theOutputStream,
00024 unsigned int theWidth,
00025 const T& theValue )
00026 {
00027 theOutputStream << std::setw( theWidth ) << theValue;
00028 }
00029 };
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 template < >
00041 struct CdbNTuplePrintDefaultConverter< std::string > {
00042 static void convertAndPrint( std::ostream& theOutputStream,
00043 unsigned int theWidth,
00044 const std::string& theValue )
00045 {
00046 babar::IOStream::all_format_guard guard( theOutputStream );
00047 theOutputStream.setf( std::ios::left, std::ios::adjustfield );
00048
00049 if( theValue.length( ) <= theWidth ) {
00050 theOutputStream << std::setw( theWidth ) << theValue.c_str( );
00051 } else {
00052 theOutputStream << std::setw( theWidth - 2 ) << theValue.substr( 0, theWidth - 2 ).c_str( ) << "..";
00053 }
00054 }
00055 };
00056
00057 #endif // CDB_NTUPLE_PRINT_DEFAULT_CONVERTER_HH
00058