Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2004-09-13 03:05:32


>>
>> Well, I think my alternative is better if you want a stateful change,
>> since yours doesn't accomplish that. My suggestion is certainly
>> consistent with normal io manipulators. The point is to stream a
>> bunch of sequences without having to repeat the format part.
>
>
> I understand what you are saying and yes your version is neater.
> However, implementing something like this would have performance
> penalties (because you will need to create/store the preset values at
> run-time).

The penalties are small. Anyway, using std::istream/ostream have
penalties, compared to using raw FILEs ;)

That said, in this case there shouldn't be many penalties.
Again, you can use
ios_base::pword and ios_base::iword for this.
It's an advanced technique, but I think it can prove very neat and flexible.

>
> It will also change the way all sequence constructs are rendered. (n-ary
> types have a different rendreing so won't be affected). As I understand,
> this is the desired effect. But then:

You can make it possible to associate a fmt object with a delimeter object.

Example: pairfmt() with openclose_formatter.
basicfmt() with formatter. Etc.

Then, you can store (default) delimeter objects within the stream.
Once you want to output/input something, it requires a specific delim
object. You'll somehow use ios_base::pword/iword to get a reference to
that object.

> [3] how do you extend this to formatter types that have additional
> delimeters?
see above.

> [4] how do you know when to extract the default delimeter values from
> the stream?
>
see above.

Best,
John

-- 
John Torjo
-- john_at_[hidden]
Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- http://www.torjo.com/win32gui/
-- v1.4.0 - save_dlg - true binding of your data to UI controls!
    + easily add validation rules (win32gui/examples/smart_dlg)

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk