xtd 0.2.0
stack_trace.h
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"
12 
14 namespace xtd {
16  class system_exception;
18 
20  namespace diagnostics {
39  class core_export_ stack_trace : public xtd::object {
40  public:
42 
45  using stack_frame_collection = std::vector<xtd::diagnostics::stack_frame>;
47 
49 
87  stack_trace();
124  explicit stack_trace(bool need_file_info);
135  explicit stack_trace(const xtd::diagnostics::stack_frame& frame);
140  explicit stack_trace(const std::exception& exception);
145  explicit stack_trace(size_t skip_frames);
152  stack_trace(const std::exception& exception, size_t skip_frames);
190  stack_trace(size_t skip_frames, bool need_file_info);
197  stack_trace(const std::exception& exception, size_t skip_frames, bool need_file_info);
202  stack_trace(const std::exception& exception, bool need_file_info);
204  stack_trace(const stack_trace&) = default;
205  stack_trace& operator =(const stack_trace&) = default;
208 
210 
214  static constexpr size_t METHODS_TO_SKIP = 0;
216 
218 
255  size_t frame_count() const noexcept;
257 
259 
298  const xtd::diagnostics::stack_frame& get_frame(size_t index) noexcept;
299 
315  const stack_frame_collection& get_frames() const noexcept;
316 
326  xtd::ustring to_string() const noexcept override;
328 
329  private:
330  friend class xtd::system_exception;
331  stack_trace(const xtd::ustring& str, size_t skip_frames, bool need_file_info);
332  xtd::ustring to_string(size_t skip_frames, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty()) const noexcept;
333 
334  stack_frame_collection frames_;
335  };
336  }
337 }
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:39
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
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:1063
std::vector< xtd::diagnostics::stack_frame > stack_frame_collection
Represents a stack_frame collection.
Definition: stack_trace.h:45
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition: stack_frame.h:37
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
Contains xtd::diagnostics::stack_frame class.