MsgFormat Class Reference
#include <MsgFormat.h>
List of all members.
Detailed Description
Definition at line 31 of file MsgFormat.h.
Member Typedef Documentation
Constructor & Destructor Documentation
MsgFormat::MsgFormat |
( |
int |
p = 6 |
) |
[inline] |
MsgFormat::MsgFormat |
( |
int |
p, |
|
|
int |
w | |
|
) |
| | [inline] |
MsgFormat::MsgFormat |
( |
const char * |
f |
) |
|
Definition at line 54 of file MsgFormat.cxx.
References flc, fmt, prc, and wdt.
00055 {
00056
00057
00058
00059
00060
00061 int i, j=0, k=0;
00062 char c, n[2][16];
00063 prc = 6;
00064 wdt = 0;
00065 fmt = static_cast<fmtflags>(0);
00066 flc = ' ';
00067 for (i=0; f[i] != '\0'; ++i) {
00068 switch(c = f[i]) {
00069 case '-': fmt |= ios::left; break;
00070 case '+': fmt |= ios::showpos; break;
00071 case ' ': break;
00072 case 'O': flc = '0'; fmt |= ios::left; break;
00073 case 'd': break;
00074 case 'u': break;
00075 case 'i': break;
00076 case 'o': fmt |= ios::oct; fmt |= ios::showbase; break;
00077 case 'x': fmt |= ios::hex; fmt |= ios::showbase; break;
00078 case 'X': fmt |= ios::hex; fmt |= ios::showbase; break;
00079 case 'f': fmt |= ios::fixed; break;
00080 case 'e': fmt |= ios::scientific; break;
00081 case 'E': fmt |= ios::scientific; break;
00082 case 'g': break;
00083 case 'G': break;
00084 default:
00085 if (c == '.') {
00086 n[j][k] = '\0';
00087 ++j;
00088 k = 0;
00089 }
00090 else {
00091 if (c >= '0' && c <= '9') n[j][k++] = c;
00092 }
00093 break;
00094 }
00095 }
00096 if (k!=0 || j!=0) {
00097 if (j==0) n[0][k] = '\0';
00098 wdt = atoi(n[0]);
00099 }
00100 if (j>0) {
00101 n[1][k] = '\0';
00102 prc = atoi(n[1]);
00103 }
00104 }
Member Function Documentation
Definition at line 58 of file MsgFormat.h.
References fmt.
00058 { fmt=ios::fixed; return *this;}
Definition at line 59 of file MsgFormat.h.
References fmt.
00059 { fmt=ios::dec; return *this;}
Definition at line 60 of file MsgFormat.h.
References fmt.
00060 { fmt=ios::hex; return *this;}
MsgFormat& MsgFormat::left_justify |
( |
int |
b = 1 |
) |
[inline] |
Definition at line 69 of file MsgFormat.h.
References fmt.
00069 {
00070 if (b) { fmt |= ios::left; fmt &= (~ios::right); }
00071 else fmt &= ~ios::left;
00072 return *this;
00073 }
Definition at line 61 of file MsgFormat.h.
References fmt.
00061 { fmt=ios::oct; return *this;}
MsgFormat& MsgFormat::plus |
( |
int |
b = 1 |
) |
[inline] |
Definition at line 84 of file MsgFormat.h.
References fmt.
00084 {
00085 if (b) fmt |= ios::showpos;
00086 else fmt &= ~ios::showpos;
00087 return *this;
00088 }
MsgFormat& MsgFormat::precision |
( |
int |
p |
) |
[inline] |
MsgFormat& MsgFormat::right_justify |
( |
int |
b = 1 |
) |
[inline] |
Definition at line 74 of file MsgFormat.h.
References fmt.
00074 {
00075 if (b) { fmt |= ios::right; fmt &= (~ios::left); }
00076 else fmt &= ~ios::right;
00077 return *this;
00078 }
MsgFormat& MsgFormat::scientific |
( |
|
) |
[inline] |
Definition at line 62 of file MsgFormat.h.
References fmt.
00062 { fmt=ios::scientific; return *this;}
MsgFormat& MsgFormat::set_fill |
( |
char |
c |
) |
[inline] |
MsgFormat& MsgFormat::show_base |
( |
int |
b = 1 |
) |
[inline] |
Definition at line 79 of file MsgFormat.h.
References fmt.
00079 {
00080 if (b) fmt |= ios::showbase;
00081 else fmt &= ~ios::showbase;
00082 return *this;
00083 }
MsgFormat& MsgFormat::trailing_zeros |
( |
int |
b = 1 |
) |
[inline] |
Definition at line 89 of file MsgFormat.h.
References fmt.
00089 {
00090 if (b) fmt |= ios::showpoint;
00091 else fmt &= ~ios::showpoint;
00092 return *this;
00093 }
MsgFormat& MsgFormat::width |
( |
int |
w |
) |
[inline] |
Friends And Related Function Documentation
Definition at line 20 of file MsgFormat.cxx.
00021 {
00022
00023
00024
00025
00026
00027
00028
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
00046 if (c != os.fill()) os.fill(c);
00047 os.precision(p);
00048 os.flags(f);
00049 return os;
00050 }
Member Data Documentation
Definition at line 98 of file MsgFormat.h.
Referenced by fixed(), general(), hex(), left_justify(), MsgFormat(), oct(), operator<<(), plus(), right_justify(), scientific(), show_base(), and trailing_zeros().
The documentation for this class was generated from the following files: