Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Utopia::TestTools::LocationInfo Struct Reference

Bundles and handles file location information: file path and line number. More...

#include <utils.hh>

Public Member Functions

 LocationInfo ()=default
 Constructs a location object without information.
 
 LocationInfo (const std::size_t line, const std::string_view file_path)
 Constructs a location object from line and file path information.
 
std::string string () const
 A string representation of the location, using the fstr member.
 

Public Attributes

std::size_t line = 0
 Some line, e.g. as provided by LINE macro.
 
std::filesystem::path file_path = ""
 Some file path, e.g. as provided by FILE macro.
 
std::string_view fstr = "@ {file_name:}::{line:d} : "
 A fmt library format string.
 

Detailed Description

Bundles and handles file location information: file path and line number.

Constructor & Destructor Documentation

◆ LocationInfo() [1/2]

Utopia::TestTools::LocationInfo::LocationInfo ( )
default

Constructs a location object without information.

◆ LocationInfo() [2/2]

Utopia::TestTools::LocationInfo::LocationInfo ( const std::size_t  line,
const std::string_view  file_path 
)
inline

Constructs a location object from line and file path information.

42 : line(line)
44 {}
std::size_t line
Some line, e.g. as provided by LINE macro.
Definition utils.hh:27
std::filesystem::path file_path
Some file path, e.g. as provided by FILE macro.
Definition utils.hh:30

Member Function Documentation

◆ string()

std::string Utopia::TestTools::LocationInfo::string ( ) const
inline

A string representation of the location, using the fstr member.

Will return an empty string if no location was specified.

49 {
50 if (file_path.empty()) {
51 return "";
52 }
53
54 using namespace fmt::literals;
55 return fmt::vformat(
56 fstr,
57 fmt::make_format_args(
58 "file_path"_a=file_path.string(),
59 "file_name"_a=file_path.filename().string(),
60 "line"_a=line
61 )
62 );
63 }
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
std::string_view fstr
A fmt library format string.
Definition utils.hh:35

Member Data Documentation

◆ file_path

std::filesystem::path Utopia::TestTools::LocationInfo::file_path = ""

Some file path, e.g. as provided by FILE macro.

◆ fstr

std::string_view Utopia::TestTools::LocationInfo::fstr = "@ {file_name:}::{line:d} : "

A fmt library format string.

Available keys: file_name, file_path, line

◆ line

std::size_t Utopia::TestTools::LocationInfo::line = 0

Some line, e.g. as provided by LINE macro.


The documentation for this struct was generated from the following file: