|
fiber
|
Formats a string and allows to pass an additional size parameter. More...
#include <OStream.hpp>
Public Member Functions | |
| constexpr | FormatStr ()=default |
| Default format constructor. | |
| constexpr | FormatStr (const char *str, size_t len) |
| Construcs a string formater. | |
| constexpr | FormatStr (const char *str) |
| Constructs a string from a terminated c-style string. I urge you to use FormatStr(const char* str, size_t len) instead. | |
| constexpr | FormatStr (const char *first, const char *last) |
| Constructs a string from a range given by the closed-open iterators [first, last) | |
| template<CStringView StringView> | |
| constexpr | FormatStr (const StringView &str) |
| constexpr FormatStr & | operator() (const char *str) |
| Assigns a string to the object. Allows to re-use formats. | |
| constexpr FormatStr & | operator() (const char *str, size_t len) |
| Assigns a string to the object. Allows to re-use formats. | |
| constexpr FormatStr & | operator() (const char *first, const char *last) |
| Assigns a string to the object. Allows to re-use formats. | |
| template<CStringView StringView> | |
| constexpr FormatStr & | operator() (const StringView &str) |
| Assigns a string to the object. Allows to re-use formats. | |
| constexpr FormatStr & | mwidth (int mw) |
| Sets the minimum number of character that will be put into the stream. | |
| constexpr FormatStr & | left () |
| Formats the string to the left area set by mwidth(). | |
| constexpr FormatStr & | right () |
| Formats the string to the left area set by mwidth(). | |
| constexpr FormatStr & | center () |
| Formats the string to the left area set by mwidth(). | |
| constexpr FormatStr & | fill (char c) |
| Sets the fill characters used by padding that is applied when mwidth() is used. | |
Static Public Member Functions | |
| static constexpr FormatStr | like (const char *str, size_t len, const FormatStrParams ¶ms) |
| static constexpr FormatStr | like (const char *str, const FormatStrParams ¶ms) |
| static constexpr FormatStr | like (const char *first, const char *last, const FormatStrParams ¶ms) |
| template<CStringView StringView> | |
| static constexpr FormatStr | like (const StringView &str, const FormatStrParams ¶ms) |
Public Attributes | |
| const char * | _str = "" |
| size_t | _len = 0 |
Public Attributes inherited from fiber::FormatStrParams | |
| AlignmentLRC | _alignment = AlignmentLRC::Right |
| int | _mwidth = 0 |
| char | _fill = ' ' |
Formats a string and allows to pass an additional size parameter.
|
constexprdefault |
Default format constructor.
|
inlineconstexpr |
Construcs a string formater.
| str | Pointer to the start of the string |
| len | The length of the string, aka. the number of character that should be printed |
|
inlineconstexpr |
Constructs a string from a terminated c-style string. I urge you to use FormatStr(const char* str, size_t len) instead.
|
inlineconstexpr |
Constructs a string from a range given by the closed-open iterators [first, last)
| first | The start of the string that should be printed. Points to the first character. |
| last | The end of the string that should be printed. Points past the last character. |
|
inlineconstexpr |
|
inlineconstexpr |
Formats the string to the left area set by mwidth().
Example:
|
inlineconstexpr |
Sets the fill characters used by padding that is applied when mwidth() is used.
| c | The new fill character |
|
inlineconstexpr |
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
|
inlineconstexpr |
Sets the minimum number of character that will be put into the stream.
Padded characters are defined by FormatStr::fill(char c). The default fill character is a space ' '.
Example:
| mw | An integer that sets the new minimal width |
|
inlineconstexpr |
Assigns a string to the object. Allows to re-use formats.
Like: FormatStr& operator()(const char* str)
| first | The start of the string that should be printed. Points to the first character. |
| last | The end of the string that should be printed. Points past the last character. |
|
inlineconstexpr |
Assigns a string to the object. Allows to re-use formats.
This function allows to create custom formaters and reuse them when printing - reusing code bloat and clutter.
Example:
Output:
| str | A terminated c-style string |
|
inlineconstexpr |
Assigns a string to the object. Allows to re-use formats.
Like: FormatStr& operator()(const char* str)
| str | A terminated c-style string |
| len | the length of the string |
|
inlineconstexpr |
Assigns a string to the object. Allows to re-use formats.
Like: FormatStr& operator()(const char* str)
| str | a string view like object. Has to offer the following two methods:
|
|
inlineconstexpr |
| size_t fiber::FormatStr::_len = 0 |
| const char* fiber::FormatStr::_str = "" |