|
Enrollment 28.2.0
|
Class to capture the source location of an error or exception. More...
#include <SourceLocation.h>
Public Member Functions | |
| std::string | FileName () const |
| Get the name of the file where the exception occurred. | |
| std::string | FunctionName () const |
| Get the name of the function where the exception occurred. | |
| constexpr int | Line () const |
| Get the line number where the exception occurred. | |
| SourceLocation (const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE()) | |
| Constructor to initialize a source location. | |
| std::string | ToString () const |
| Creates string representation of SourceLocation. | |
Class to capture the source location of an error or exception.
This struct serves as a pre-C++20 replacement for std::source_location, which is used to capture and store information about the source location where an exception was thrown.
|
inlineexplicit |
Constructor to initialize a source location.
This constructor initializes a SourceLocation object with the file name, function name, and line number. In C++ the values are typically captured using compiler-provided built-in macros like __builtin_FILE(), __builtin_FUNCTION(), and __builtin_LINE().
| file | The name of the source file |
| function | The name of the function |
| line | The line number within the file |
|
inlinenodiscard |
Get the name of the file where the exception occurred.
This function returns the file name (path) where the exception was thrown.
|
inlinenodiscard |
Get the name of the function where the exception occurred.
This function returns the name of the function in which the exception was thrown.
|
inlinenodiscardconstexpr |
Get the line number where the exception occurred.
This function returns the line number from where the exception was thrown.
|
inlinenodiscard |
Creates string representation of SourceLocation.
Format is file:line 'function'