Skip to content

Commit e788d28

Browse files
committed
Adapted documentation of the callstack wrapper class, made two parameters constant
1 parent 6590f9c commit e788d28

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

include/callstack.hpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* CallstackLibrary - Library creating human-readable call stacks.
33
*
4-
* Copyright (C) 2022 - 2024 mhahnFr
4+
* Copyright (C) 2022 - 2025 mhahnFr
55
*
66
* This file is part of the CallstackLibrary.
77
*
@@ -38,26 +38,26 @@
3838
#include "callstack_cxx_compat.hpp"
3939

4040
/**
41-
* This namespace contains a wrapper class for the `struct callstack`.
41+
* This namespace contains a wrapper class for the @code struct callstack@endcode.
4242
* It is needed to avoid name conflicts between the structure and the wrapper class.
4343
*/
4444
namespace lcs {
4545
/**
46-
* @brief A wrapper class around the `struct callstack`.
46+
* @brief A wrapper class around the @code struct callstack@endcode.
4747
*
4848
* It provides the usual constructors and operator overloads. Additionally, it contains the
4949
* possibility to implicitly cast an object of this class to a pointer to the C structure.
5050
*/
5151
class callstack {
52-
/** A `typedef` for convenience. */
52+
/** A @c typedef for convenience. */
5353
typedef ::callstack struct_callstack;
54-
/** The original C structure. */
54+
/** The original C structure. */
5555
struct_callstack self;
5656

5757
/**
58-
* @brief Helper function to throw the appropriate exception.
58+
* Helper function to throw the appropriate exception.
5959
*
60-
* @throws A `system_error` if compiled using C++11 or newer, a runtime error otherwise.
60+
* @throws std::system_error if compiled using C++11 or newer, a @c std::runtime_error otherwise
6161
*/
6262
inline static void error() {
6363
#if __cplusplus >= 201103
@@ -71,14 +71,15 @@ class callstack {
7171
/**
7272
* @brief A trivial default constructor.
7373
*
74-
* Zero-initializes the underlying C structure. If the given boolean value is `true`,
75-
* it is initialized using the function `callstack_emplace()`.
76-
* Throws a `runtime_error` or a `system_error` if compiled using C++11 or newer if
77-
* `emplace` is set to `true` and the backtrace could not be created.
74+
* Zero-initializes the underlying C structure. If the given boolean value is @c true,
75+
* it is initialized using the function @c callstack_emplace().
76+
* Throws a @c std::runtime_error (or a @c std::system_error if compiled using C++11 or newer) if
77+
* @c emplace is set to @c true and the backtrace could not be created.
7878
*
79-
* @param emplace Whether to call `callstack_emplace()`.
79+
* @param emplace Whether to call @c callstack_emplace().
80+
* @throws std::system_error if the backtrace could not be created
8081
*/
81-
inline explicit callstack(bool emplace = true) {
82+
inline explicit callstack(const bool emplace = true) {
8283
if (emplace) {
8384
if (!callstack_emplace(*this)) {
8485
error();
@@ -91,11 +92,12 @@ class callstack {
9192
/**
9293
* @brief Constructs this object using the given stack address.
9394
*
94-
* Initializes the underlying C structure using the function `callstack_emplaceWithAddress()`.
95-
* Throws a `runtime_error` or a `system_error` if compiled using C++11 or newer if
95+
* Initializes the underlying C structure using the function @c callstack_emplaceWithAddress().
96+
* Throws a @c std::runtime_error (or a @c std::system_error if compiled using C++11 or newer) if
9697
* the backtrace could not be created.
9798
*
9899
* @param address The stack address after which frames are ignored.
100+
* @throws std::system_error if the backtrace could not be created
99101
*/
100102
inline explicit callstack(void* address) {
101103
if (!callstack_emplaceWithAddress(*this, address)) {
@@ -106,13 +108,14 @@ class callstack {
106108
/**
107109
* @brief Constructs the underlying C structure with the given backtrace.
108110
*
109-
* if the given trace length is smaller than zero, a `runtime_error` or a `system_error`
110-
* if compiled using C++11 or newer is thrown.
111+
* if the given trace length is smaller than zero, a @c std::runtime_error
112+
* (or a @c std::system_error if compiled using C++11 or newer) is thrown.
111113
*
112114
* @param trace The backtrace.
113115
* @param length The length of the given backtrace.
116+
* @throws std::system_error if the trace length is smaller than @c 0
114117
*/
115-
inline callstack(void** trace, int length) {
118+
inline callstack(void** trace, const int length) {
116119
if (!callstack_emplaceWithBacktrace(*this, trace, length)) {
117120
error();
118121
}
@@ -163,9 +166,9 @@ class callstack {
163166
*
164167
* @param onlyBinaries whether to only deduct the names of the runtime images
165168
* @return @c this
166-
* @throws an exception when the translation failed
169+
* @throws std::runtime_error if the translation failed
167170
*/
168-
inline callstack& translate(bool onlyBinaries = false) {
171+
inline callstack& translate(const bool onlyBinaries = false) {
169172
if (onlyBinaries) {
170173
if (callstack_getBinaries(*this) == LCS_NULL) {
171174
throw std::runtime_error("LCS: Failed to translate the callstack (binaries only)");
@@ -186,7 +189,7 @@ class callstack {
186189
* the cache of the library and only valid as long as the cache is.
187190
*
188191
* @return @c this
189-
* @throws an exception if the translation failed
192+
* @throws std::runtime_error if the translation failed
190193
*/
191194
inline callstack& translateBinariesCached() {
192195
if (callstack_getBinariesCached(*this) == LCS_NULL) {

0 commit comments

Comments
 (0)