qxLib
Public Member Functions | List of all members
qx::sbo_bytes< traits_t > Class Template Reference

A type erased small buffer object that works with raw data. More...

#include <sbo_bytes.h>

Public Member Functions

bool resize (size_type nRequestedSize) noexcept
 Make sure the capacity is at least nRequestedSize and allocate memory if needed, and change the size to nRequestedSize. More...
 
bool reserve (size_type nRequestedSize) noexcept
 Make sure the capacity is at least nRequestedSize and allocate memory if needed, but do not change the size. More...
 
bool shrink_to_fit () noexcept
 Reduce capacity to fit the size, possibly moving data to the internal buffer if the size becomes small. More...
 
void free () noexcept
 Free allocated memory.
 
QX_FORCE_INLINE std::byte * data () noexcept
 Get SBO data: from a buffer or from a heap. More...
 
QX_FORCE_INLINE const std::byte * data () const noexcept
 Get SBO data: from a buffer or from a heap. More...
 
QX_FORCE_INLINE size_type size () const noexcept
 Get SBO size (bytes) More...
 
QX_FORCE_INLINE size_type capacity () const noexcept
 Get SBO capacity (bytes) More...
 
QX_FORCE_INLINE bool is_small () const noexcept
 Is the SBO small and fits into the local buffer. More...
 

Detailed Description

template<class traits_t>
class qx::sbo_bytes< traits_t >

A type erased small buffer object that works with raw data.

Template Parameters
traits_t- SBO traits type
Author
Khrapov
Date
20.12.2025

Definition at line 29 of file sbo_bytes.h.

Member Function Documentation

◆ capacity()

template<class traits_t >
QX_FORCE_INLINE sbo_bytes< traits_t >::size_type qx::sbo_bytes< traits_t >::capacity ( void  ) const
noexcept

Get SBO capacity (bytes)

Return values
-SBO capacity (bytes), can't be less than nBufferSize

Definition at line 118 of file sbo_bytes.inl.

◆ data() [1/2]

template<class traits_t >
QX_FORCE_INLINE const std::byte * qx::sbo_bytes< traits_t >::data
noexcept

Get SBO data: from a buffer or from a heap.

Return values
-SBO data pointer

Definition at line 106 of file sbo_bytes.inl.

◆ data() [2/2]

template<class traits_t >
QX_FORCE_INLINE std::byte * qx::sbo_bytes< traits_t >::data
noexcept

Get SBO data: from a buffer or from a heap.

Return values
-SBO data pointer

Definition at line 97 of file sbo_bytes.inl.

◆ is_small()

template<class traits_t >
QX_FORCE_INLINE bool qx::sbo_bytes< traits_t >::is_small
noexcept

Is the SBO small and fits into the local buffer.

Return values
-true if the SBO is small and fits into the local buffer

Definition at line 124 of file sbo_bytes.inl.

◆ reserve()

template<class traits_t >
bool qx::sbo_bytes< traits_t >::reserve ( size_type  nRequestedSize)
noexcept

Make sure the capacity is at least nRequestedSize and allocate memory if needed, but do not change the size.

Parameters
nRequestedSize- required size (bytes)
Return values
-false if memory allocation failed, true otherwise

Definition at line 60 of file sbo_bytes.inl.

◆ resize()

template<class traits_t >
bool qx::sbo_bytes< traits_t >::resize ( size_type  nRequestedSize)
noexcept

Make sure the capacity is at least nRequestedSize and allocate memory if needed, and change the size to nRequestedSize.

Parameters
nRequestedSize- required size (bytes)
Return values
-false if memory allocation failed, true otherwise

Definition at line 39 of file sbo_bytes.inl.

◆ shrink_to_fit()

template<class traits_t >
bool qx::sbo_bytes< traits_t >::shrink_to_fit
noexcept

Reduce capacity to fit the size, possibly moving data to the internal buffer if the size becomes small.

Return values
-false if memory allocation failed, SBO remains valid in this case, true otherwise

Definition at line 69 of file sbo_bytes.inl.

◆ size()

template<class traits_t >
QX_FORCE_INLINE sbo_bytes< traits_t >::size_type qx::sbo_bytes< traits_t >::size
noexcept

Get SBO size (bytes)

Return values
-SBO size (bytes)

Definition at line 112 of file sbo_bytes.inl.


The documentation for this class was generated from the following files: