|
|
@ -495,7 +495,11 @@ namespace detail {
|
|
|
|
class FormatArg
|
|
|
|
class FormatArg
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
FormatArg() {}
|
|
|
|
FormatArg()
|
|
|
|
|
|
|
|
: m_value(nullptr),
|
|
|
|
|
|
|
|
m_formatImpl(nullptr),
|
|
|
|
|
|
|
|
m_toIntImpl(nullptr)
|
|
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
template<typename T>
|
|
|
|
explicit FormatArg(const T& value)
|
|
|
|
explicit FormatArg(const T& value)
|
|
|
@ -507,11 +511,15 @@ class FormatArg
|
|
|
|
void format(std::ostream& out, const char* fmtBegin,
|
|
|
|
void format(std::ostream& out, const char* fmtBegin,
|
|
|
|
const char* fmtEnd, int ntrunc) const
|
|
|
|
const char* fmtEnd, int ntrunc) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
assert(m_value);
|
|
|
|
|
|
|
|
assert(m_formatImpl);
|
|
|
|
m_formatImpl(out, fmtBegin, fmtEnd, ntrunc, m_value);
|
|
|
|
m_formatImpl(out, fmtBegin, fmtEnd, ntrunc, m_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int toInt() const
|
|
|
|
int toInt() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
assert(m_value);
|
|
|
|
|
|
|
|
assert(m_toIntImpl);
|
|
|
|
return m_toIntImpl(m_value);
|
|
|
|
return m_toIntImpl(m_value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -712,23 +720,27 @@ inline const char* streamStateFromFormat(std::ostream& out, bool& spacePadPositi
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'X':
|
|
|
|
case 'X':
|
|
|
|
out.setf(std::ios::uppercase);
|
|
|
|
out.setf(std::ios::uppercase);
|
|
|
|
|
|
|
|
// Falls through
|
|
|
|
case 'x': case 'p':
|
|
|
|
case 'x': case 'p':
|
|
|
|
out.setf(std::ios::hex, std::ios::basefield);
|
|
|
|
out.setf(std::ios::hex, std::ios::basefield);
|
|
|
|
intConversion = true;
|
|
|
|
intConversion = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
case 'E':
|
|
|
|
out.setf(std::ios::uppercase);
|
|
|
|
out.setf(std::ios::uppercase);
|
|
|
|
|
|
|
|
// Falls through
|
|
|
|
case 'e':
|
|
|
|
case 'e':
|
|
|
|
out.setf(std::ios::scientific, std::ios::floatfield);
|
|
|
|
out.setf(std::ios::scientific, std::ios::floatfield);
|
|
|
|
out.setf(std::ios::dec, std::ios::basefield);
|
|
|
|
out.setf(std::ios::dec, std::ios::basefield);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'F':
|
|
|
|
case 'F':
|
|
|
|
out.setf(std::ios::uppercase);
|
|
|
|
out.setf(std::ios::uppercase);
|
|
|
|
|
|
|
|
// Falls through
|
|
|
|
case 'f':
|
|
|
|
case 'f':
|
|
|
|
out.setf(std::ios::fixed, std::ios::floatfield);
|
|
|
|
out.setf(std::ios::fixed, std::ios::floatfield);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'G':
|
|
|
|
case 'G':
|
|
|
|
out.setf(std::ios::uppercase);
|
|
|
|
out.setf(std::ios::uppercase);
|
|
|
|
|
|
|
|
// Falls through
|
|
|
|
case 'g':
|
|
|
|
case 'g':
|
|
|
|
out.setf(std::ios::dec, std::ios::basefield);
|
|
|
|
out.setf(std::ios::dec, std::ios::basefield);
|
|
|
|
// As in boost::format, let stream decide float format.
|
|
|
|
// As in boost::format, let stream decide float format.
|
|
|
|