Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2002-01-24 03:01:21


nbecker_at_[hidden] wrote:
> >> What I'd like (and what I'm trying to implement in command
> >> line/config
>
> file
>
> >> parser) is map like interface. So that one could be able to say
> >>
> >> environment["http_proxy"].as<ip_address>()
> >>
> >> where "as" method is a shortcut to lexical_cast/any_cast.
>
> What about orthogonality? I don't think translations should be built
> in. environment should give you a string. You do whatever conversion
> you want from string to whatever using nonmember functions.

I need to clarify. I don't mean that function/classes that work with
environment should bother with conversion. I mean that it would be very
convenient to have a map-like class for holding values, which would support
the following two expressions

        values["http_proxy"].exists()
        values["http_proxy"].as<ip_address>()

This class should be able to get values from any sources, be it registry or
config file, using some common interface. Again, there's no need to support
casting by environment-accessing functions.

I'd like to note that "as" won't simply call lexical_cast. In command line
library it is possible to specify a type for a variable. In this case, "as"
will use "any_cast". If no type is specified, "lexical_cast" is used. I think
this is quite a considerable convenience.

- Volodya

        

        


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