29 #ifndef __BASE_CPRINTF_FORMATS_HH__
30 #define __BASE_CPRINTF_FORMATS_HH__
103 template <
typename T>
107 std::ios::fmtflags flags(out.flags());
111 out.setf(std::ios::hex, std::ios::basefield);
115 out.setf(std::ios::oct, std::ios::basefield);
119 out.setf(std::ios::dec, std::ios::basefield);
125 out.setf(std::ios::showbase);
146 out.width(fmt.
width);
149 out.setf(std::ios::left);
152 out.setf(std::ios::showpos);
155 out.setf(std::ios::uppercase);
162 template <
typename T>
166 std::ios::fmtflags flags(out.flags());
175 out.width(fmt.
width);
180 out.setf(std::ios::scientific);
183 }
else if (fmt.
width > 0) {
184 out.width(fmt.
width);
188 out.setf(std::ios::uppercase);
194 out.width(fmt.
width);
196 out.setf(std::ios::fixed);
198 }
else if (fmt.
width > 0) {
199 out.width(fmt.
width);
209 out.width(fmt.
width);
219 template <
typename T>
224 std::stringstream foo;
226 int flen = foo.str().size();
228 if (fmt.
width > flen) {
229 char spaces[fmt.
width - flen + 1];
230 std::memset(spaces,
' ', fmt.
width - flen);
231 spaces[fmt.
width - flen] = 0;
234 out << foo.str() << spaces;
236 out << spaces << foo.str();
253 template <
typename T>
257 out <<
"<bad arg type for char format>";
329 template <
typename T>
364 template <
typename T>
368 out <<
"<bad arg type for float format>";
386 template <
typename T>
396 #endif // __CPRINTF_FORMATS_HH__