31 #ifndef __BASE_CPRINTF_FORMATS_HH__
32 #define __BASE_CPRINTF_FORMATS_HH__
91 ios::fmtflags flags(out.flags());
95 out.setf(std::ios::hex, std::ios::basefield);
99 out.setf(std::ios::oct, std::ios::basefield);
103 out.setf(std::ios::dec, std::ios::basefield);
109 out.setf(std::ios::showbase);
130 out.width(fmt.
width);
133 out.setf(std::ios::left);
136 out.setf(std::ios::showpos);
139 out.setf(std::ios::uppercase);
146 template <
typename T>
152 ios::fmtflags flags(out.flags());
158 out.width(fmt.
width);
163 out.setf(std::ios::scientific);
168 out.width(fmt.
width);
171 out.setf(std::ios::uppercase);
177 out.width(fmt.
width);
179 out.setf(std::ios::fixed);
183 out.width(fmt.
width);
192 out.width(fmt.
width);
202 template <
typename T>
208 #if defined(__GNUC__) && (__GNUC__ < 3) || 1
210 std::stringstream foo;
212 int flen = foo.str().size();
214 if (fmt.
width > flen) {
215 char *spaces =
new char[fmt.
width - flen + 1];
216 memset(spaces,
' ', fmt.
width - flen);
217 spaces[fmt.
width - flen] = 0;
220 out << foo.str() << spaces;
222 out << spaces << foo.str();
231 out.width(fmt.
width);
233 out.setf(std::ios::left);
247 template <
typename T>
250 { out <<
"<bad arg type for char format>"; }
299 template <
typename T>
342 template <
typename T>
345 { out <<
"<bad arg type for float format>"; }
358 template <
typename T>
369 #endif // __CPRINTF_FORMATS_HH__
void _format_float(std::ostream &out, const T &data, Format &fmt)
void _format_integer(std::ostream &out, const T &data, Format &fmt)
void format_string(std::ostream &out, const T &data, Format &fmt)
void format_float(std::ostream &out, const T &data, Format &fmt)
void format_integer(std::ostream &out, const T &data, Format &fmt)
void _format_char(std::ostream &out, const T &data, Format &fmt)
void format_char(std::ostream &out, const T &data, Format &fmt)
void _format_string(std::ostream &out, const T &data, Format &fmt)