reducing size of a stringstream
As an easy way to store several status logs etc. I have chosen a
std::stringstream. In case of an error I can simply dump .rdbuf() into a
file to be able to reproduce what my program has been doing before it
crashed.
My problem now is, that this stringstream grows in size indefinitely. I
have tried several things to ensure that I only keep the last 1MiB or so
of the stream but have not been successful.
.rdbuf()->pubseekoff(...)
.ignore(...)
getline(...)
ss.str() = ss.str().substr(...)
Apparently the underlying buffer object always only increases in size - no
matter whether some of the data has already been read or not.
Is there any way to reduce the size / hold it at some constant (preferably
without regular deep copies)? A circular buffer as an underlying buffer
object would be perfect - is that possible? Esp. does that already exist?
No comments:
Post a Comment