HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
source_location.hpp
1// Copyright Take Vos 2020-2021.
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#pragma once
6
7namespace hi::inline v1 {
8
10public:
11 constexpr source_location() noexcept = default;
12 constexpr source_location(
13 uint_least32_t line,
14 uint_least32_t column,
15 char const *file_name,
16 char const *function_name) noexcept :
17 _line(line), _column(column), _file_name(file_name), _function_name(function_name)
18 {
19 }
20
21 constexpr source_location(source_location const &) noexcept = default;
22 constexpr source_location(source_location &&) noexcept = default;
23 constexpr source_location &operator=(source_location const &) noexcept = default;
24 constexpr source_location &operator=(source_location &&) noexcept = default;
25
26 [[nodiscard]] constexpr uint_least32_t line() const noexcept
27 {
28 return _line;
29 }
30
31 [[nodiscard]] constexpr uint_least32_t column() const noexcept
32 {
33 return _column;
34 }
35
36 [[nodiscard]] constexpr char const *file_name() const noexcept
37 {
38 return _file_name;
39 }
40
41 [[nodiscard]] constexpr char const *function_name() const noexcept
42 {
43 return _function_name;
44 }
45
46private:
47 uint_least32_t _line = 0;
48 uint_least32_t _column = 0;
49 char const *_file_name = nullptr;
50 char const *_function_name = nullptr;
51};
52
53#define hi_source_location_current() hi::source_location(__LINE__, 0, __FILE__, __func__)
54
55inline std::string to_string(source_location const &rhs) noexcept
56{
57 return std::format("{}:{}", rhs.file_name(), rhs.line());
58}
59
60} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:15
Definition source_location.hpp:9