|
LibSWOC++ 1.5.14
Solid Wall of C++
|
#include <array>#include <string_view>#include "swoc/swoc_version.h"#include "swoc/bwf_base.h"#include "swoc/swoc_meta.h"

Go to the source code of this file.
Classes | |
| struct | swoc::bwf::Pattern |
| struct | swoc::bwf::Errno |
| struct | swoc::bwf::Date |
| struct | swoc::bwf::SubText< Args > |
| struct | swoc::bwf::UnHex |
Namespaces | |
| namespace | swoc |
| For template deduction guides. | |
Functions | |
| std::string_view | swoc::bwf::detail::FirstOfConverter (std::nullptr_t) |
| std::string_view | swoc::bwf::detail::FirstOfConverter (char const *s) |
| template<typename T> | |
| std::string_view | swoc::bwf::detail::FirstOfConverter (T &&t) |
| template<typename... Args> | |
| std::string_view | swoc::bwf::FirstOf (Args &&...args) |
| template<typename... Args> | |
| SubText< Args... > | swoc::bwf::If (bool flag, TextView const &fmt, Args &&...args) |
| template<typename T> | |
| auto | swoc::bwf::detail::Optional (meta::CaseTag< 2 >, TextView fmt, T &&t) -> decltype(void(t.empty()), meta::TypeFunc< SubText< T > >()) |
| template<typename T> | |
| auto | swoc::bwf::detail::Optional (meta::CaseTag< 1 >, TextView fmt, T &&t) -> decltype(bool(t), meta::TypeFunc< SubText< T > >()) |
| template<typename T> | |
| auto | swoc::bwf::detail::Optional (meta::CaseTag< 0 >, TextView fmt, T &&t) -> SubText< T > |
| template<typename ARG> | |
| SubText< ARG > | swoc::bwf::Optional (TextView fmt, ARG &&arg) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, bwf::Pattern const &pattern) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, bwf::Errno const &e) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, bwf::Date const &date) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, bwf::UnHex const &obj) |
| template<typename... Args> | |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &, bwf::SubText< Args... > const &subtext) |
BufferWriter formatters for types in the std namespace.
Definition in file bwf_ex.h.
| std::string_view swoc::bwf::FirstOf | ( | Args &&... | args | ) |
|
inline |
|
inline |
| std::string_view swoc::bwf::detail::FirstOfConverter | ( | T && | t | ) |
| SubText< Args... > swoc::bwf::If | ( | bool | flag, |
| TextView const & | fmt, | ||
| Args &&... | args ) |
Optional printing wrapper.
| Args | Arguments for output. |
| flag | Generate output flag. |
| fmt | Format for output and args. |
| args | The arguments. |
This function is passed a flag, a printing format fmt, and a set of arguments args to be used by the format. Output is generated if flag is true, otherwise the empty string (no output) is generated. For example, if in a function there was a flag to determine if an extra tag with delimiters, e.g. "[tag]", was to be generated, this could be done with
| auto swoc::bwf::detail::Optional | ( | meta::CaseTag< 0 > | , |
| TextView | fmt, | ||
| T && | t ) -> SubText<T> |
| auto swoc::bwf::detail::Optional | ( | meta::CaseTag< 1 > | , |
| TextView | fmt, | ||
| T && | t ) -> decltype(bool(t), meta::TypeFunc<SubText<T>>()) |
| auto swoc::bwf::detail::Optional | ( | meta::CaseTag< 2 > | , |
| TextView | fmt, | ||
| T && | t ) -> decltype(void(t.empty()), meta::TypeFunc<SubText<T>>()) |
| SubText< ARG > swoc::bwf::Optional | ( | TextView | fmt, |
| ARG && | arg ) |
Simplified optional text wrapper.
| ARG | the type of the (single) argument. |
| fmt | Format string. |
| arg | The single argument to the format string and predicate. |
This generates output iff arg is not empty. fmt is required to take only a single argument, which will be arg. This is a convenience overload, to handle the common case where the argument and the conditional are the same. The argument must have one of the following properties in order to serve as the conditional. These are checked in order.
empty() method which returns true if the argument is empty and should not be printed. This handles the case of C++ string types.bool which is false if the argument should not be printed. This covers the case of pointers.As an example, if an output function had three strings alpha, bravo, and charlie, each of which could be null, which should be output with space separators, this would be
Because of the property handling, these strings can be C styles strings ( char* ) or C++ string types (such as std::string_view ).