xtd 0.2.0
stack_frame.h
Go to the documentation of this file.
1 #pragma once
5 #include <cstdint>
6 #include <limits>
7 #include "../iequatable.h"
8 #include "../object.h"
9 #include "../ustring.h"
10 
12 namespace xtd {
14  namespace diagnostics {
16  class stack_trace;
18 
37  class core_export_ stack_frame : public xtd::object, public xtd::iequatable<stack_frame> {
38  public:
39 
41 
44  stack_frame();
47  explicit stack_frame(size_t skip_frame);
50  explicit stack_frame(bool need_file_info);
54  stack_frame(size_t skip_frame, bool need_file_info);
58  stack_frame(const xtd::ustring& file_name, uint32 line_number);
63  stack_frame(const xtd::ustring& file_name, uint32 line_number, const xtd::ustring& method_name);
69  stack_frame(const xtd::ustring& file_name, uint32 line_number, const xtd::ustring& method_name, uint32 column_number);
75  stack_frame(const xtd::ustring& file_name, uint32 line_number, uint32 column_number);
81  stack_frame(const xtd::ustring& file_name, uint32 line_number, const xtd::ustring& method_name, uint32 column_number, uint32 offset);
83  stack_frame(const stack_frame&) = default;
84  stack_frame(stack_frame&&) = default;
85  stack_frame& operator =(const stack_frame&) = default;
88 
90 
94  static stack_frame empty() noexcept;
95 
98  static constexpr uint32 OFFSET_UNKNOWN = std::numeric_limits<uint32>::max();
100 
102 
104  bool equals(const stack_frame& sf) const noexcept override;
105 
121  virtual uint32 get_file_column_number() const noexcept;
122 
138  virtual uint32 get_file_line_number() const noexcept;
139 
155  virtual const xtd::ustring& get_file_name() const noexcept;
156 
172  virtual const xtd::ustring& get_method() const noexcept;
173 
189  virtual uint32 get_offset() const noexcept;
190 
193  xtd::ustring to_string() const noexcept override;
194 
195  private:
196  friend class stack_trace;
197  static std::vector<stack_frame> get_stack_frames(const xtd::ustring& str, size_t skip_frames, bool need_file_info) noexcept;
198 
199  xtd::ustring file_name_;
200  uint32 file_line_number_ = 0;
201  xtd::ustring method_name_;
202  uint32 file_column_number_ = 0;
203  uint32 offset_ = OFFSET_UNKNOWN;
204  };
205  }
206 }
207 
208 #include "current_stack_frame.h"
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
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
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
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:239