basic_c_string Struct Template
A C string operand of a comparator. More...
Declaration
struct micro_os_plus::micro_test_plus::detail::basic_c_string<Char_T> { ... }
Included Headers
Public Constructors Index
template <character Char_T> | |
| constexpr | basic_c_string (const Char_T *str) noexcept |
|
Constructs the operand from a pointer to a null-terminated string. More... | |
template <character Char_T> | |
| constexpr | basic_c_string (const Char_T *str, std::size_t capacity) noexcept |
|
Constructs the operand from an array of characters. More... | |
Public Member Functions Index
template <character Char_T> | |
| constexpr bool | is_null (void) const noexcept |
|
Returns whether the operand is a null pointer. More... | |
template <character Char_T> | |
| constexpr auto | view (void) const noexcept -> std::basic_string_view< Char_T > |
|
Returns the characters, as a string view. More... | |
Private Member Attributes Index
template <character Char_T> | |
| std::size_t | size_ |
|
The number of characters, without the terminator. More... | |
template <character Char_T> | |
| const Char_T * | str_ |
|
The first character, or nullptr. More... | |
Description
A C string operand of a comparator.
The comparators convert the arrays (including the string literals) and the pointers of the character types to this type (see as_operand()), so that they are compared by content, as a reader of a test expects, and not by address. A null pointer is equal only to another null pointer (not to an empty string), and is less than any string.
The characters are not copied; the operand must outlive the comparison, which is always the case within a check.
- Template Parameters
-
Char_T The character type; it satisfies character.
Definition at line 1673 of file detail.h.
Public Constructors
basic_c_string()
| explicit constexpr noexcept |
Constructs the operand from a pointer to a null-terminated string.
- Parameters
-
str The string, or nullptr.
The length is computed with std::char_traits<Char_T>::length(), which, unlike strlen(), can be evaluated at compile time.
Declaration at line 1681 of file detail.h, definition at line 1498 of file detail-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::str_.
basic_c_string()
| constexpr noexcept |
Constructs the operand from an array of characters.
The string ends at the first null character, or at the end of the array, so that an array without a terminator is not read beyond its end.
- Parameters
-
str The first character of the array.
capacity The number of elements of the array.
The characters are counted up to the first null character, or up to capacity.
Declaration at line 1694 of file detail.h, definition at line 1511 of file detail-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::str_.
Public Member Functions
is_null()
| nodiscard constexpr noexcept |
Returns whether the operand is a null pointer.
- Parameters
None.
- Return Values
-
true The operand is a null pointer.
false The operand is a string, possibly empty.
Returns whether the stored pointer is null.
Declaration at line 1717 of file detail.h, definition at line 1543 of file detail-inlines.h.
Reference micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::str_.
Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<.
view()
| nodiscard constexpr noexcept |
Returns the characters, as a string view.
- Parameters
None.
- Returns
The characters, without the terminator; empty for a null pointer.
Returns an empty view for a null pointer.
Declaration at line 1706 of file detail.h, definition at line 1531 of file detail-inlines.h.
References micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::size_ and micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::str_.
Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<.
Private Member Attributes
size_
|
The number of characters, without the terminator.
Computed by the constructors; zero for a null pointer.
Definition at line 1734 of file detail.h.
Referenced by micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::view.
str_
|
The first character, or nullptr.
Not owned; points into the operand passed to the comparator.
Definition at line 1726 of file detail.h.
Referenced by micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::basic_c_string, micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::basic_c_string, micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::is_null and micro_os_plus::micro_test_plus::detail::basic_c_string< Char_T >::view.
The documentation for this struct was generated from the following files:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.