xtd 0.2.0
Loading...
Searching...
No Matches
line_info.cpp

Shows how to use xtd::diagnostics::stack_frame class and csf_ keyword.

#include <xtd/xtd.tunit>
#include <iostream>
using namespace std;
using namespace xtd::diagnostics;
using namespace xtd::tunit;
void trace_message(const string& message, const stack_frame& sf) {
cout << "message: " << message << endl;
cout << "member name: " << sf.get_method() << endl;
cout << "source file path: " << sf.get_file_name() << endl;
cout << "source line number: " << sf.get_file_line_number() << endl;
}
auto main()->int {
trace_message("Something happened.", csf_);
}
// This code can produce the following output:
//
// message: Something happened.
// member name: main
// source file path: !---OMITTED---!/line_info/src/line_info.cpp
// source line number: 16
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.h:37
virtual uint32 get_file_line_number() const noexcept
Gets the line number in the file that contains the code that is executing. This information is typica...
virtual const xtd::ustring & get_file_name() const noexcept
Gets the file name that contains the code that is executing. This information is typically extracted ...
virtual const xtd::ustring & get_method() const noexcept
Gets the method in which the frame is executing.
#define csf_
Provides information about the current stack frame.
Definition current_stack_frame.h:30
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.h:10
The tunit namespace contains a unit test library.
Definition abort_error.h:10