numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
source_info_view.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 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 <string_view>
23
26
27namespace num_collect::util {
28
36public:
54
60 [[nodiscard]] constexpr auto file_path() const -> std::string_view {
61 return file_path_;
62 }
63
69 [[nodiscard]] constexpr auto line() const -> index_type { return line_; }
70
76 [[nodiscard]] constexpr auto column() const -> index_type {
77 return column_;
78 }
79
85 [[nodiscard]] constexpr auto function_name() const -> std::string_view {
86 return function_name_;
87 }
88
89private:
91 std::string_view file_path_;
92
95
98
100 std::string_view function_name_;
101};
102
103} // namespace num_collect::util
Class to hold information of source codes.
constexpr auto column() const -> index_type
Get the column number.
constexpr auto line() const -> index_type
Get the line number.
std::string_view function_name_
Function name.
constexpr auto function_name() const -> std::string_view
Get the function name.
constexpr source_info_view(std::string_view file_path=NUM_COLLECT_BUILTIN_FILE(), index_type line=NUM_COLLECT_BUILTIN_LINE(), index_type column=NUM_COLLECT_BUILTIN_COLUMN(), std::string_view function_name=NUM_COLLECT_BUILTIN_FUNCTION())
Constructor.
constexpr auto file_path() const -> std::string_view
Get the file path.
std::string_view file_path_
File path.
Definition of macros for built-in functions of compilers.
#define NUM_COLLECT_BUILTIN_COLUMN()
Get column number.
#define NUM_COLLECT_BUILTIN_FUNCTION()
Get function name.
#define NUM_COLLECT_BUILTIN_LINE()
Get line number.
#define NUM_COLLECT_BUILTIN_FILE()
Get file path.
Definition of index_type type.
std::ptrdiff_t index_type
Type of indices in this library.
Definition index_type.h:33
Namespace of utilities.
Definition assert.h:30
STL namespace.