tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
source_location.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_SOURCE_LOCATION_SOURCE_LOCATION_HPP
5#define TETL_SOURCE_LOCATION_SOURCE_LOCATION_HPP
6
7#include <etl/_config/all.hpp>
8
9#include <etl/_cstdint/uint_least_t.hpp>
10#include <etl/_version/language_standard.hpp>
11
12namespace etl {
13
14/// A class representing information about the source code, such as file names,
15/// line numbers, and function names
16///
17/// \ingroup source_location
18///
19/// \include source_location.cpp
21 [[nodiscard]] static consteval auto current(
22 uint_least32_t const line = TETL_BUILTIN_LINE(),
23 uint_least32_t const column = TETL_BUILTIN_COLUMN(),
24 char const* const file = TETL_BUILTIN_FILE(),
25 char const* const function = TETL_BUILTIN_FUNCTION()
26 ) noexcept -> source_location
27 {
28 auto result = source_location{};
29 result._line = line;
30 result._column = column;
31 result._file = file;
32 result._function = function;
33 return result;
34 }
35
36 constexpr source_location() noexcept = default;
37
38 [[nodiscard]] constexpr auto line() const noexcept -> etl::uint_least32_t
39 {
40 return _line;
41 }
42
43 [[nodiscard]] constexpr auto column() const noexcept -> etl::uint_least32_t
44 {
45 return _column;
46 }
47
48 [[nodiscard]] constexpr auto file_name() const noexcept -> char const*
49 {
50 return _file;
51 }
52
53 [[nodiscard]] constexpr auto function_name() const noexcept -> char const*
54 {
55 return _function;
56 }
57
58private:
59 etl::uint_least32_t _line{};
60 etl::uint_least32_t _column{};
61 char const* _file = "";
62 char const* _function = "";
63};
64
65} // namespace etl
66
67#endif // TETL_SOURCE_LOCATION_SOURCE_LOCATION_HPP
Definition adjacent_find.hpp:9
A class representing information about the source code, such as file names, line numbers,...
Definition source_location.hpp:20
static consteval auto current(uint_least32_t const line=TETL_BUILTIN_LINE(), uint_least32_t const column=TETL_BUILTIN_COLUMN(), char const *const file=TETL_BUILTIN_FILE(), char const *const function=TETL_BUILTIN_FUNCTION()) noexcept -> source_location
Definition source_location.hpp:21
constexpr auto column() const noexcept -> etl::uint_least32_t
Definition source_location.hpp:43
constexpr auto function_name() const noexcept -> char const *
Definition source_location.hpp:53
constexpr auto file_name() const noexcept -> char const *
Definition source_location.hpp:48
constexpr source_location() noexcept=default
constexpr auto line() const noexcept -> etl::uint_least32_t
Definition source_location.hpp:38