3 This file is part of libmspstrings
4 Copyright © 2006-2007 Mikko Rasa
5 Distributed under the LGPL
7 #include <msp/core/error.h>
15 Resets the format to the default. Mainly used by constructors.
34 Applies the format to the given ostream. All existing formatting information
37 void Fmt::apply(ostream &out) const
39 out.flags(((base==HEX) ? ios_base::hex : (base==OCT) ? ios_base::oct : ios_base::dec)
40 | ((fmode==SCI) ? ios_base::scientific : (fmode==FIXED) ? ios_base::fixed : ios_base::fmtflags(0))
41 | (fillc=='0' ? ios_base::internal : (align==LEFT) ? ios_base::left : ios_base::right)
42 | (sbase ? ios_base::showbase : ios_base::fmtflags(0))
43 | (spoint ? ios_base::showpoint : ios_base::fmtflags(0))
44 | (spos ? ios_base::showpos : ios_base::fmtflags(0))
45 | (ucase ? ios_base::uppercase : ios_base::fmtflags(0)));
52 Parses a printf-style conversion specification. Called from constructors.
54 void Fmt::parse(const char *f)
78 if(*f>='0' && *f<='9')
90 if(*f>='0' && *f<='9')
91 prec=prec*10+(*f-'0');
97 if(*f=='x' || *f=='X')
101 else if(*f=='e' || *f=='E')
103 else if(*f=='f' || *f=='F')
105 else if(*f=='g' || *f=='G')
112 else if(*f=='d' || *f=='i' || *f=='u' || *f=='c' || *f=='s')
115 throw InvalidParameterValue("Invalid conversion specifier");
117 if(*f=='E' || *f=='F' || *f=='G' || *f=='X')
123 throw InvalidParameterValue("Extra characters in conversion specification");