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.
source_location()
Initializes a new instance of the xtd::diagnostics::source_location class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
#define core_export_
Define shared library export.
Definition core_export.hpp:13
- Inheritance
- xtd::object → xtd::diagnostics::source_location
- Header
#include <xtd/diagnostics/source_location>
- Namespace
- xtd
- Library
- xtd.core
|
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.
|
|
|
| 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::unique_ptr_object< 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.
|
|
◆ source_location()
xtd::diagnostics::source_location::source_location |
( |
| ) |
|
◆ column()
xtd::size xtd::diagnostics::source_location::column |
( |
| ) |
const |
|
noexcept |
Gets the column number represented by this object.
- Returns
- The column number represented by this object.
◆ file_name()
const xtd::string & xtd::diagnostics::source_location::file_name |
( |
| ) |
const |
|
noexcept |
Gets the name of the current source file represented by this object, represented as a null-terminated byte string.
- Returns
- The name of the current source file represented by this object.
◆ function_name()
const xtd::string & xtd::diagnostics::source_location::function_name |
( |
| ) |
const |
|
noexcept |
Gets the name of the function associated with the position represented by this object, if any.
- Returns
- If this object represents a position in a body of a function, returns a string corresponding to the name of the function; otherwise, an xtd::string::empty_string (
""
) is returned.
◆ line()
xtd::size xtd::diagnostics::source_location::line |
( |
| ) |
const |
|
noexcept |
Gets the line number represented by this object.
- Returns
- The line number represented by this object.
◆ to_string()
xtd::string xtd::diagnostics::source_location::to_string |
( |
| ) |
const |
|
overridevirtualnoexcept |
Returns a xtd::string that represents the current object.
- Returns
- A string that represents the current object.
- Examples
- The following code example demonstrates what to_string returns.
#include <xtd/xtd>
namespace examples {
namespace object_test {
class object1 :
public object {
};
}
}
auto main() -> int {
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
object()=default
Create a new instance of the ultimate base class object.
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Reimplemented from xtd::object.
◆ current()
static source_location xtd::diagnostics::source_location::current |
( |
const __xtd_source_location__ & | value = __xtd_source_location__::current() | ) |
|
|
staticnoexcept |
The documentation for this class was generated from the following file: