17namespace swoc {
inline namespace SWOC_VERSION_NS {
19using namespace swoc::literals;
59 Date(std::string_view fmt = DEFAULT_FORMAT);
64inline std::string_view
65FirstOfConverter(std::nullptr_t) {
66 return std::string_view{};
69inline std::string_view
70FirstOfConverter(
char const *s) {
71 return std::string_view{s ? s :
""};
77FirstOfConverter(T &&t) {
84template <
typename... Args>
87 std::array<std::string_view,
sizeof...(args)> strings{{detail::FirstOfConverter(args)...}};
88 for (
auto &s : strings) {
92 return std::string_view{};
99template <
typename... Args>
struct SubText {
108 bool operator!()
const;
111 explicit operator bool()
const;
114template <
typename... Args>
SubText<Args...>::operator bool()
const {
115 return !
_fmt.empty();
118template <
typename... Args>
144template <
typename... Args>
147 return SubText<Args...>(flag ? fmt :
TextView{}, std::forward_as_tuple(args...));
155 return SubText<T>(t.empty() ?
TextView{} : fmt, std::forward_as_tuple(t));
162 return SubText<T>(
bool(t) ? fmt :
TextView{}, std::forward_as_tuple(t));
168Optional(meta::CaseTag<0>, TextView fmt, T &&t) -> SubText<T> {
169 return SubText<T>(fmt, std::forward_as_tuple(t));
204template <
typename ARG>
207 return detail::Optional(meta::CaseArg, fmt, std::forward<ARG>(arg));
275template <
typename... Args>
278 if (!subtext.
_fmt.empty()) {
SubText< ARG > Optional(TextView fmt, ARG &&arg)
std::string_view FirstOf(Args &&...args)
SubText< Args... > If(bool flag, TextView const &fmt, Args &&...args)
BufferWriter & print_v(const TextView &fmt, const std::tuple< Args... > &args)
For template deduction guides.
BufferWriter & bwformat(BufferWriter &w, bwf::Spec const &spec, std::string_view sv)
static constexpr std::string_view DEFAULT_FORMAT
Default format.
Date(time_t t, std::string_view fmt=DEFAULT_FORMAT)
std::string_view _fmt
Data format.
Errno(int e=errno)
Construct wrapper, default to current errno.
std::string_view _text
output text.
arg_pack _args
Arguments to format string.
bool operator!() const
Check for output not enabled.
std::tuple< Args... > arg_pack
The pack of arguments for format string.
TextView _fmt
Format string. If empty, do not generate output.
SubText(TextView const &fmt, arg_pack const &args)
Construct with a specific fmt and args.
MemSpan< void const > _span
Source span.