iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
source_location.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
2// Copyright (c) 2025 Contributors to the Eclipse Foundation
3//
4// See the NOTICE file(s) distributed with this work for additional
5// information regarding copyright ownership.
6//
7// This program and the accompanying materials are made available under the
8// terms of the Apache Software License 2.0 which is available at
9// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
10// which is available at https://opensource.org/licenses/MIT.
11//
12// SPDX-License-Identifier: Apache-2.0 OR MIT
13
14#ifndef IOX2_BB_DETAIL_SOURCE_LOCATION_HPP
15#define IOX2_BB_DETAIL_SOURCE_LOCATION_HPP
16
17#include <cstdint>
18
19namespace iox2 {
20namespace bb {
21namespace detail {
23 private:
24 const char* m_file { nullptr };
25 const char* m_function { nullptr };
26 uint32_t m_line { 0 };
27
28 public:
29 static constexpr auto current(const char* file = __builtin_FILE(),
30 const uint32_t line = __builtin_LINE(),
31 const char* function = __builtin_FUNCTION()) noexcept -> SourceLocation {
32 return SourceLocation { file, line, function };
33 }
34
35 constexpr auto file_name() const noexcept -> const char* {
36 return m_file;
37 }
38 constexpr auto line() const noexcept -> uint32_t {
39 return m_line;
40 }
41 constexpr auto function_name() const noexcept -> const char* {
42 return m_function;
43 }
44
45 private:
46 constexpr SourceLocation(const char* file, uint32_t line, const char* function) noexcept
47 : m_file(file)
48 , m_function(function)
49 , m_line(line) {
50 }
51};
52
53} // namespace detail
54} // namespace bb
55} // namespace iox2
56
57#endif // IOX2_BB_DETAIL_SOURCE_LOCATION_HPP
static constexpr auto current(const char *file=__builtin_FILE(), const uint32_t line=__builtin_LINE(), const char *function=__builtin_FUNCTION()) noexcept -> SourceLocation
constexpr auto file_name() const noexcept -> const char *
constexpr auto function_name() const noexcept -> const char *
constexpr auto line() const noexcept -> uint32_t