Boost logo

Boost :

Subject: Re: [boost] Boost.Convert+Boost.Parameter
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-03-02 09:16:15


On Saturday, February 28, 2009 10:22 AM
Andrey Semashev wrote:
> Vladimir Batov wrote:
>
> > If you need additional (like "uppercase")
> > configuration, one writes uppercase manipulator that will pass an
> > additional parameter to op<<. Like
> >
> > string s = convert::to<string>(uuid) >> uppercase;
> >
> > std::ostream& operator<<(std::ostream& str, uuid const& id)
> > {
> > ...extract uppercase command from the stream...
> > str << id.as_string();
> > return str;
> > }
>
> Two notes regarding this:
> 1. If I understand you correctly, the "casual" user won't be able to
> extend the conversion, because the operator<< defined by the uuid
> developer still has to know what kind of hint the manipulator
> may have
> put into the stream.

The uuid author will create both the insertion operator and the manipulators it recognizes.

> 2. It's not clear to me how the conversion hint will be put into the
> stream. What's behind the "...extract uppercase command from the
> stream..." line?

If IOStreams don't already support the required formatting option, then it must be attached to the stream via its iword/pword/xalloc interfaces.

> >> Do I understand correctly that the manipulators are used
> to format or
> >> parse the input by defining their streaming operators? If
> so, then how
> >> do the manipulators compose with each other? If I write:
> >>
> >> int i = convert::from(str, -1) >> my_special_formatter
> >> >> my_super_special_formatter;
> >>
> >> which one will be called?

Both are called and the interoperate or work orthogonally as warranted by their intended behavior and use of the iword/pword/xalloc APIs.

> I assume, you mean that the manipulators don't actually do
> formatting/parsing, but instead do something tricky with the
> stream, am
> I right?
>
> If so, it begins to look like you're trying to invent a run-time
> alternative to Boost.Parameter with a different syntax.

Quite the contrary. It's an interface built upon IOStreams, which predates Boost.Parameter. Which is better, or whether 'tis better to follow the Spirit path, is yet open to debate.

> >> I think that the default value should be immediately
> recognizable. The
> >> default_ keyword does that. There were alternative syntax
> suggestions
> >> that provided that, too. I think, we should strive to the cleanest
> >> interface we can provide.

I certainly agree with that.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


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