anonymous{expression-formatter.cpp} Namespace
Local helpers of the expression formatter. More...
Definition
Functions Index
| void | append_hex (std::string &buffer, char32_t code, std::string_view escape, std::size_t count) |
|
Appends an escape and a fixed number of hexadecimal digits. More... | |
| void | append_plain (std::string &buffer, std::string_view sv) |
|
Appends a text in the plain mode, with the control characters escaped. More... | |
| void | append_quoted (std::string &buffer, std::string_view sv) |
|
Appends a string, as a quoted literal. More... | |
| void | append_utf8 (std::string &text, char32_t code) |
|
Appends a code point to a text, as UTF-8. More... | |
template <class Char_T> | |
| void | append_wide_text (std::string &buffer, std::basic_string_view< Char_T > sv) |
|
Appends the text of a string of a wide character type, converted to UTF-8, as the char text is appended. More... | |
template <class Char_T> | |
| auto | bounded_view (const Char_T *s, std::size_t capacity) noexcept -> std::basic_string_view< Char_T > |
|
Returns the text of a C string held in a buffer of a known capacity. More... | |
| constexpr bool | is_escaped_in_plain (char c) noexcept |
|
Tells whether a character is escaped in the plain mode. More... | |
template <class Char_T> | |
| std::string | utf16_to_utf8 (std::basic_string_view< Char_T > sv) |
|
Converts a UTF-16 text to UTF-8. More... | |
template <class Char_T> | |
| std::string | utf32_to_utf8 (std::basic_string_view< Char_T > sv) |
|
Converts a UTF-32 text to UTF-8. More... | |
Description
Local helpers of the expression formatter.
The unnamed namespace gives the helpers internal linkage, so that they are visible only in this translation unit, and cannot conflict with the names of the application or of the other source files of the framework. They are not declared in any header.
It contains append_hex(), which writes the hexadecimal escapes of the characters that cannot be printed as they are, and append_quoted(), which writes a string between double quotes.
Functions
append_hex()
|
Appends an escape and a fixed number of hexadecimal digits.
Used by expression_formatter::append_character(); the digits are lowercase, the most significant first, and the leading zeros are kept, so that the number of digits shows the size of the type.
- Parameters
-
buffer The text to which the escape is appended.
code The value to write.
escape The escape before the digits ("\\x", "\\u", or "\\U").
count The number of digits.
- Returns
Nothing.
Definition at line 99 of file expression-formatter.cpp.
Reference append_hex.
Referenced by append_hex and append_quoted.
append_plain()
|
Appends a text in the plain mode, with the control characters escaped.
- Parameters
-
buffer The buffer to append to.
sv The text.
The characters selected by is_escaped_in_plain() are written by append_control_escape(); all the others, including the tab, the line feed, and the bytes of the UTF-8 sequences, unchanged.
Definition at line 322 of file expression-formatter.cpp.
References micro_os_plus::micro_test_plus::detail::append_control_escape, append_plain and is_escaped_in_plain.
Referenced by append_plain.
append_quoted()
|
Appends a string, as a quoted literal.
Used by the string operands, so that the empty strings and the leading or trailing spaces are visible, and the control characters do not reach the console. The escapes are those of the character literals, with the double quote escaped instead of the single quote. The bytes above 0x7F are written unchanged, so that the UTF-8 text remains readable.
- Parameters
-
buffer The text to which the literal is appended.
sv The string to write; it may contain '\\0'.
- Returns
Nothing.
Definition at line 130 of file expression-formatter.cpp.
References append_hex and append_quoted.
Referenced by append_quoted.
append_utf8()
|
Appends a code point to a text, as UTF-8.
A value that is not a Unicode scalar value (a surrogate, or a value above U+10FFFF) is written as the replacement character U+FFFD.
- Parameters
-
text The text to append to.
code The code point.
Definition at line 194 of file expression-formatter.cpp.
Reference append_utf8.
Referenced by append_utf8, utf16_to_utf8 and utf32_to_utf8.
append_wide_text()
|
Appends the text of a string of a wide character type, converted to UTF-8, as the char text is appended.
The text is written by a formatter in the plain mode, so without quotes, with the control characters other than the tab and the line feed, and DEL, escaped, whatever the mode of the caller.
- Template Parameters
-
Char_T The character type.
- Parameters
-
[inout] buffer The buffer to append to.
sv The text.
- Returns
Nothing.
Definition at line 385 of file expression-formatter.cpp.
References micro_os_plus::micro_test_plus::detail::plain_text::append and append_wide_text.
Referenced by append_wide_text.
bounded_view()
| noexcept |
Returns the text of a C string held in a buffer of a known capacity.
With npos, the length is computed by the constructor of the view, which reads up to the terminator; otherwise only the capacity characters are searched for the terminator, so that an array without one is not read beyond its end.
- Template Parameters
-
Char_T The character type.
- Parameters
-
s The text; it must not be null.
capacity The number of characters that may be read, or npos if the text is null-terminated.
- Returns
A view of the characters before the first null character, or of the capacity characters if there is none.
Definition at line 356 of file expression-formatter.cpp.
Reference bounded_view.
Referenced by bounded_view.
is_escaped_in_plain()
| constexpr noexcept |
Tells whether a character is escaped in the plain mode.
The control characters other than the tab and the line feed, and the DEL character, which can change the state of a terminal, and truncate a text.
- Parameters
-
c The character.
- Return Values
-
true The character is escaped.
false The character is written unchanged.
Definition at line 303 of file expression-formatter.cpp.
Reference is_escaped_in_plain.
Referenced by append_plain and is_escaped_in_plain.
utf16_to_utf8()
|
Converts a UTF-16 text to UTF-8.
The surrogate pairs are combined; an unpaired surrogate is written as the replacement character.
- Template Parameters
-
Char_T A character type of at least 16 bits, holding UTF-16 code units.
- Parameters
-
sv The text to convert.
- Returns
The UTF-8 text.
Definition at line 240 of file expression-formatter.cpp.
References append_utf8 and utf16_to_utf8.
Referenced by utf16_to_utf8.
utf32_to_utf8()
|
Converts a UTF-32 text to UTF-8.
- Template Parameters
-
Char_T A character type of at least 32 bits, holding UTF-32 code units.
- Parameters
-
sv The text to convert.
- Returns
The UTF-8 text.
Unlike UTF-16, UTF-32 needs no decoding: each code unit is encoded by append_utf8(), which writes the values that are not Unicode scalar values as U+FFFD.
Definition at line 279 of file expression-formatter.cpp.
References append_utf8 and utf32_to_utf8.
Referenced by utf32_to_utf8.
The documentation for this namespace was generated from the following file:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.