Topic: ios::iword, ios::pword, ios::xalloc
Author: lewis@sophists.com (Lewis G. Pringle)
Date: Mon, 12 Oct 1992 18:14:26 GMT Raw View
In article <1992Oct8.234902.12170@lucid.com> jss@lucid.com (Jerry Schwarz) writes:
>These functions are intended to support extension of stream types
>without requiring derivation. My claim is that this is useful because
>the actual type of a stream is lost in an expression involving insertions
>or extractions. That is
>
> mystream m ;
> m << y << mymanipulator ;
>
>You can't declare
>
> mystream& mymanipulator(mystream&) ;
>
>because it's argument is an ostream&, not a mystream&. However mymanipulator
>can look into the infinite arrays for any useful information put there
>by the mystream constructor.
Could you please elaborate even further.
A long standing problem with the isotream library, from my point of view,
was that roughly half the time I wanted the interpretation of inserters
to be that it inserted a "pretty" form of the item, and the other half
of the time I wanted the interpretation to be to insert an EXTRACTABLE
represenation of the item. This "pretty" form is most often useful when
preparing to display some object, or when writting out debug info. The
EXTRACTABLE version is most useful when saving and restoring to a file.
I've experimented with hacks like global variables, etc, but what I really
wanted was the ability to "add a boolean" into the iostream so that each
inserter could write things out appropriately. Ideally I would want the
predefiend inserters and extractors (eg int) to also pay attention to
this boolean.
Could the iword/pword mechanism be used to achieve this? Do you know of
some better mechanism to achieve this? How are you supposed to actually
use the iword/pword mechanism? Where is it documented?
Lewis.
--
Reading peoples signatures is a real waste of time.
lewis@sophists.com (Lewis Gordon Pringle, Jr.)
Author: Lewis.G..Pringle@f1.n100.z60.wlink.nl (Lewis G. Pringle)
Date: Mon, 12 Oct 1992 20:14:26 -0100 Raw View
Organization: Sophist Solutions
In article <1992Oct8.234902.12170@lucid.com> jss@lucid.com (Jerry Schwarz) writes:
>These functions are intended to support extension of stream types
>without requiring derivation. My claim is that this is useful because
>the actual type of a stream is lost in an expression involving insertions
>or extractions. That is
>
> mystream m ;
> m << y << mymanipulator ;
>
>You can't declare
>
> mystream& mymanipulator(mystream&) ;
>
>because it's argument is an ostream&, not a mystream&. However mymanipulator
>can look into the infinite arrays for any useful information put there
>by the mystream constructor.
Could you please elaborate even further.
A long standing problem with the isotream library, from my point of view,
was that roughly half the time I wanted the interpretation of inserters
to be that it inserted a "pretty" form of the item, and the other half
of the time I wanted the interpretation to be to insert an EXTRACTABLE
represenation of the item. This "pretty" form is most often useful when
preparing to display some object, or when writting out debug info. The
EXTRACTABLE version is most useful when saving and restoring to a file.
I've experimented with hacks like global variables, etc, but what I really
wanted was the ability to "add a boolean" into the iostream so that each
inserter could write things out appropriately. Ideally I would want the
predefiend inserters and extractors (eg int) to also pay attention to
this boolean.
Could the iword/pword mechanism be used to achieve this? Do you know of
some better mechanism to achieve this? How are you supposed to actually
use the iword/pword mechanism? Where is it documented?
Lewis.
--
Reading peoples signatures is a real waste of time.
lewis@sophists.com (Lewis Gordon Pringle, Jr.)