Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
SourceLocation.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
18#include <fmt/core.h>
19#include <fmt/format.h>
20#include <fmt/printf.h>
21#include <fmt/ranges.h>
22
24 return fmt::format(
25 R"=(
26---- Source Location ----
27{}:{}:{}
28call = {}
29-------------------------
30)=",
31 loc.file_name(),
32 loc.line(),
33 loc.column(),
34 loc.function_name());
35}
36
37std::string SourceLocation::format_multiline(std::string stacktrace) const {
38 return fmt::format(
39 R"=(
40---- Source Location ----
41{}:{}:{}
42call = {}
43stacktrace :
44{}
45-------------------------
46)=",
47 loc.file_name(),
48 loc.line(),
49 loc.column(),
50 loc.function_name(),
51 stacktrace);
52}
53
54std::string SourceLocation::format_one_line() const {
55 return fmt::format("{}:{}:{}", loc.file_name(), loc.line(), loc.column());
56}
57
58std::string SourceLocation::format_one_line_func() const {
59 return fmt::format(
60 "{} ({}:{}:{})", loc.function_name(), loc.file_name(), loc.line(), loc.column());
61}
Source location utility.
std::string format_one_line_func() const
format the location in a one liner with the function name displayed
std::string format_multiline() const
format the location in multiple lines
std::string format_one_line() const
format the location in a one liner
constexpr const char * file_name() const noexcept
Returns the file name of the source location.
constexpr unsigned column() const noexcept
Returns the column offset of the source location.
constexpr unsigned line() const noexcept
Returns the line number of the source location.
constexpr const char * function_name() const noexcept
Returns the function name of the source location.