The xtd::diagnostics::source_location class represents certain information about the source code, such as file names, line numbers, and function names. Previously, functions that desire to obtain this information about the call site (for logging, testing, or debugging purposes) must use macros so that predefined macros like __LINE__
and __FILE__
are expanded in the context of the caller. The xtd::diagnostics::source_location class provides a better alternative.
Public Constructors | |
source_location () | |
Initializes a new instance of the xtd::diagnostics::source_location class. | |
Public Properties | |
xtd::size | column () const noexcept |
Gets the column number represented by this object. | |
const xtd::string & | file_name () const noexcept |
Gets the name of the current source file represented by this object, represented as a null-terminated byte string. | |
const xtd::string & | function_name () const noexcept |
Gets the name of the function associated with the position represented by this object, if any. | |
xtd::size | line () const noexcept |
Gets the line number represented by this object. | |
Public Methods | |
xtd::string | to_string () const noexcept override |
Returns a xtd::string that represents the current object. | |
Public Static Methods | |
static source_location | current (const __xtd_source_location__ &value=__xtd_source_location__::current()) noexcept |
Crates a new xtd::diagnostics::source_location object corresponding to the location of the call site. | |
Additional Inherited Members | |
![]() | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual xtd::size | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<class object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
![]() | |
template<class object_a_t , class object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<class object_a_t , class object_b_t > | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
xtd::diagnostics::source_location::source_location | ( | ) |
Initializes a new instance of the xtd::diagnostics::source_location class.
|
noexcept |
Gets the column number represented by this object.
|
noexcept |
Gets the name of the current source file represented by this object, represented as a null-terminated byte string.
""
) when the source file is unknown.
|
noexcept |
Gets the name of the function associated with the position represented by this object, if any.
""
) is returned.
|
noexcept |
Gets the line number represented by this object.
|
overridevirtualnoexcept |
Returns a xtd::string that represents the current object.
Reimplemented from xtd::object.
|
staticnoexcept |
Crates a new xtd::diagnostics::source_location object corresponding to the location of the call site.
__LINE__
and __FILE__
.