Line wrapping in ostream

Discussion in 'C++' started by Alex Dribin, Aug 6, 2003.

  1. Alex Dribin

    Alex Dribin Guest

    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
    Alex Dribin, Aug 6, 2003
    #1
    1. Advertising

  2. 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
    Karl Heinz Buchegger, Aug 6, 2003
    #2
    1. Advertising

  3. Alex Dribin <> 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:> <http://www.dietmar-kuehl.de/>
    Phaidros eaSE - Easy Software Engineering: <http://www.phaidros.com/>
    Dietmar Kuehl, Aug 6, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWc=?=

    Line wrapping with WebForm Label

    =?Utf-8?B?bWc=?=, Jan 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    395
    =?Utf-8?B?QmFycnkgRm9ycmVzdA==?=
    Jan 19, 2004
  2. Amelyan
    Replies:
    2
    Views:
    662
    Amelyan
    May 21, 2005
  3. Gnarlodious
    Replies:
    9
    Views:
    13,403
    Bernhard Sturm
    Jan 28, 2005
  4. Carolyn Marenger

    horizontal menu line wrapping issue

    Carolyn Marenger, Mar 18, 2006, in forum: HTML
    Replies:
    4
    Views:
    667
    dorayme
    Mar 19, 2006
  5. Replies:
    2
    Views:
    1,902
Loading...

Share This Page