expression-formatter.cpp File
C++ source file with non-template implementations for the µTest++ expression formatter. More...
Included Headers
Namespaces Index
| namespace | micro_os_plus |
|
The primary namespace for the µOS++ framework. More... | |
| namespace | micro_test_plus |
|
Primary namespace for the µTest++ testing framework. More... | |
| namespace | detail |
|
Internal implementation details for the µTest++ framework. More... | |
| namespace | anonymous{expression-formatter.cpp} |
|
Local helpers of the expression formatter. More... | |
Functions Index
| void | append_control_escape (std::string &text, char c) |
|
Appends the escape sequence of a control character. More... | |
| 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
C++ source file with non-template implementations for the µTest++ expression formatter.
This source file contains the non-template operator<< overloads of expression_formatter for all standard arithmetic, character, string, boolean, and null-pointer types, std::nullopt, and the named_bool operand. Each overload appends the formatted value — together with an appropriate type suffix where applicable — to the internal string buffer. It also contains the private helpers that write the decimal point, the suffixes, and the characters, and the functions that assign the buffer to the checks.
All definitions reside within the micro_os_plus::micro_test_plus::detail namespace.
This file must be included when building the µTest++ library.
Functions
append_control_escape()
|
Appends the escape sequence of a control character.
Writes the usual escape of the character (\\0, \\a, \\b, \\t, \\n, \\v, \\f, or \\r), or \\xHH for the other ones. Used for the characters of the messages and of the names that would otherwise reach the console and the output files unchanged. Defined in src/expression-formatter.cpp.
- Parameters
-
text The text to append to.
c The control character.
The usual escapes for the characters that have one; the other ones, including DEL, as \\xHH.
Definition at line 401 of file expression-formatter.cpp.
Reference micro_os_plus::micro_test_plus::detail::append_control_escape.
Referenced by micro_os_plus::micro_test_plus::detail::append_control_escape, micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_plain, micro_os_plus::micro_test_plus::detail::escape_control_characters and micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<.
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 micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_hex.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_hex and micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::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, micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_plain and micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::is_escaped_in_plain.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::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 micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_hex and micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_quoted.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::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 micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_utf8.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_utf8, micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::utf16_to_utf8 and micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::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 micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_wide_text.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::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 micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::bounded_view.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::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 micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::is_escaped_in_plain.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_plain and micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::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 micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_utf8 and micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::utf16_to_utf8.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::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 micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::append_utf8 and micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::utf32_to_utf8.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{expression-formatter.cpp}::utf32_to_utf8.
File Listing
The file content with the documentation metadata removed is:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.