Skip to content

callstack.hpp

mhahnFr edited this page May 25, 2024 · 11 revisions

This header defines the C++ wrapper class for the callstack structure.
It's not necessary to include this header on its own, this is automatically done by callstack.h.

namespace lcs

The namespace used to separate the wrapper class from the struct callstack, declared in callstack.h.

class callstack

The actual wrapper class, consisting of all necessary operators and constructors for seamlessly integration into C++ code.

Typedefs

typedef ::callstack struct_callstack

A typedef to improve the readability of the code.

Variables

A private variable containing the underlying struct callstack.

Note

The underlying callstack object is managed by this class.

Constructors

callstack::callstack(bool emplace = true)

The default constructor. Creates a new backtrace unless emplace is set to false. In either case, the underlying struct callstack is properly initialized.
If the backtrace could not be created a runtime_error or a system_error if compiled using C++11 or newer is thrown.

callstack::callstack(void* address)

Initializes the underlying struct callstack creating a backtrace of the calling function, ignoring all frames after the given address.
If the backtrace could not be created a runtime_error or a system_error if compiled using C++11 or newer is thrown.

callstack::callstack(void** trace, int length)

Constructs the underlying struct callstack using the given trace.
If the length of the trace is smaller than 0 a runtime_error or a system_error if compiled using C++11 or newer is thrown.

callstack::callstack(const callstack&other)

Trivial copy constructor.

explicit callstack::callstack(const struct_callstack* other)

Constructs a callstack object using the given struct callstack.

callstack::callstack(callstack&& other)

Trivial move constructor. Only available when compiled using a compiler supporting C++11 or newer.

Destructor

callstack::~callstack()

Trivial destructor.

Operators

callstack& operator=(const callstack& other)

Trivial copy assignment operator.

callstack& operator=(callstack&& other)

Trivial move assignment operator. Only available when compiled using a compiler supporting C++11 or newer.

operator struct_callstack*()

Implicit casting operator. Returns a pointer to the underlying struct callstack.

operator const struct_callstack*() const

Implicit casting operator. Returns a pointer to the underlying struct callstack.

struct_callstack* operator->()

Dereferencing operator. Returns a pointer to the underlying struct callstack.

Note

Added in version 1.1.

const struct_callstack* operator->() const

Dereferencing operator. Returns a pointer to the underlying struct callstack.

Note

Added in version 1.1.

Methods

void error()

Private helper function used to throw either a system_error if compiled using C++11 or newer or to throw a runtime_error otherwise.