Skip to main content

tap_name Class

A name prepared for a single TAP line, without a copy when it needs no change. More...

Declaration​

class micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name { ... }

Public Constructors Index​

tap_name (const char *text, bool escape)

Prepares a name. More...

tap_name (const tap_name &)=delete

Deleted copy constructor. More...

tap_name (tap_name &&)=delete

Deleted move constructor. More...

Public Destructor Index​

~tap_name ()=default

Destructor. More...

Public Operators Index​

tap_name &operator= (const tap_name &)=delete

Deleted copy assignment operator. More...

tap_name &operator= (tap_name &&)=delete

Deleted move assignment operator. More...

Public Member Functions Index​

const char *c_str (void) const noexcept

Retrieves the prepared name. More...

Private Member Attributes Index​

boolis_copy_ { false }

Whether the name was copied into prepared_. More...

std::stringprepared_ {}

The changed copy of the name. More...

const char *text_

The original name. More...

Description​

A name prepared for a single TAP line, without a copy when it needs no change.

The names of the suites and of the test cases rarely contain a character that tap_text() changes, so the name is searched, and only copied (with tap_text()) when it must be changed; otherwise c_str() returns the original name, which must outlive the object. The object is neither copyable nor movable.

Definition at line 151 of file reporter-tap.cpp.

Public Constructors​

tap_name()​

micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::tap_name (const char * text, bool escape)
inline

Prepares a name.

Parameters
text

The null-terminated name.

escape

Whether to escape the \\ and # characters, as tap_text() does.

The name is copied, through tap_text(), only when it contains a line break, or, when escaping, a \\ or a #; otherwise the original pointer is kept, and nothing is allocated.

Definition at line 166 of file reporter-tap.cpp.

166 tap_name (const char* text, bool escape) : text_{ text }
167 {
168 // The line breaks are always changed; the other two characters
169 // only when escaping.
170 if (std::string_view{ text }.find_first_of (escape ? "\r\n\\#"
171 : "\r\n")
172 != std::string_view::npos)
173 {
174 prepared_ = tap_text (text, escape);
175 is_copy_ = true;
176 }
177 }

References is_copy_, prepared_, micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_text and text_.

Referenced by tap_name, tap_name, operator= and operator=.

tap_name()​

micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::tap_name (const tap_name &)
delete

Deleted copy constructor.

The object is used only as a local variable of the function that writes the line.

Definition at line 186 of file reporter-tap.cpp.

Reference tap_name.

tap_name()​

micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::tap_name (tap_name &&)
delete

Deleted move constructor.

The object is used only as a local variable of the function that writes the line.

Definition at line 195 of file reporter-tap.cpp.

Reference tap_name.

Public Destructor​

~tap_name()​

micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::~tap_name ()
default

Destructor.

Releases the copy of the name, if one was made.

Definition at line 225 of file reporter-tap.cpp.

Public Operators​

operator=()​

tap_name & micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::operator= (const tap_name &)
delete

Deleted copy assignment operator.

The object is used only as a local variable of the function that writes the line.

Definition at line 205 of file reporter-tap.cpp.

Reference tap_name.

operator=()​

tap_name & micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::operator= (tap_name &&)
delete

Deleted move assignment operator.

The object is used only as a local variable of the function that writes the line.

Definition at line 216 of file reporter-tap.cpp.

Reference tap_name.

Public Member Functions​

c_str()​

const char * micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::c_str (void)
inline nodiscard noexcept

Retrieves the prepared name.

Parameters

None.

Returns

The null-terminated name, valid as long as this object and the original name.

Returns the copy, when the name had to be changed, or the original name otherwise.

Definition at line 240 of file reporter-tap.cpp.

240 c_str (void) const noexcept
241 {
242 return is_copy_ ? prepared_.c_str () : text_;
243 }

References is_copy_, prepared_ and text_.

Private Member Attributes​

is_copy_​

bool micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::is_copy_ { false }

Whether the name was copied into prepared_.

Set by the constructor, when the name contains a character that tap_text() changes.

Definition at line 269 of file reporter-tap.cpp.

269 bool is_copy_{ false };

Referenced by tap_name and c_str.

prepared_​

std::string micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::prepared_ {}

The changed copy of the name.

Empty, and not allocated, unless is_copy_ is true.

Definition at line 260 of file reporter-tap.cpp.

260 std::string prepared_{};

Referenced by tap_name and c_str.

text_​

const char* micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::text_

The original name.

Not owned; it must outlive the object.

Definition at line 252 of file reporter-tap.cpp.

252 const char* text_;

Referenced by tap_name and c_str.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.