xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Go to the documentation of this file.
1 #pragma once
5 #include <exception>
6 #include <memory>
7 #include <vector>
8 #include "../core_export.h"
9 #include "../object.h"
10 #include "../ustring.h"
11 #include "stack_frame.h"
14 namespace xtd {
16  class system_exception;
20  namespace diagnostics {
37  class core_export_ stack_trace : public xtd::object {
38  public:
43  using stack_frame_collection = std::vector<xtd::diagnostics::stack_frame>;
85  stack_trace();
122  explicit stack_trace(bool need_file_info);
133  explicit stack_trace(const xtd::diagnostics::stack_frame& frame);
138  explicit stack_trace(const std::exception& exception);
143  explicit stack_trace(size_t skip_frames);
150  stack_trace(const std::exception& exception, size_t skip_frames);
188  stack_trace(size_t skip_frames, bool need_file_info);
195  stack_trace(const std::exception& exception, size_t skip_frames, bool need_file_info);
200  stack_trace(const std::exception& exception, bool need_file_info);
202  stack_trace(const stack_trace&) = default;
203  stack_trace& operator=(const stack_trace&) = default;
212  static constexpr size_t METHODS_TO_SKIP = 0;
253  size_t frame_count() const;
296  const xtd::diagnostics::stack_frame& get_frame(size_t index);
313  const stack_frame_collection& get_frames() const;
324  xtd::ustring to_string() const noexcept override;
328  friend std::ostream& operator<<(std::ostream& os, const xtd::diagnostics::stack_trace& stack_trace) noexcept {return os << stack_trace.to_string();}
331  private:
332  friend class xtd::system_exception;
333  stack_trace(const xtd::ustring& str, size_t skip_frames, bool need_file_info);
336  stack_frame_collection frames_;
337  };
338  }
339 }
Defines the base class for predefined exceptions in the xtd namespace.
Definition: system_exception.h:24
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Represents a stack trace, which is an ordered collection of one or more stack frames.
Definition: stack_trace.h:37
virtual xtd::ustring stack_trace() const noexcept
Gets a string representation of the immediate frames on the call stack.
Definition: system_exception.h:137
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1110
std::vector< xtd::diagnostics::stack_frame > stack_frame_collection
Represents a stack_frame collection.
Definition: stack_trace.h:43
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition: stack_frame.h:34
static stack_frame empty() noexcept
Return an empty stack frame.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
xtd::ustring to_string() const noexcept override
Builds a readable representation of the stack trace.
Contains xtd::diagnostics::stack_frame class.