HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
source_location.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
6#pragma once
7
8namespace tt {
9
11public:
12 constexpr source_location() noexcept = default;
13 constexpr source_location(uint_least32_t line, uint_least32_t column, char const *file_name, char const *function_name) noexcept :
14 _line(line), _column(column), _file_name(file_name), _function_name(function_name) {}
15
16 constexpr source_location(source_location const &) noexcept = default;
17 constexpr source_location(source_location &&) noexcept = default;
18 constexpr source_location &operator=(source_location const &) noexcept = default;
19 constexpr source_location &operator=(source_location &&) noexcept = default;
20
21 [[nodiscard]] constexpr uint_least32_t line() const noexcept
22 {
23 return _line;
24 }
25
26 [[nodiscard]] constexpr uint_least32_t column() const noexcept
27 {
28 return _column;
29 }
30
31 [[nodiscard]] constexpr char const *file_name() const noexcept
32 {
33 return _file_name;
34 }
35
36 [[nodiscard]] constexpr char const *function_name() const noexcept
37 {
38 return _function_name;
39 }
40
41private:
42 uint_least32_t _line = 0;
43 uint_least32_t _column = 0;
44 char const *_file_name = nullptr;
45 char const *_function_name = nullptr;
46};
47
48#define tt_source_location_current() tt::source_location(__LINE__, 0, __FILE__, __func__)
49
50inline std::string to_string(source_location const &rhs) noexcept
51{
52 return std::format("{}:{}", rhs.file_name(), rhs.line());
53}
54
55}
56
Definition source_location.hpp:10