Esempio n. 1
0
	/// Generates a sprintf format string for the given type.
	void ostringstream::fmtstring (char* format, const char* typestr, bool bInteger) const
	{
		*format++ = '%';
		if (m_Width)
			format = encode_dec (format, m_Width);
		if (m_Flags & left)
			*format++ = '-';
		if (!bInteger) {
			*format++ = '.';
			format = encode_dec (format, m_Precision);
		}
		while (*typestr)
			*format++ = *typestr++;
		if (bInteger)
		{
			if (m_Base == 16)
				format[-1] = 'X';
			else if (m_Base == 8)
				format[-1] = 'o';
		} else {
			if (m_Flags & scientific)
				format[-1] = 'E';
		}
		*format = 0;
	}
Esempio n. 2
0
/// Generates a sprintf format string for the given type.
void ostringstream::fmtstring (char* fmt, const char* typestr, bool bInteger) const
{
    *fmt++ = '%';
    if (_width)
  fmt = encode_dec (fmt, _width);
    if (_flags & left)
  *fmt++ = '-';
    if (!bInteger) {
  *fmt++ = '.';
  fmt = encode_dec (fmt, _precision);
    }
    while (*typestr)
  *fmt++ = *typestr++;
    if (bInteger) {
  if (_base == 16)
      fmt[-1] = 'X';
  else if (_base == 8)
      fmt[-1] = 'o';
    } else {
  if (_flags & scientific)
      fmt[-1] = 'E';
    }
    *fmt = 0;
}