#include <MsgFormat.h>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <MsgBoundFormat.h>
Go to the source code of this file.
Functions | |
ostream & | operator<< (ostream &os, const MsgBoundFormat &bf) |
ostream& operator<< | ( | ostream & | os, | |
const MsgBoundFormat & | bf | |||
) |
Definition at line 20 of file MsgFormat.cxx.
References MsgBoundFormat::f, MsgFormat::flc, MsgFormat::fmt, MsgFormat::prc, MsgBoundFormat::val, and MsgFormat::wdt.
00021 { 00022 //====================================================================== 00023 // Purpose: Print a value with the given format 00024 // 00025 // Inputs: os - the stream to print to 00026 // bf - the value and format to print 00027 // 00028 // Returns: the stream printed to 00029 //====================================================================== 00030 int p = os.precision(); 00031 MsgFormat::fmtflags f = 00032 os.setf(bf.f.fmt,static_cast<MsgFormat::fmtflags>(0xFFFF)); 00033 char c = os.fill(); 00034 00035 if (bf.f.flc != c) os.fill(bf.f.flc); 00036 00037 if ((bf.f.fmt&ios::hex) || (bf.f.fmt&ios::oct)) { 00038 os.setf(bf.f.fmt, ios::basefield); 00039 os << setprecision(bf.f.prc) << setw(bf.f.wdt) << (int)bf.val; 00040 } 00041 else { 00042 os << setprecision(bf.f.prc) << setw(bf.f.wdt) << bf.val; 00043 } 00044 00045 // Reset stream 00046 if (c != os.fill()) os.fill(c); 00047 os.precision(p); 00048 os.flags(f); 00049 return os; 00050 }