The pointer
class is one of the types supported by container::xpod::type.
More...
#include <pointer.hpp>
The pointer
class is one of the types supported by container::xpod::type.
It provides an optional reference-counted mechanism (via stable_reference_buffer or an internal std::shared_ptr
) to manage the underlying memory. Otherwise, it simply stores a raw pointer.
◆ pointer() [1/5]
cbeam::memory::pointer::pointer |
( |
| ) |
|
|
default |
◆ pointer() [2/5]
cbeam::memory::pointer::pointer |
( |
void * | ptr | ) |
|
|
inline |
Construct from the given raw pointer. Checks if this ptr is managed by stable_reference_buffer.
- Parameters
-
ptr | A raw pointer that may or may not be managed by stable_reference_buffer. If it is managed, a reference to it is kept in _mem . |
◆ pointer() [3/5]
cbeam::memory::pointer::pointer |
( |
const std::string & | str_ptr | ) |
|
|
inline |
Construct from the given pointer in string representation (e.g. "0x...").
Internally calls convert::from_string<void*>(str_ptr)
.
- Parameters
-
str_ptr | The string representation of the pointer. |
◆ pointer() [4/5]
Construct from an existing stable_reference_buffer, incrementing its reference counter.
- Parameters
-
mem | A stable_reference_buffer object referencing some memory. |
◆ pointer() [5/5]
template<typename T>
cbeam::memory::pointer::pointer |
( |
const std::shared_ptr< T > & | ptr | ) |
|
|
inline |
◆ is_managed()
bool cbeam::memory::pointer::is_managed |
( |
| ) |
const |
|
inline |
Checks whether the pointer is managed by stable_reference_buffer (or a std::shared_ptr
) or not.
- Returns
- true if the pointer is managed, false otherwise.
◆ operator container::stable_reference_buffer()
Converts the pointer to a stable_reference_buffer
if it is managed, otherwise throws a runtime_error.
- Exceptions
-
- Returns
- A copy of the underlying stable_reference_buffer.
◆ operator std::string()
cbeam::memory::pointer::operator std::string |
( |
| ) |
const |
|
inlineexplicit |
Converts the pointer to a hex string with leading "0x".
- Returns
- A string representation of the pointer value in hexadecimal format.
◆ operator void *()
cbeam::memory::pointer::operator void * |
( |
| ) |
const |
|
inline |
Converts the pointer to a raw void*
.
- Returns
- A
void*
pointing to the underlying memory (or nullptr if empty).
◆ operator=()
Copy assignment operator. Increments the reference counter if the other pointer is managed.
- Parameters
-
other | The pointer object to copy from. |
- Returns
- A reference to this object.
The documentation for this class was generated from the following file: