3 This file is part of libmspstrings
4 Copyright © 2006-2008 Mikko Rasa
5 Distributed under the LGPL
8 #include <msp/core/except.h>
15 void Fmt::parse(const char *f)
39 if(*f>='0' && *f<='9')
51 if(*f>='0' && *f<='9')
52 prec = prec*10+(*f-'0');
59 if(*f=='d' || *f=='u')
61 else if(*f=='x' || *f=='X')
67 else if(*f=='e' || *f=='E')
69 else if(*f=='f' || *f=='F')
71 else if(*f=='g' || *f=='G')
73 else if(*f=='p' || *f=='P')
85 throw InvalidParameterValue("Invalid conversion specifier");
87 if(*f=='E' || *f=='F' || *f=='G' || *f=='X' || *f=='P')
93 throw InvalidParameterValue("Extra characters in conversion specification");
113 void Fmt::apply(ostream &out) const
115 out.flags(((base==HEX) ? ios_base::hex : (base==OCT) ? ios_base::oct : ios_base::dec)
116 | ((fmode==SCI) ? ios_base::scientific : (fmode==FIXED) ? ios_base::fixed : ios_base::fmtflags(0))
117 | (fillc=='0' ? ios_base::internal : (align==LEFT) ? ios_base::left : ios_base::right)
118 | (sbase ? ios_base::showbase : ios_base::fmtflags(0))
119 | (spoint ? ios_base::showpoint : ios_base::fmtflags(0))
120 | (spos ? ios_base::showpos : ios_base::fmtflags(0))
121 | (ucase ? ios_base::uppercase : ios_base::fmtflags(0)));