cpp-msgpack-rpc
0.2.0
An RPC library implementing MessagePack RPC.
Toggle main menu visibility
Loading...
Searching...
No Matches
source_location_view.h
Go to the documentation of this file.
1
/*
2
* Copyright 2023 MusicScience37 (Kenta Kabashima)
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
20
#pragma once
21
22
#include <cstdint>
23
#include <string_view>
24
25
namespace
msgpack_rpc::logging
{
26
30
class
SourceLocationView
{
31
public
:
41
constexpr
SourceLocationView
(std::string_view
file_path
, std::uint32_t
line
,
42
std::string_view
function
) noexcept
43
:
file_path_
(
file_path
),
line_
(
line
),
function_
(
function
) {}
44
50
[[nodiscard]]
constexpr
std::string_view
file_path
() const noexcept {
51
return
file_path_
;
52
}
53
59
[[nodiscard]]
constexpr
std::uint32_t
line
() const noexcept {
60
return
line_
;
61
}
62
68
[[nodiscard]]
constexpr
std::string_view
function
() const noexcept {
69
return
function_
;
70
}
71
72
private
:
74
std::string_view
file_path_
;
75
77
std::uint32_t
line_
;
78
80
std::string_view
function_
;
81
};
82
83
}
// namespace msgpack_rpc::logging
84
86
#define MSGPACK_RPC_CURRENT_FILE_PATH __FILE__
87
89
#define MSGPACK_RPC_CURRENT_LINE __LINE__
90
91
#ifdef MSGPACK_RPC_DOCUMENTATION
97
#define MSGPACK_RPC_CURRENT_FUNCTION <implementation defined strings>
98
#elif __GNUC__
// GCC and Clang
99
#define MSGPACK_RPC_CURRENT_FUNCTION __func__
100
#elif _MSC_VER
// MSVC
101
#define MSGPACK_RPC_CURRENT_FUNCTION __FUNCSIG__
102
#else
// fallback (C++ standard)
103
#define MSGPACK_RPC_CURRENT_FUNCTION __func__
104
#endif
105
107
#define MSGPACK_RPC_CURRENT_SOURCE_LOCATION() \
108
::msgpack_rpc::logging::SourceLocationView( \
109
std::string_view(MSGPACK_RPC_CURRENT_FILE_PATH),
/*NOLINT*/
\
110
static_cast<std::uint32_t>(MSGPACK_RPC_CURRENT_LINE), \
111
std::string_view(MSGPACK_RPC_CURRENT_FUNCTION))
/*NOLINT*/
msgpack_rpc::logging::SourceLocationView::function_
std::string_view function_
Function name.
Definition
source_location_view.h:80
msgpack_rpc::logging::SourceLocationView::line
constexpr std::uint32_t line() const noexcept
Get the line number.
Definition
source_location_view.h:59
msgpack_rpc::logging::SourceLocationView::line_
std::uint32_t line_
Line number.
Definition
source_location_view.h:77
msgpack_rpc::logging::SourceLocationView::file_path
constexpr std::string_view file_path() const noexcept
Get the file path.
Definition
source_location_view.h:50
msgpack_rpc::logging::SourceLocationView::SourceLocationView
constexpr SourceLocationView(std::string_view file_path, std::uint32_t line, std::string_view function) noexcept
Constructor.
Definition
source_location_view.h:41
msgpack_rpc::logging::SourceLocationView::function
constexpr std::string_view function() const noexcept
Get the function name.
Definition
source_location_view.h:68
msgpack_rpc::logging::SourceLocationView::file_path_
std::string_view file_path_
File path.
Definition
source_location_view.h:74
msgpack_rpc::logging
Namespace of logging.
Definition
i_log_sink.h:27
include
msgpack_rpc
logging
source_location_view.h
Generated on
for cpp-msgpack-rpc by
1.18.0