|
Boost : |
Subject: Re: [boost] Interest in another formatting library ?
From: Roberto Hinz (robhz786_at_[hidden])
Date: 2017-06-26 16:03:54
( I answered this message in private by accident. I´m resending it to list
now)
On Sun, Jun 25, 2017 at 3:26 PM, Frédéric Bron <frederic.bron_at_[hidden]>
wrote:
> > But what if we just add new input type that applies the formatting string
> > to a sublist of arguments:
> >
> > strf::make_string
> > ( "\n--------------------------------------------------\n"
> > , { strf::join_center(50)
> > , { { strf::fmt("Table {}.{} - Configuration files")
> > , {chapterId, tableId}}}}
> > , "\n--------------------------------------------------\n"
> > );
>
> I think that it would work. However, we need to be able to have any
> format for chapterId and tableId, not only the standard operator<<. If
> it is a floating point for example, we need to be able to change the
> precision...
>
> Frédéric
>
The formatting can then be specified as usual, either by a
braced-init-list around the argument ( as below ) or by facets
double x = 0.0;
double y = 0.0;
int precision = 6;
strf::make_string
( { strf::fmt("x = {0}, and y = {1}")
, { {x, {"", precision}}
, {y, {"", precision}}}}
);
Positional parameters as above can be implemented easily.
But I'm against any formatting inside the parsed string,
unless there is a really good reason. It would bring to much
complication, since the formatting characters may change
according to the input type. User-defined types, in particular,
will not be required to follow any formatting convention
robhz
On Sun, Jun 25, 2017 at 2:32 AM, Frédéric Bron <frederic.bron_at_[hidden]>
wrote:
> > Is there space for another formatting library in Boost?
> > doc: https://robhz786.github.io/stringify/doc/html/index.html
>
> I find
> strf::make_string(value, " in hexadecimal is ", {value, "#x"})
> not easy to translate.
>
> This would be written like this:
> strf::make_string(value, gettext(" in hexadecimal is "), {value, "#x"})
> but it works much better for translators to have the full sentence
> gettext("{0} in hexadecimal is {1}")
>
> I understand that what you save the time to parse the string doing so.
>
> Could have something like
> make_string("{0} in hexadecimal is {1}").with({value0, fmt0}, {value1,
> fmt1})?
>
> This would keep the parsing very simple and quick and still allow for
> compile time parsing of the format (with template facets).
>
> Frédéric
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk