xtd 0.2.0
Loading...
Searching...
No Matches
stack_trace.hpp
Go to the documentation of this file.
1
4#pragma once
5#include <exception>
6#include <memory>
7#include "stack_frame.hpp"
8#define __XTD_CORE_INTERNAL__
10#undef __XTD_CORE_INTERNAL__
11
13namespace xtd {
15 class exception;
17
19 namespace diagnostics {
41 public:
43
48
50
125 explicit stack_trace(bool need_file_info, const xtd::diagnostics::stack_frame& current_frame = xtd::diagnostics::stack_frame::current());
126
131 explicit stack_trace(const std::exception& exception);
136 explicit stack_trace(xtd::size skip_frames);
143 stack_trace(const std::exception& exception, xtd::size skip_frames);
181 stack_trace(xtd::size skip_frames, bool need_file_info);
188 stack_trace(const std::exception& exception, xtd::size skip_frames, bool need_file_info);
193 stack_trace(const std::exception& exception, bool need_file_info);
196 auto operator =(const xtd::diagnostics::stack_trace&) -> stack_trace& = default;
199
201
205 static constexpr xtd::size METHODS_TO_SKIP = 0;
207
209
246 [[nodiscard]] auto frame_count() const noexcept -> xtd::size;
248
250
289 [[nodiscard]] auto get_frame(xtd::size index) noexcept -> const xtd::diagnostics::stack_frame&;
290
306 [[nodiscard]] auto get_frames() const noexcept -> const stack_frame_collection&;
307
317 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
319
330 [[nodiscard]] static auto from_stack_frame(const xtd::diagnostics::stack_frame& frame) -> xtd::diagnostics::stack_trace;
331
332
333 private:
334 friend class xtd::exception;
335 stack_trace(const xtd::diagnostics::stack_frame& frame, bool empty);
336 stack_trace(const xtd::string& str, xtd::size skip_frames, bool need_file_info);
337 [[nodiscard]] auto to_string(xtd::size skip_frames) const noexcept -> xtd::string;
338
339 struct data;
340 xtd::ptr<data> data_;
341 };
342 }
343}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.hpp:48
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.
Represents a stack trace, which is an ordered collection of one or more stack frames.
Definition stack_trace.hpp:40
auto get_frames() const noexcept -> const stack_frame_collection &
Returns a copy of all stack frames in the current stack trace.
auto get_frame(xtd::size index) noexcept -> const xtd::diagnostics::stack_frame &
Gets the specified stack frame.
xtd::array< xtd::diagnostics::stack_frame > stack_frame_collection
Represents a stack_frame collection.
Definition stack_trace.hpp:46
stack_trace(const xtd::diagnostics::stack_frame &current_frame=xtd::diagnostics::stack_frame::current())
Initializes a new instance of the xtd::diagnostics::stack_trace class from the caller's frame.
stack_trace(const std::exception &exception, xtd::size skip_frames)
Initializes a new instance of the StackTrace class using the provided exception object and skipping t...
stack_trace(xtd::size skip_frames)
Initializes a new instance of the xtd::diagnostics::stack_trace class from the caller's frame,...
static constexpr xtd::size METHODS_TO_SKIP
Defines the default for the number of methods to omit from the stack trace. This field is constant.
Definition stack_trace.hpp:205
auto to_string() const noexcept -> xtd::string override
Builds a readable representation of the stack trace.
stack_trace(const std::exception &exception, xtd::size skip_frames, bool need_file_info)
Initializes a new instance of the xtd::diagnostics::stack_trace class using the provided exception ob...
stack_trace(const std::exception &exception, bool need_file_info)
Initializes a new instance of the xtd::diagnostics::stack_trace class, using the provided exception o...
static auto from_stack_frame(const xtd::diagnostics::stack_frame &frame) -> xtd::diagnostics::stack_trace
Create a new instance of the xtd::diagnostics::stack_trace class that contains a single frame.
stack_trace(xtd::size skip_frames, bool need_file_info)
Initializes a new instance of the xtd::diagnostics::stack_trace class from the caller's frame,...
stack_trace(bool need_file_info, const xtd::diagnostics::stack_frame &current_frame=xtd::diagnostics::stack_frame::current())
Initializes a new instance of the xtd::diagnostics::stack_trace class from the caller's frame,...
stack_trace(const std::exception &exception)
Initializes a new instance of the xtd::diagnostics::stack_trace class using the provided exception ob...
auto frame_count() const noexcept -> xtd::size
Gets the number of frames in the stack trace.
Defines the base class for predefined exceptions in the xtd namespace.
Definition exception.hpp:29
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
#define core_export_
Define shared library export.
Definition core_export.hpp:13
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
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 const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::diagnostics::stack_frame class.