/// Attempts to create more output space. Returns remaining().
ostringstream::size_type ostringstream::overflow (size_type n)
{
    if (n > remaining()) {
	const uoff_t oldPos (pos());
	m_Buffer.reserve (oldPos + n, false);
	m_Buffer.resize (oldPos + n);
	ostream::link (m_Buffer);
	SetPos (oldPos);
    }
    verify_remaining ("write", "text", n);
    return (remaining());
}
Exemple #2
0
/// Aligns the write pointer on \p grain. The skipped bytes are zeroed.
void ostream::align (size_type grain)
{
    assert (!((grain-1)&grain) && "grain must be a power of 2");
    iterator ip = ipos();
    iterator ipa = iterator((uintptr_t(ip) + (grain-1)) & ~(grain-1));
    size_t nb = distance (ip, ipa);
#if WANT_STREAM_BOUNDS_CHECKING
    if (!verify_remaining ("align", "padding", nb))
	return;
#else
    assert (remaining() >= nb && "Buffer overrun. Check your stream size calculations.");
#endif
    memset (const_cast<void *>(reinterpret_cast<const void *>(ip)), '\x0', nb);
    m_Pos += nb;
}