29 #ifndef __BASE_CPRINTF_FORMATS_HH__
30 #define __BASE_CPRINTF_FORMATS_HH__
104 template <
typename T>
108 std::ios::fmtflags
flags(out.flags());
112 out.setf(std::ios::hex, std::ios::basefield);
116 out.setf(std::ios::oct, std::ios::basefield);
120 out.setf(std::ios::dec, std::ios::basefield);
126 out.setf(std::ios::showbase);
147 out.width(fmt.
width);
150 out.setf(std::ios::left);
153 out.setf(std::ios::showpos);
156 out.setf(std::ios::uppercase);
163 template <
typename T>
167 std::ios::fmtflags
flags(out.flags());
176 out.width(fmt.
width);
181 out.setf(std::ios::scientific);
184 }
else if (fmt.
width > 0) {
185 out.width(fmt.
width);
189 out.setf(std::ios::uppercase);
195 out.width(fmt.
width);
197 out.setf(std::ios::fixed);
199 }
else if (fmt.
width > 0) {
200 out.width(fmt.
width);
210 out.width(fmt.
width);
220 template <
typename T>
225 std::stringstream foo;
227 int flen = foo.str().size();
229 if (fmt.
width > flen) {
230 char spaces[fmt.
width - flen + 1];
231 std::memset(spaces,
' ', fmt.
width - flen);
232 spaces[fmt.
width - flen] = 0;
235 out << foo.str() << spaces;
237 out << spaces << foo.str();
254 template <
typename T>
258 out <<
"<bad arg type for char format>";
330 template <
typename T>
365 template <
typename T>
369 out <<
"<bad arg type for float format>";
387 template <
typename T>
397 #endif // __CPRINTF_FORMATS_HH__