Sen API
Sen Libraries
Toggle main menu visibility
Loading...
Searching...
No Matches
source_location.h
Go to the documentation of this file.
1
// === source_location.h ===============================================================================================
2
// Sen Infrastructure
3
// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4
// See the LICENSE.txt file for more information.
5
// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6
// =====================================================================================================================
7
8
#ifndef SEN_CORE_BASE_SOURCE_LOCATION_H
9
#define SEN_CORE_BASE_SOURCE_LOCATION_H
10
11
// std
12
#include <cstddef>
13
#include <string_view>
14
15
namespace
sen::impl
16
{
17
20
constexpr
size_t
getFilenameOffset(
const
std::string_view str)
noexcept
21
{
22
const
size_t
pos = str.find_last_of(
"/\\"
);
23
return
pos == std::string_view::npos ? 0 : pos + 1;
24
}
25
27
template
<
typename
T, T v>
28
struct
ConstexprValue
29
{
30
static
constexpr
const
T value = v;
31
};
32
35
#define SEN_SL_CONSTEXPR_VAL(exp) ::sen::impl::ConstexprValue<decltype(exp), exp>::value
36
37
}
// namespace sen::impl
38
39
namespace
sen
40
{
41
44
46
struct
SourceLocation
47
{
48
std::string_view
fileName
{
"file name not set"
};
49
int
lineNumber
{-1};
50
std::string_view
functionName
{
"function name not set"
};
51
};
52
53
#ifdef WIN32
54
# define SEN_PRETTY_FUNCTION_NAME __FUNCSIG__
55
#else
56
# define SEN_PRETTY_FUNCTION_NAME __PRETTY_FUNCTION__
57
#endif
58
61
#define SEN_SL() \
62
::sen::SourceLocation \
63
{ \
64
std::string_view {&__FILE__[SEN_SL_CONSTEXPR_VAL(::sen::impl::getFilenameOffset(__FILE__))]}, __LINE__, \
65
std::string_view(SEN_PRETTY_FUNCTION_NAME) \
66
}
67
69
70
}
// namespace sen
71
72
#endif
// SEN_CORE_BASE_SOURCE_LOCATION_H
sen::SourceLocation::fileName
std::string_view fileName
Definition
source_location.h:48
sen::SourceLocation::functionName
std::string_view functionName
Definition
source_location.h:50
sen::SourceLocation::lineNumber
int lineNumber
Definition
source_location.h:49
sen::SourceLocation
Represents a location in source code.
Definition
source_location.h:47
sen
Definition
assert.h:17
libs
core
include
sen
core
base
source_location.h
Generated by
1.17.0