3 This file is part of libmspstrings
4 Copyright © 2006-2008 Mikko Rasa
5 Distributed under the LGPL
8 #include <msp/core/except.h>
16 Resets the format to the default. Mainly used by constructors.
36 Applies the format to the given ostream. All existing formatting information
39 void Fmt::apply(ostream &out) const
41 out.flags(((base==HEX) ? ios_base::hex : (base==OCT) ? ios_base::oct : ios_base::dec)
42 | ((fmode==SCI) ? ios_base::scientific : (fmode==FIXED) ? ios_base::fixed : ios_base::fmtflags(0))
43 | (fillc=='0' ? ios_base::internal : (align==LEFT) ? ios_base::left : ios_base::right)
44 | (sbase ? ios_base::showbase : ios_base::fmtflags(0))
45 | (spoint ? ios_base::showpoint : ios_base::fmtflags(0))
46 | (spos ? ios_base::showpos : ios_base::fmtflags(0))
47 | (ucase ? ios_base::uppercase : ios_base::fmtflags(0)));
54 Parses a printf-style conversion specification. Called from constructors.
56 void Fmt::parse(const char *f)
80 if(*f>='0' && *f<='9')
92 if(*f>='0' && *f<='9')
93 prec=prec*10+(*f-'0');
100 if(*f=='d' || *f=='u')
102 else if(*f=='x' || *f=='X')
108 else if(*f=='e' || *f=='E')
110 else if(*f=='f' || *f=='F')
112 else if(*f=='g' || *f=='G')
114 else if(*f=='p' || *f=='P')
126 throw InvalidParameterValue("Invalid conversion specifier");
128 if(*f=='E' || *f=='F' || *f=='G' || *f=='X' || *f=='P')
134 throw InvalidParameterValue("Extra characters in conversion specification");