29#ifndef __BASE_CPRINTF_FORMATS_HH__
30#define __BASE_CPRINTF_FORMATS_HH__
110 std::ios::fmtflags
flags(out.flags());
114 out.setf(std::ios::hex, std::ios::basefield);
118 out.setf(std::ios::oct, std::ios::basefield);
122 out.setf(std::ios::dec, std::ios::basefield);
128 out.setf(std::ios::showbase);
149 out.width(fmt.
width);
152 out.setf(std::ios::left);
155 out.setf(std::ios::showpos);
158 out.setf(std::ios::uppercase);
169 std::ios::fmtflags
flags(out.flags());
178 out.width(fmt.
width);
183 out.setf(std::ios::scientific);
186 }
else if (fmt.
width > 0) {
187 out.width(fmt.
width);
191 out.setf(std::ios::uppercase);
197 out.width(fmt.
width);
199 out.setf(std::ios::fixed);
201 }
else if (fmt.
width > 0) {
202 out.width(fmt.
width);
212 out.width(fmt.
width);
226 using stl_helpers::operator<<;
228 std::stringstream foo;
230 int flen = foo.str().size();
232 if (fmt.
width > flen) {
233 char spaces[fmt.
width - flen + 1];
234 std::memset(spaces,
' ', fmt.
width - flen);
235 spaces[fmt.
width - flen] = 0;
238 out << foo.str() << spaces;
240 out << spaces << foo.str();
261 out <<
"<bad arg type for char format>";
372 out <<
"<bad arg type for float format>";
static void _formatChar(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 _formatFloat(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 formatFloat(std::ostream &out, const T &data, Format &fmt)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.