xtd 1.0.0
Loading...
Searching...
No Matches
stack_frame.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include "source_location.hpp"
7#include "../core_export.hpp"
8#include "../iequatable.hpp"
9#include "../null_ptr.hpp"
10#include "../object.hpp"
11#include "../ptr.hpp"
12#include "../usize.hpp"
13#define __XTD_CORE_INTERNAL__
15#undef __XTD_CORE_INTERNAL__
16#include <limits>
17
19namespace xtd {
21 namespace diagnostics {
23 class stack_trace;
25
46 class core_export_ stack_frame : public xtd::object, public xtd::iequatable<stack_frame> {
47 public:
48
50
56 explicit stack_frame(xtd::usize skip_frame);
59 explicit stack_frame(bool need_file_info);
63 stack_frame(xtd::usize skip_frame, bool need_file_info);
67 stack_frame(const xtd::string& file_name, xtd::usize line_number);
72 stack_frame(const xtd::string& file_name, xtd::usize line_number, const xtd::string& method_name);
78 stack_frame(const xtd::string& file_name, xtd::usize line_number, const xtd::string& method_name, xtd::usize column_number);
84 stack_frame(const xtd::string& file_name, xtd::usize line_number, xtd::usize column_number);
91 stack_frame(const xtd::string& file_name, xtd::usize line_number, const xtd::string& method_name, xtd::usize column_number, xtd::usize offset);
101 stack_frame(xtd::null_ptr frame); // Not explicit by design.
105 auto operator =(const xtd::diagnostics::stack_frame&) -> stack_frame& = default;
106 auto operator =(xtd::diagnostics::stack_frame&&) -> stack_frame& = default;
109
111
115 [[nodiscard]] static auto empty() noexcept -> xtd::diagnostics::stack_frame;
116
119 static constexpr xtd::usize OFFSET_UNKNOWN = std::numeric_limits<xtd::usize>::max();
121
123
128 [[nodiscard]] auto equals(const xtd::object& obj) const noexcept -> bool override;
132 [[nodiscard]] auto equals(const xtd::diagnostics::stack_frame& other) const noexcept -> bool override;
133
136 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
137
153 [[nodiscard]] virtual auto get_file_column_number() const noexcept -> xtd::usize;
154
170 [[nodiscard]] virtual auto get_file_line_number() const noexcept -> xtd::usize;
171
187 [[nodiscard]] virtual auto get_file_name() const noexcept -> const xtd::string&;
188
204 [[nodiscard]] virtual auto get_method() const noexcept -> const xtd::string&;
205
221 [[nodiscard]] virtual auto get_native_offset() const noexcept -> xtd::usize;
222
238 [[nodiscard]] virtual auto get_offset() const noexcept -> xtd::usize;
239
242 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
244
246
255 [[nodiscard]] static auto current(const xtd::diagnostics::source_location& value = xtd::diagnostics::source_location::current()) noexcept -> xtd::diagnostics::stack_frame;
257
258 private:
259 friend class stack_trace;
260 static auto get_stack_frames(const xtd::string& str, xtd::usize skip_frames, bool need_file_info) noexcept;
261
262 struct data;
263 xtd::ptr<data> data_;
264 };
265 }
266}
The xtd::diagnostics::source_location class represents certain information about the source code,...
Definition source_location.hpp:33
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.hpp:46
auto to_string() const noexcept -> xtd::string override
Builds a readable representation of the stack trace.
virtual auto get_file_column_number() const noexcept -> xtd::usize
Gets the column number in the file that contains the code that is executing. This information is typi...
stack_frame(const xtd::diagnostics::source_location &source_location, xtd::usize offset)
Initializes a new instance of the xtd::diagnostics::stack_frame class that contains only the given gi...
static constexpr xtd::usize OFFSET_UNKNOWN
Defines the value that is returned from the get_offset() method when the offset is unknown....
Definition stack_frame.hpp:119
virtual auto get_offset() const noexcept -> xtd::usize
Gets the offset from the start of the code for the method that is being executed.
virtual auto get_method() const noexcept -> const xtd::string &
Gets the method in which the frame is executing.
virtual auto get_native_offset() const noexcept -> xtd::usize
Gets the offset from the start of the native code for the method that is being executed.
virtual auto get_file_name() const noexcept -> const xtd::string &
Gets the file name that contains the code that is executing. This information is typically extracted ...
stack_frame(const xtd::string &file_name, xtd::usize line_number, const xtd::string &method_name)
Initializes a new instance of the xtd::diagnostics::stack_frame class that contains only the given fi...
stack_frame()
Initializes a new instance of the xtd::diagnostics::stack_frame class.
stack_frame(xtd::usize skip_frame, bool need_file_info)
Initializes a new instance of the xtd::diagnostics::stack_frame class that corresponds to a frame abo...
stack_frame(xtd::usize skip_frame)
Initializes a new instance of the xtd::diagnostics::stack_frame class that corresponds to a frame abo...
stack_frame(xtd::null_ptr frame)
Initializes a new empty instance of the xtd::diagnostics::stack_frame.
stack_frame(const xtd::string &file_name, xtd::usize line_number, const xtd::string &method_name, xtd::usize column_number, xtd::usize offset)
Initializes a new instance of the xtd::diagnostics::stack_frame class that contains only the given fi...
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
static auto empty() noexcept -> xtd::diagnostics::stack_frame
Return an empty stack frame.
virtual auto get_file_line_number() const noexcept -> xtd::usize
Gets the line number in the file that contains the code that is executing. This information is typica...
static auto current(const xtd::diagnostics::source_location &value=xtd::diagnostics::source_location::current()) noexcept -> xtd::diagnostics::stack_frame
Crates a new xtd::diagnostics::stack_frame object corresponding to the location of the call site.
stack_frame(const xtd::diagnostics::source_location &source_location)
Initializes a new instance of the xtd::diagnostics::stack_frame class that contains only the given so...
stack_frame(const xtd::string &file_name, xtd::usize line_number, xtd::usize column_number)
Initializes a new instance of the xtd::diagnostics::stack_frame class that contains only the given fi...
stack_frame(bool need_file_info)
Initializes a new instance of the xtd::diagnostics::stack_frame class, optionally capturing source in...
stack_frame(const xtd::string &file_name, xtd::usize line_number)
Initializes a new instance of the xtd::diagnostics::stack_frame class that contains only the given fi...
auto equals(const xtd::object &obj) const noexcept -> bool override
Indicates whether the current xtd::diagnostic::stack_frame is equal to another xtd::diagnostic::stack...
stack_frame(const xtd::string &file_name, xtd::usize line_number, const xtd::string &method_name, xtd::usize column_number)
Initializes a new instance of the xtd::diagnostics::stack_frame class that contains only the given fi...
Represents a stack trace, which is an ordered collection of one or more stack frames.
Definition stack_trace.hpp:40
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
std::nullptr_t null_ptr
Represents the null_opt alias on std::nullptr_t.
Definition null_ptr.hpp:19
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
Contains xtd::iequatable interface.
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Contains xtd::null_ptr alias.
Contains xtd::object class.
Contains xtd::ptr type.
Contains xtd::diagnostics::source_location method.
Contains xtd::usize type.