By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,836 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

Line wrapping in ostream

P: n/a
Hi,

Are there ready solutions for auto-wrapping lines in ostream?

I am using ostream for output and want this output to be wrapped at some
position. Of course I can monitor stream pointer position and insert
end-of-lines periodically. Something better than that?

Alex

Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


Alex Dribin wrote:

Hi,

Are there ready solutions for auto-wrapping lines in ostream?

I am using ostream for output and want this output to be wrapped at some
position. Of course I can monitor stream pointer position and insert
end-of-lines periodically. Something better than that?


You want to equip the stream object with a custom stream buffer.
Search the newsgroup comp.lang.c++ for posts from Dietmar Kuehl.
He has posted examples of how to write stream buffer classes
in the past.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 19 '05 #2

P: n/a
Alex Dribin <no****@nospam.net> wrote:
Are there ready solutions for auto-wrapping lines in ostream?
Dunno.
I am using ostream for output and want this output to be wrapped at some
position. Of course I can monitor stream pointer position and insert
end-of-lines periodically. Something better than that?


Create a stream buffer whose buffer happens to be the maximum size of your
line. On buffer overflow you just search the buffer up to the first newline
and sent this portion, moving the remainder to the front of the buffer. If
there is no newline, you jsut sent the whole buffer followed by a newline
and emptying the buffer.

This stream buffer is probably a filtering stream buffer and would take
something like maybe 20 lines. Together with a few convenience classes you
will have something like 50 lines.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
Phaidros eaSE - Easy Software Engineering: <http://www.phaidros.com/>
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.