Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
SourceLocation.hpp
1#pragma once
2
3#if defined(HAS_SOURCE_LOCATION) && __has_builtin(__builtin_source_location)
4// this is used by fully compatible compilers like gcc
5#include <source_location>
6
7#elif defined(HAS_EXPERIMENTAL_SOURCE_LOCATION)
8// this is used by clang on linux where source_location is still not out of
9// experimental headers
10#include <experimental/source_location>
11
12#else
13
14#include <cstddef>
15#include <string_view>
16#endif
17
18namespace util {
19
20#if defined(HAS_SOURCE_LOCATION) && __has_builtin(__builtin_source_location)
21using SourceLocationType = std::source_location;
22
23#elif defined(HAS_EXPERIMENTAL_SOURCE_LOCATION)
24using SourceLocationType = std::experimental::source_location;
25
26#else
34 char const* file_;
35 std::size_t line_;
36
37public:
44 constexpr SourceLocation(char const* file, std::size_t line) : file_{file}, line_{line}
45 {
46 }
47
53 constexpr std::string_view
54 file_name() const
55 {
56 return file_;
57 }
58
64 constexpr std::size_t
65 line() const
66 {
67 return line_;
68 }
69};
70using SourceLocationType = SourceLocation;
71#define SOURCE_LOCATION_OLD_API
72
73#endif
74
75} // namespace util
76
77#if defined(SOURCE_LOCATION_OLD_API)
78#define CURRENT_SRC_LOCATION util::SourceLocationType(__FILE__, __LINE__)
79#else
80#define CURRENT_SRC_LOCATION util::SourceLocationType::current()
81#endif
constexpr std::string_view file_name() const
Get the file name.
Definition SourceLocation.hpp:54
constexpr SourceLocation(char const *file, std::size_t line)
Construct a new Source Location object.
Definition SourceLocation.hpp:44
constexpr std::size_t line() const
Get the line number.
Definition SourceLocation.hpp:65
This namespace contains various utilities.
Definition AccountUtils.hpp:11