Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
src_line_info.hpp
Go to the documentation of this file.
1// Copyright 2024, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_SOURCE_LOCATION_SRC_LINE_INFO_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_SOURCE_LOCATION_SRC_LINE_INFO_HPP_
7
8#include "arene/base/stdlib_choice/cstdint.hpp"
10// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
11// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
12
13// IWYU pragma: private, include "arene/base/source_location.hpp"
14// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
15
16namespace arene {
17namespace base {
18
19/// @brief Container for the location information associated with a line of source code
21 // parasoft-begin-suppress AUTOSAR-M11_0_1-a "False positive: 'src_line_info' is POD"
22 /// @brief function name of the parent function
24 /// @brief filepath of the source file
26 /// @brief line number
28 // parasoft-end-suppress AUTOSAR-M11_0_1-a
29};
30
31} // namespace base
32} // namespace arene
33
34// AUTOSAR Rule A16-0-1 Exception: File, function and line informations in C
35// and C++ are accessible only using the preprocessor. This macro is required
36// to extract these informations for the logger purpose
37
38// parasoft-begin-suppress AUTOSAR-A16_0_1-d "Defines function-like macros permitted by A16-0-1 Permit #1"
39// parasoft-begin-suppress AUTOSAR-A3_9_1-b "False positive: This represents a character not a number"
40
41/// @def ARENE_GET_SRC_CODE_LOCATION_INFO()
42/// Construct @c src_line_info with the current source code information that includes the source code file filepath, the
43/// current line, and the function name.
44// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
45#define ARENE_GET_SRC_CODE_LOCATION_INFO() \
46 (::arene::base::src_line_info{ \
47 static_cast<::arene::base::null_terminated_string_view>(static_cast<const char*>(__func__)), \
48 static_cast<::arene::base::null_terminated_string_view>(static_cast<const char*>(__FILE__)), \
49 static_cast<std::uint32_t>(__LINE__) \
50 })
51
52// parasoft-end-suppress AUTOSAR-A3_9_1-b
53// parasoft-end-suppress AUTOSAR-A16_0_1-d
54
55#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_SOURCE_LOCATION_SRC_LINE_INFO_HPP_
A read-only string-view that provides a view onto a null-terminated string.
Definition null_terminated_string_view.hpp:62
Definition accumulate.hpp:37
Definition accumulate.hpp:36
::uint32_t uint32_t
A 32-bit unsigned integer type.
Definition cstdint.hpp:41
Container for the location information associated with a line of source code.
Definition src_line_info.hpp:20
std::uint32_t line
line number
Definition src_line_info.hpp:27
null_terminated_string_view filepath
filepath of the source file
Definition src_line_info.hpp:25
null_terminated_string_view function_name
function name of the parent function
Definition src_line_info.hpp:23