Go to the documentation of this file.
29 #ifndef __BASE_CPRINTF_FORMATS_HH__
30 #define __BASE_CPRINTF_FORMATS_HH__
100 template <
typename T>
104 std::ios::fmtflags flags(out.flags());
108 out.setf(std::ios::hex, std::ios::basefield);
112 out.setf(std::ios::oct, std::ios::basefield);
116 out.setf(std::ios::dec, std::ios::basefield);
122 out.setf(std::ios::showbase);
143 out.width(fmt.
width);
146 out.setf(std::ios::left);
149 out.setf(std::ios::showpos);
152 out.setf(std::ios::uppercase);
159 template <
typename T>
163 std::ios::fmtflags flags(out.flags());
172 out.width(fmt.
width);
177 out.setf(std::ios::scientific);
180 }
else if (fmt.
width > 0) {
181 out.width(fmt.
width);
185 out.setf(std::ios::uppercase);
191 out.width(fmt.
width);
193 out.setf(std::ios::fixed);
195 }
else if (fmt.
width > 0) {
196 out.width(fmt.
width);
206 out.width(fmt.
width);
216 template <
typename T>
221 std::stringstream
foo;
223 int flen =
foo.str().size();
225 if (fmt.
width > flen) {
226 char spaces[fmt.
width - flen + 1];
227 std::memset(spaces,
' ', fmt.
width - flen);
228 spaces[fmt.
width - flen] = 0;
231 out <<
foo.str() << spaces;
233 out << spaces <<
foo.str();
250 template <
typename T>
254 out <<
"<bad arg type for char format>";
326 template <
typename T>
361 template <
typename T>
365 out <<
"<bad arg type for float format>";
383 template <
typename T>
392 #endif // __CPRINTF_FORMATS_HH__
static void _formatFloat(std::ostream &out, const T &data, Format &fmt)
static void _formatChar(std::ostream &out, const T &data, Format &fmt)
static void formatInteger(std::ostream &out, const T &data, Format &fmt)
static void formatString(std::ostream &out, const T &data, Format &fmt)
static void _formatString(std::ostream &out, const T &data, Format &fmt)
static void formatChar(std::ostream &out, const T &data, Format &fmt)
static void _formatInteger(std::ostream &out, const T &data, Format &fmt)
std::true_type foo(void(*)(ThreadContext *, const Ret &ret, State &state))
static void formatFloat(std::ostream &out, const T &data, Format &fmt)
Generated on Tue Mar 23 2021 19:41:23 for gem5 by doxygen 1.8.17