|
LibSWOC++ 1.5.14
Solid Wall of C++
|
#include <cstdlib>#include <utility>#include <cstring>#include <vector>#include <unordered_map>#include <string>#include <iosfwd>#include <string_view>#include <functional>#include <tuple>#include <any>#include <array>#include "swoc/swoc_version.h"#include "swoc/TextView.h"#include "swoc/MemSpan.h"#include "swoc/MemArena.h"#include "swoc/BufferWriter.h"#include "swoc/swoc_meta.h"

Go to the source code of this file.
Classes | |
| struct | swoc::bwf::Spec |
| struct | swoc::bwf::Spec::Property |
| Handrolled initialization the character syntactic property data. More... | |
| struct | swoc::bwf::Format |
| struct | swoc::bwf::Format::TextViewExtractor |
| Extraction support for TextView. More... | |
| struct | swoc::bwf::Format::FormatExtractor |
| Extraction support for pre-parsed format strings. More... | |
| class | swoc::bwf::NameBinding |
| class | swoc::bwf::NilBinding |
| class | swoc::bwf::NameMap< F > |
| class | swoc::bwf::ExternalNames |
| class | swoc::bwf::ContextNames< T > |
| class | swoc::bwf::ContextNames< T >::Binding |
Specialized binding for names in an instance of ContextNames. More... | |
| class | swoc::bwf::ArgPack |
| class | swoc::bwf::ArgTuple< Args > |
| struct | swoc::bwf::HexDump |
Namespaces | |
| namespace | swoc |
| For template deduction guides. | |
Typedefs | |
| using | swoc::bwf::ExternalGeneratorSignature = BufferWriter &(BufferWriter &w, Spec const &spec) |
| template<typename TUPLE> | |
| using | swoc::bwf::ArgFormatterSignature = BufferWriter &(*)(BufferWriter &w, Spec const &, TUPLE const &args) |
| — Formatting — | |
| template<typename T> | |
| using | swoc::bwf::TupleAccessorSignature = std::any (*)(T const &t) |
| The signature for accessing an element of a tuple. | |
Functions | |
| ExternalNames & | swoc::bwf::Global_Names () |
| void | swoc::bwf::Err_Bad_Arg_Index (BufferWriter &w, int i, size_t n) |
| Internal error / reporting message generators. | |
| template<typename TUPLE, size_t I> | |
| BufferWriter & | swoc::bwf::Arg_Formatter (BufferWriter &w, Spec const &spec, TUPLE const &args) |
| template<typename TUPLE, size_t... N> | |
| ArgFormatterSignature< TUPLE > * | swoc::bwf::Get_Arg_Formatter_Array (std::index_sequence< N... >) |
| void | swoc::bwf::Adjust_Alignment (BufferWriter &aux, Spec const &spec) |
| BufferWriter & | swoc::bwf::Format_Integer (BufferWriter &w, Spec const &spec, uintmax_t i, bool neg_p) |
| BufferWriter & | swoc::bwf::Format_Float (BufferWriter &w, Spec const &spec, double f, bool negative_p) |
| void | swoc::bwf::Format_As_Hex (BufferWriter &w, std::string_view view, const char *digits) |
| template<size_t IDX, typename T> | |
| std::any | swoc::bwf::TupleAccessor (T const &t) |
| Template access method. | |
| template<typename T, size_t... N> | |
| std::array< TupleAccessorSignature< T >, sizeof...(N)> & | swoc::bwf::Tuple_Accessor_Array (std::index_sequence< N... >) |
| Create and return an array of specialized accessors, indexed by tuple index. | |
| template<typename T> | |
| std::any | swoc::bwf::Tuple_Nth (T const &t, size_t idx) |
Get the Nth element of the tuple as std::any. | |
| template<typename F> | |
| auto | swoc::bwf::arg_capture (F &&, BufferWriter &, Spec const &, std::any &&, swoc::meta::CaseTag< 0 >) -> void |
| template<typename F> | |
| auto | swoc::bwf::arg_capture (F &&f, BufferWriter &w, Spec const &spec, std::any &&value, swoc::meta::CaseTag< 1 >) -> decltype(f.capture(w, spec, value)) |
| template<typename EXTRACTOR, typename VIEW, typename SPEC> | |
| auto | swoc::bwf::extractor_spec_type (bool(EXTRACTOR::*)(VIEW, SPEC)) -> SPEC |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, std::string_view sv) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, const void *ptr) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, MemSpan< void const > const &span) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, MemSpan< void > const &span) |
| template<typename T> | |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, MemSpan< T > const &span) |
| template<size_t N> | |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, const char(&a)[N]) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, std::nullptr_t) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, const char *v) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, std::string const &s) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, TextView tv) |
| template<typename X, typename V> | |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &, TransformView< X, V > &&view) |
| template<typename F> | |
| auto | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, F &&f) -> typename std::enable_if< std::is_floating_point_v< typename std::remove_reference_t< F > >, BufferWriter & >::type |
| template<typename I> | |
| auto | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, I &&i) -> typename std::enable_if< std::is_unsigned< typename std::remove_reference< I >::type >::value &&std::is_integral< typename std::remove_reference< I >::type >::value, BufferWriter & >::type |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &, char c) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, bool f) |
| template<typename... Args> | |
| std::string & | swoc::bwprint_v (std::string &s, TextView fmt, std::tuple< Args... > const &args) |
| template<typename... Args> | |
| std::string & | swoc::bwprint (std::string &s, TextView fmt, Args &&...args) |
| template<typename... Args> | |
| std::string & | swoc::bwappend (std::string &s, TextView fmt, Args &&...args) |
| template<typename T> | |
| auto | swoc::detail::tag_label (BufferWriter &, const bwf::Spec &, meta::CaseTag< 0 >) -> void |
| template<typename T> | |
| auto | swoc::detail::tag_label (BufferWriter &w, const bwf::Spec &, meta::CaseTag< 1 >) -> decltype(T::label, meta::TypeFunc< void >()) |
| template<intmax_t N, typename C, typename T> | |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, Scalar< N, C, T > const &x) |
| template<typename V> | |
| BufferWriter & | swoc::operator<< (BufferWriter &w, V &&v) |
| template<typename T> | |
| HexDump | swoc::bwf::As_Hex (T const &t) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, bwf::HexDump const &hex) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, BufferWriter const &ww) |
Basic formatting support for BufferWriter.
Definition in file bwf_base.h.
| using swoc::bwf::ArgFormatterSignature = BufferWriter &(*)(BufferWriter &w, Spec const &, TUPLE const &args) |
— Formatting —
Internal signature for template generated formatting. args is a forwarded tuple of arguments to be processed.
Definition at line 640 of file bwf_base.h.
| using swoc::bwf::ExternalGeneratorSignature = BufferWriter &(BufferWriter &w, Spec const &spec) |
Signature for a functor bound to a name.
| w | The output. |
| spec | The format specifier. |
The functor is expected to write to w based on spec.
Definition at line 241 of file bwf_base.h.
| using swoc::bwf::TupleAccessorSignature = std::any (*)(T const &t) |
The signature for accessing an element of a tuple.
Definition at line 720 of file bwf_base.h.
| void swoc::bwf::Adjust_Alignment | ( | BufferWriter & | aux, |
| Spec const & | spec ) |
This performs generic alignment operations.
If a formatter specialization performs this operation instead, that should result in output that is at least spec._min characters wide, which will cause this function to make no further adjustments.
Perform alignment adjustments / fill on w of the content in lw. This is the normal mechanism, in cases where the length can be known or limited before conversion, it can be more efficient to work in a temporary local buffer and copy out as needed without moving data in the output buffer.
Definition at line 276 of file bw_format.cc.
| auto swoc::bwf::arg_capture | ( | F && | , |
| BufferWriter & | , | ||
| Spec const & | , | ||
| std::any && | , | ||
| swoc::meta::CaseTag< 0 > | ) -> void |
If capture is used, the format extractor must provide a capture method. This isn't required so make it compile time optional, but throw if the extractor sets up for capture and didn't provide one.
Definition at line 749 of file bwf_base.h.
| auto swoc::bwf::arg_capture | ( | F && | f, |
| BufferWriter & | w, | ||
| Spec const & | spec, | ||
| std::any && | value, | ||
| swoc::meta::CaseTag< 1 > | ) -> decltype(f.capture(w, spec, value)) |
Definition at line 755 of file bwf_base.h.
| BufferWriter & swoc::bwf::Arg_Formatter | ( | BufferWriter & | w, |
| Spec const & | spec, | ||
| TUPLE const & | args ) |
This selects the I th argument in the TUPLE arg pack and calls the formatter on it. This (or the equivalent lambda) is needed because the array of formatters must have a homogenous signature, not vary per argument. Effectively this indirection erases the type of the specific argument being formatted. Instances of this have the signature ArgFormatterSignature.
Definition at line 653 of file bwf_base.h.
| HexDump swoc::bwf::As_Hex | ( | T const & | t | ) |
Treat t as raw memory and dump the memory as hexadecimal.
| T | Type of argument. |
| t | Object to dump. |
This is the standard way to do a hexadecimal memory dump of an object.
Definition at line 1309 of file bwf_base.h.
| void swoc::bwf::Err_Bad_Arg_Index | ( | BufferWriter & | w, |
| int | i, | ||
| size_t | n ) |
Internal error / reporting message generators.
Definition at line 264 of file bw_format.cc.
| auto swoc::bwf::extractor_spec_type | ( | bool(EXTRACTOR::* | )(VIEW, SPEC) | ) | -> SPEC |
Extract the specifier type from an Extractor.
| EXTRACTOR | Format extractor functor type. |
| VIEW | String view argument type. |
| SPEC | Specifier argument type. |
This is never called - it exists to extract SPEC from a format extractor functor to be used to declare the specifier instance passed to the format extractor. When used in this fashion with decltype the extracted type is a reference and that must be removed for the actual declaration type. The purpose is to enable format extractors to subclass bwf::Spec to pass additional information along, particularly to a name binding without interfering with the base use case.
Definition at line 776 of file bwf_base.h.
| void swoc::bwf::Format_As_Hex | ( | BufferWriter & | w, |
| std::string_view | view, | ||
| const char * | digits ) |
Format output as a hexadecimal dump.
| w | Output buffer. |
| view | Input view. |
| digits | Digit array for hexadecimal digits. |
This dumps the memory in the view as a hexadecimal string.
Definition at line 595 of file bw_format.cc.
| BufferWriter & swoc::bwf::Format_Float | ( | BufferWriter & | w, |
| Spec const & | spec, | ||
| double | f, | ||
| bool | negative_p ) |
Format for floating point values. Seperates floating point into a whole number and a fraction. The fraction is converted into an unsigned integer based on the specified precision, spec._prec. ie. 3.1415 with precision two is seperated into two unsigned integers 3 and 14. The different pieces are assembled and placed into the BufferWriter. The default is two decimal places. ie. X.XX. The value is always written in base 10.
format: whole.fraction or: left.right
Format f as a floating point value.
| w | Output buffer. |
| spec | Format specifier. |
| f | Input value to format. |
| negative_p | Input value shoudl be treated as a negative value. |
A leading sign character will be output based on spec and negative_p.
Definition at line 500 of file bw_format.cc.
| BufferWriter & swoc::bwf::Format_Integer | ( | BufferWriter & | w, |
| Spec const & | spec, | ||
| uintmax_t | n, | ||
| bool | negative_p ) |
Format n as an integral value.
| w | Output buffer. |
| spec | Format specifier. |
| n | Input value to format. |
| negative_p | Input value should be treated as a negative value. |
A leading sign character will be output based on spec and negative_p.
Definition at line 404 of file bw_format.cc.
| ArgFormatterSignature< TUPLE > * swoc::bwf::Get_Arg_Formatter_Array | ( | std::index_sequence< N... > | ) |
This exists only to expand the index sequence into an array of formatters for the tuple type TUPLE. Due to language limitations it cannot be done directly. The formatters can be accessed via standard array access in contrast to templated tuple access. The actual array is static and therefore at run time the only operation is loading the address of the array.
Definition at line 663 of file bwf_base.h.
| ExternalNames & swoc::bwf::Global_Names | ( | ) |
Default global names. This nameset is used if no other is provided. Therefore bindings added to this nameset will be available in the default formatting use.
Definition at line 33 of file bw_format.cc.
| auto swoc::detail::tag_label | ( | BufferWriter & | , |
| const bwf::Spec & | , | ||
| meta::CaseTag< 0 > | ) -> void |
Definition at line 1250 of file bwf_base.h.
| auto swoc::detail::tag_label | ( | BufferWriter & | w, |
| const bwf::Spec & | , | ||
| meta::CaseTag< 1 > | ) -> decltype(T::label, meta::TypeFunc<void>()) |
Definition at line 1254 of file bwf_base.h.
| std::array< TupleAccessorSignature< T >, sizeof...(N)> & swoc::bwf::Tuple_Accessor_Array | ( | std::index_sequence< N... > | ) |
Create and return an array of specialized accessors, indexed by tuple index.
Definition at line 732 of file bwf_base.h.
| std::any swoc::bwf::Tuple_Nth | ( | T const & | t, |
| size_t | idx ) |
Get the Nth element of the tuple as std::any.
Definition at line 740 of file bwf_base.h.
| std::any swoc::bwf::TupleAccessor | ( | T const & | t | ) |
Template access method.
Definition at line 725 of file bwf_base.h.