PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
source_location.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_EXCEPTIONS_SOURCE_LOCATION_HPP_
13 #define PLSSVM_EXCEPTIONS_SOURCE_LOCATION_HPP_
14 #pragma once
15 
16 #include <cstdint> // std::uint_least32_t
17 #include <string_view> // std::string_view
18 
19 namespace plssvm {
20 
26  public:
35  [[nodiscard]] static constexpr source_location current(
36  const char *file_name = __builtin_FILE(),
37  const char *function_name = __builtin_FUNCTION(),
38  int line = __builtin_LINE(),
39  int column = 0) noexcept {
40  source_location loc;
41 
42  loc.file_name_ = file_name;
44  loc.line_ = line;
45  loc.column_ = column;
46 
47  return loc;
48  }
49 
54  [[nodiscard]] constexpr std::string_view function_name() const noexcept { return function_name_; }
60  [[nodiscard]] constexpr std::string_view file_name() const noexcept { return file_name_; }
65  [[nodiscard]] constexpr std::uint_least32_t line() const noexcept { return line_; }
71  [[nodiscard]] constexpr std::uint_least32_t column() const noexcept { return column_; }
72 
73  private:
75  std::uint_least32_t line_{ 0 };
77  std::uint_least32_t column_{ 0 };
79  const char *file_name_{ "unknown" };
81  const char *function_name_{ "unknown" };
82 };
83 
84 } // namespace plssvm
85 
86 #endif // PLSSVM_EXCEPTIONS_SOURCE_LOCATION_HPP_
The plssvm::source_location class represents certain information about the source code,...
Definition: source_location.hpp:25
const char * file_name_
The file name as retrieved by __builtin_FILE().
Definition: source_location.hpp:79
std::uint_least32_t column_
The column number (always 0).
Definition: source_location.hpp:77
constexpr std::uint_least32_t column() const noexcept
Returns the column number.
Definition: source_location.hpp:71
constexpr std::string_view file_name() const noexcept
Returns the function name without additional signature information (i.e. return type and parameters) ...
Definition: source_location.hpp:60
std::uint_least32_t line_
The line number as retrieved by __builtin_LINE().
Definition: source_location.hpp:75
const char * function_name_
The function name as retrieved by __builtin_FUNCTION().
Definition: source_location.hpp:81
constexpr std::uint_least32_t line() const noexcept
Returns the line number or 0 if no information could be retrieved.
Definition: source_location.hpp:65
constexpr std::string_view function_name() const noexcept
Returns the absolute path name of the file or "unknown" if no information could be retrieved.
Definition: source_location.hpp:54
static constexpr source_location current(const char *file_name=__builtin_FILE(), const char *function_name=__builtin_FUNCTION(), int line=__builtin_LINE(), int column=0) noexcept
Construct new source location information about the current call side.
Definition: source_location.hpp:35
The main namespace containing all public API functions.
Definition: backend_types.hpp:24