Skip to main content

source_location Class

Local implementation of source location information for diagnostics. More...

Declaration​

class micro_os_plus::micro_test_plus::reflection::source_location { ... }

Included Headers​

Public Member Functions Index​

constexpr autofile_name (void) const noexcept

Returns the file name associated with this source location. More...

constexpr autoline (void) const noexcept

Returns the line number associated with this source location. More...

Private Member Attributes Index​

const char *file_ { "unknown" }

The file name where the source location was captured. More...

unsigned intline_ {}

The line number where the source location was captured. More...

Public Static Functions Index​

static constexpr source_locationcurrent (const char *file="unknown", unsigned int line={}) noexcept

Returns the current source location. More...

Description​

Local implementation of source location information for diagnostics.

This class provides a lightweight, constexpr-compatible alternative to std::source_location, used when the standard library does not provide it (__cpp_lib_source_location is not defined).

It enables retrieval of the file name and line number at the point of invocation, for the reports of the checks.

The static member function current() captures the current source location, using compiler built-ins where available, or defaulting to "unknown" and zero otherwise.

Since

3.0.0

Definition at line 142 of file reflection.h.

Public Member Functions​

file_name()​

auto micro_os_plus::micro_test_plus::reflection::source_location::file_name (void)
nodiscard constexpr noexcept

Returns the file name associated with this source location.

Parameters

None.

Returns

The file name as a constant character pointer.

Returns the file name captured at the time this source_location instance was created.

Declaration at line 170 of file reflection.h, definition at line 101 of file reflection-inlines.h.

101 source_location::file_name (void) const noexcept
102 {
103 return file_;
104 }

Reference file_.

Referenced by micro_os_plus::micro_test_plus::runner::abort, micro_os_plus::micro_test_plus::detail::reporter_human::abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_prefix and micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix.

line()​

auto micro_os_plus::micro_test_plus::reflection::source_location::line (void)
nodiscard constexpr noexcept

Returns the line number associated with this source location.

Parameters

None.

Returns

The line number as an unsigned integer.

Returns the line number captured at the time this source_location instance was created.

Declaration at line 180 of file reflection.h, definition at line 112 of file reflection-inlines.h.

112 source_location::line (void) const noexcept
113 {
114 return line_;
115 }

Reference line_.

Referenced by micro_os_plus::micro_test_plus::runner::abort, micro_os_plus::micro_test_plus::detail::reporter_human::abort_session, micro_os_plus::micro_test_plus::detail::reporter_tap::abort_session, current, micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_prefix and micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix.

Private Member Attributes​

file_​

const char* micro_os_plus::micro_test_plus::reflection::source_location::file_ { "unknown" }

The file name where the source location was captured.

Defaults to "unknown" when no location was provided.

Definition at line 189 of file reflection.h.

189 const char* file_{ "unknown" };

Referenced by current and file_name.

line_​

unsigned int micro_os_plus::micro_test_plus::reflection::source_location::line_ {}

The line number where the source location was captured.

Defaults to zero when no location was provided.

Definition at line 197 of file reflection.h.

197 unsigned int line_{};

Referenced by current and line.

Public Static Functions​

current()​

source_location micro_os_plus::micro_test_plus::reflection::source_location::current (const char * file="unknown", unsigned int line={})
nodiscard constexpr noexcept static

Returns the current source location.

Parameters
file

The file name (automatically provided by the compiler).

line

The line number (automatically provided by the compiler).

Returns

A source_location instance with the captured information.

Returns a source_location instance representing the file name and line number at the point of invocation.

If supported by the compiler, uses built-in macros to capture this information; otherwise, defaults to "unknown" and zero.

Declaration at line 153 of file reflection.h, definition at line 87 of file reflection-inlines.h.

87 source_location::current (const char* file, unsigned int line) noexcept
88 {
90 sl.file_ = file;
91 sl.line_ = line;
92 return sl;
93 }

References file_, line and line_.

Referenced by micro_os_plus::micro_test_plus::test_case::expect, micro_os_plus::micro_test_plus::test_case::operator=, micro_os_plus::micro_test_plus::test_case::require and micro_os_plus::micro_test_plus::detail::runnable_base::run.


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


Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.