|
LibSWOC++ 1.5.14
Solid Wall of C++
|
#include <array>#include <cctype>#include <chrono>#include <cmath>#include <ctime>#include <sys/param.h>#include <unistd.h>#include "swoc/BufferWriter.h"#include "swoc/bwf_base.h"#include "swoc/bwf_ex.h"#include "swoc/swoc_meta.h"#include "swoc/DiscreteRange.h"
Go to the source code of this file.
Namespaces | |
| namespace | swoc |
| For template deduction guides. | |
| namespace | std |
| STL namespace. | |
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. | |
| void | swoc::bwf::Adjust_Alignment (BufferWriter &aux, Spec const &spec) |
| template<size_t RADIX> | |
| size_t | swoc::bwf::To_Radix (uintmax_t n, char *buff, size_t width, char *digits) |
| template<typename F> | |
| void | swoc::bwf::Write_Aligned (BufferWriter &w, F const &f, Spec::Align align, int width, char fill, char neg) |
| 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) |
| 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, bwf::HexDump const &hex) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, MemSpan< void const > const &span) |
| 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::Pattern const &pattern) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, std::error_code const &ec) |
| BufferWriter & | swoc::bwformat (BufferWriter &w, bwf::Spec const &spec, bwf::UnHex const &obj) |
| ostream & | std::operator<< (ostream &s, swoc::FixedBufferWriter &w) |
| template<int RADIX> | |
| uintmax_t | svto_radix (TextView &src) |
Formatted output for BufferWriter.
Definition in file bw_format.cc.
| 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.
| 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.
| 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.
| 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.
| uintmax_t swoc::svto_radix | ( | TextView & | src | ) |
Convert the text in src to an unsigned numeric value.
| N | The radix (must be 1..36) |
| src | The source text. Updated during parsing. |
This is a specialized function useful only where conversion performance is critical. It is used inside svtoi and svtou for the common cases of 8, 10, and 16, therefore normally this isn't much more performant in those cases than just svtoi. Because of this only positive values are parsed. If determining the radix from the text or signed value parsing is needed, used svtoi.
src is updated in place to indicate what characters were parsed by removing them from the view Parsing stops on the first invalid digit, so any leading non-digit characters (e.g. whitespace) must already be removed. For overflow, all valid digits are consumed and the maximum value returned.
Definition at line 1059 of file TextView.h.
| size_t swoc::bwf::To_Radix | ( | uintmax_t | n, |
| char * | buff, | ||
| size_t | width, | ||
| char * | digits ) |
Templated radix based conversions. Only a small number of radix are supported and providing a template minimizes cut and paste code while also enabling compiler optimizations (e.g. for power of 2 radix the modulo / divide become bit operations).
Definition at line 327 of file bw_format.cc.
| void swoc::bwf::Write_Aligned | ( | BufferWriter & | w, |
| F const & | f, | ||
| Spec::Align | align, | ||
| int | width, | ||
| char | fill, | ||
| char | neg ) |
Output a string with a specified alignment.
| F | Output functor. |
| w | Output buffer. |
| f | Functor that generates output. |
| align | Alignment. |
| width | Field width. |
| fill | Fill character. |
| neg | Character to use for negative (null char means do not output). |
Definition at line 353 of file bw_format.cc.