Board index » cppbuilder » Triming characters off the end of a stream

Triming characters off the end of a stream


2008-01-23 02:16:16 AM
cppbuilder55
I have a strstream, which has a few characters at the end of the stream ')|'
to be exact, I want to remove them form the stream, but SetLength doesn't
work on strstream, and I can't find any other way to turnicate the stream.
- Dan
 
 

Re:Triming characters off the end of a stream

"Dan" < XXXX@XXXXX.COM >wrote in message
Quote
I have a strstream, which has a few characters at the end of the
stream ')|' to be exact, I want to remove them form the stream,
but SetLength doesn't work on strstream, and I can't find any
other way to turnicate the stream.
There is no direct way to truncate a strstream. You will have to copy the
desired portion of it to another stream or other container and then perform
the rest of your operations on that. For example:
strstream data;
// fill data as needed, then...
strstream tmp(data.str(), NumberOfCharsToKeep);
// use tmp as needed...
Gambit
 

Re:Triming characters off the end of a stream

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Dan" < XXXX@XXXXX.COM >wrote in message
news:479632fe$ XXXX@XXXXX.COM ...

>I have a strstream, which has a few characters at the end of the
>stream ')|' to be exact, I want to remove them form the stream,
>but SetLength doesn't work on strstream, and I can't find any
>other way to turnicate the stream.

There is no direct way to truncate a strstream. You will have to copy the
desired portion of it to another stream or other container and then
perform the rest of your operations on that. For example:

strstream data;
// fill data as needed, then...
strstream tmp(data.str(), NumberOfCharsToKeep);
// use tmp as needed...


Gambit
Guess that means unless I want to decrease performance I should just fix the
function. Thanks Remy.
- Dan
 

{smallsort}