ae.utils.text.functor

Functor-powered lazy @nogc text formatting.

Members

Functions

fmtIf
auto fmtIf(Cond cond, T t, F f)

Returns an object which, depending on a condition, is stringified as one of two objects. The two branches should themselves be passed as nullary functors, to enable lazy evaluation. Combines formattingFunctor, stringifiable, and select.

fmtSeq
auto fmtSeq(Values values)

Returns an object which is stringified as all of the given objects in sequence. In essence, a lazy std.conv.text. Combines formattingFunctor, stringifiable, and seq.

formatted
auto formatted(T values)

Constructs a stringifiable object from a value (i.e., a lazily formatted object). Combines formattingFunctor and stringifiable.

stringifiable
auto stringifiable(F functor)

Constructs a stringifiable object from a functor.

Templates

formattingFunctor
template formattingFunctor(string fmt = null, int line = __LINE__, T...)

Given zero or more values, returns a functor which retains a copy of these values; the functor can later be called with a sink, which will make it write the values out. The returned functor's signature varies depending on whether a format string is specified, but either way compatible with toString signatures accepted by formattedWrite If a format string is specified, that will be used to format the values; otherwise, a format string will be accepted at call time. For details, see accepted toString signatures in the "Structs, Unions, Classes, and Interfaces" section of https://dlang.org/phobos/std_format_write.html.

stringifiable
template stringifiable(alias fun, T...)

Constructs a functor type from a function alias, and wraps it into a stringifiable object. Can be used to create stringifiable widgets which need a sink for more complex behavior.

Meta

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Authors

Vladimir Panteleev <ae@cy.md>