Boost logo

Boost :

From: Samuel Krempp (krempp_at_[hidden])
Date: 2004-04-25 04:51:25


I meant to mention this for a while : I've written an alternative
stringstream class implementation as part of boost::format, with 2
motivations :
a. make boost::format compile on platforms that don't provide
std::stringstream (gcc-2.95)
b. allow more efficient use of stringstream in the context of
boost::format (by adding copy-less access to the stringstream's buffer,
and allowing reuse of the buffer)

Now it's been there working hand in hand with boost::format for a while,
compiling ok on mostly all platforms, but I dont know what to do about
this class, if I should leave it there undocumented and unmentionned, or
document it, or make it a mini-library, or a detail or whatever.
IMO this class might interest some users, as it is more flexible than
std::stringstream (allowing more efficient uses in some situations),
while it includes the original stringstream's interface, keeps its
overall design, and ease-of-use.

It lies in boost/format/alt_stringstream.hpp (and _impl.hpp)
it depends on the rest of boost::format only due to workaround settings
(mainly required by gcc-2.95)

alt_stringstream provides the features of std::stringstream, plus :

void clear_buffer(); // calls seekpos

// 0-copy access :
Ch * begin() const
std::streamsize size() const
std::streamsize cur_size() const

// copy buffer to string :
string_type cur_str() const // [pbase, pptr[

This cur_str() function differ from the std::stringstream str()
function, which returns a copy of [pbase, epptr[, thus unaffected by
calls to seekpos, actually preventing buffer-reuse.
(alt_stringstream defines functions cur_str() and str(), so it can have
the same behaviour as std::stringstream if used with str() )

So, what should I do with this class ?

-- 
Samuel

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk