A buffer class that allocates a buffer of a given type and size. More...
#include <mn_buffer.hpp>
Public Types | |
using | self_type = buffer< TVALUE, TALLOCATOR > |
using | value_type = TVALUE |
using | allocator = TALLOCATOR |
using | pointer = value_type * |
using | reference = value_type & |
using | size_type = mn::size_t |
using | const_reference = const value_type & |
using | const_pointer = const value_type * |
using | iterator_category = random_access_iterator_tag |
using | difference_type = ptrdiff_t |
using | iterator = pointer |
using | const_iterator = const value_type * |
Public Member Functions | |
buffer (const size_type &size) | |
Consructs and allocates the Buffer. More... | |
buffer (pointer buffer, size_type size) | |
Consructs the buffer from a given memory pointer. More... | |
buffer (const_pointer buffer, size_type size) | |
Consructs and allocates the Buffer. copies the contents of the supplied memory into the buffer. More... | |
buffer (const self_type &other) | |
Move constructor. More... | |
~buffer () | |
Deconstrut the buffer. Is allocated the memory by buffer, then deallocated it. More... | |
iterator | begin () |
Get the iterator to the beginning of the buffer. More... | |
const_iterator | begin () const |
Get the iterator to the beginning of the buffer. More... | |
iterator | end () |
Get the iterator to end of the buffer. More... | |
const_iterator | end () const |
Get the iterator to end of the buffer. More... | |
void | append (const_pointer pBuffer, std::size_t sBufferSize) |
Resizes this buffer and appends the given data. More... | |
void | append (value_type value) |
Resizes this buffer and appends the given data. More... | |
void | append (const self_type &refBuffer) |
Resizes this buffer and appends the given data. More... | |
bool | resize (size_type newSize, bool bReserve=true) |
Resizes the buffer capacity and size. More... | |
bool | change_size (size_type newSize, bool bReserve=true) |
Change the buffer size. More... | |
void | assign (const_pointer pBuffer, size_type size) |
Assigns the argument buffer to this buffer. More... | |
void | clear () |
Clear the used content. More... | |
bool | is_equel (const buffer &other) const |
Is the given buffer equel with this? More... | |
constexpr bool | is_empty () const noexcept |
is the buffer empty? More... | |
constexpr bool | is_full () const noexcept |
is the buffer full? More... | |
constexpr size_type | get_size () const noexcept |
Get the allocated memory size in elements. More... | |
constexpr size_type | get_size_bytes () const noexcept |
Get the allocated memory size in bytes. More... | |
constexpr size_type | get_used () const noexcept |
Get the used size of the buffer in elements. More... | |
constexpr size_type | get_used_bytes () const noexcept |
Get the used size of the buffer in bytes. More... | |
bool | operator== (const buffer &other) const |
Compare operator. More... | |
bool | operator!= (const buffer &other) const |
Not compare operator. More... | |
reference | operator[] (size_type index) |
const_reference | operator[] (size_type index) const |
Private Member Functions | |
void | init_internal_buffer () |
void | init_internal_buffer (const pointer buffer) |
void | destroy_internal_buffer () |
Private Attributes | |
size_type | m_sSize |
size_type | m_sUsed |
pointer | m_pRawBuffer |
bool | m_bOwnMem |
allocator | m_allocator |
Detailed Description
template<typename TVALUE, class TALLOCATOR = memory::default_allocator>
class mn::buffer< TVALUE, TALLOCATOR >
A buffer class that allocates a buffer of a given type and size.
- Note
- Useful for temporery buffering data.
Member Typedef Documentation
◆ allocator
using mn::buffer< TVALUE, TALLOCATOR >::allocator = TALLOCATOR |
◆ const_iterator
using mn::buffer< TVALUE, TALLOCATOR >::const_iterator = const value_type* |
◆ const_pointer
using mn::buffer< TVALUE, TALLOCATOR >::const_pointer = const value_type* |
◆ const_reference
using mn::buffer< TVALUE, TALLOCATOR >::const_reference = const value_type& |
◆ difference_type
using mn::buffer< TVALUE, TALLOCATOR >::difference_type = ptrdiff_t |
◆ iterator
using mn::buffer< TVALUE, TALLOCATOR >::iterator = pointer |
◆ iterator_category
using mn::buffer< TVALUE, TALLOCATOR >::iterator_category = random_access_iterator_tag |
◆ pointer
using mn::buffer< TVALUE, TALLOCATOR >::pointer = value_type* |
◆ reference
using mn::buffer< TVALUE, TALLOCATOR >::reference = value_type& |
◆ self_type
using mn::buffer< TVALUE, TALLOCATOR >::self_type = buffer<TVALUE, TALLOCATOR> |
◆ size_type
using mn::buffer< TVALUE, TALLOCATOR >::size_type = mn::size_t |
◆ value_type
using mn::buffer< TVALUE, TALLOCATOR >::value_type = TVALUE |
Constructor & Destructor Documentation
◆ buffer() [1/4]
|
inline |
Consructs and allocates the Buffer.
- Parameters
-
size The size of the buffer
◆ buffer() [2/4]
|
inline |
Consructs the buffer from a given memory pointer.
- Parameters
-
size The size of the buffer buffer The using pointer for this buffer
- Note
- This pointer not deallocated, from buffer on deconstruction
◆ buffer() [3/4]
|
inline |
Consructs and allocates the Buffer. copies the contents of the supplied memory into the buffer.
- Parameters
-
size The size of the buffer buffer The using pointer for this buffer
◆ buffer() [4/4]
|
inline |
Move constructor.
◆ ~buffer()
|
inline |
Deconstrut the buffer. Is allocated the memory by buffer, then deallocated it.
Member Function Documentation
◆ append() [1/3]
|
inline |
Resizes this buffer and appends the given data.
- Parameters
-
refBuffer The other buffer to append.
◆ append() [2/3]
|
inline |
Resizes this buffer and appends the given data.
- Parameters
-
pBuffer The array of data to append. sBufferSize The number elements in the array.
◆ append() [3/3]
|
inline |
Resizes this buffer and appends the given data.
- Parameters
-
value The value to append.
◆ assign()
|
inline |
Assigns the argument buffer to this buffer.
- Note
- If necessary, resizes the buffer.
◆ begin() [1/2]
|
inline |
Get the iterator to the beginning of the buffer.
- Returns
- The iterator to the beginning of the buffer.
◆ begin() [2/2]
|
inline |
Get the iterator to the beginning of the buffer.
- Returns
- The iterator to the beginning of the buffer.
◆ change_size()
|
inline |
Change the buffer size.
- Note
- Externally memory can not change.
- Parameters
-
newSize The new size for this buffer. bReserve If true then the content of the old buffer is copied over to the new buffer.
◆ clear()
|
inline |
Clear the used content.
◆ destroy_internal_buffer()
|
inlineprivate |
◆ end() [1/2]
|
inline |
Get the iterator to end of the buffer.
- Returns
- The iterator to end of the buffer.
◆ end() [2/2]
|
inline |
Get the iterator to end of the buffer.
- Returns
- The iterator to end of the buffer.
◆ get_size()
|
inlineconstexprnoexcept |
Get the allocated memory size in elements.
- Returns
- The allocated memory size in elements.
◆ get_size_bytes()
|
inlineconstexprnoexcept |
Get the allocated memory size in bytes.
- Returns
- The allocated memory size in bytes.
◆ get_used()
|
inlineconstexprnoexcept |
Get the used size of the buffer in elements.
- Returns
- The used size of the buffer in elements.
◆ get_used_bytes()
|
inlineconstexprnoexcept |
Get the used size of the buffer in bytes.
- Returns
- The used size of the buffer in bytes.
◆ init_internal_buffer() [1/2]
|
inlineprivate |
◆ init_internal_buffer() [2/2]
|
inlineprivate |
◆ is_empty()
|
inlineconstexprnoexcept |
is the buffer empty?
- Returns
- If true then is the buffer empty and if false then not.
◆ is_equel()
|
inline |
Is the given buffer equel with this?
- Parameters
-
other Reference to the comparing buffer
- Returns
- true The given buffer is equel with this, false when not.
◆ is_full()
|
inlineconstexprnoexcept |
is the buffer full?
- Returns
- If true then is the buffer full and if false then not.
◆ operator!=()
|
inline |
Not compare operator.
◆ operator==()
|
inline |
Compare operator.
◆ operator[]() [1/2]
|
inline |
◆ operator[]() [2/2]
|
inline |
◆ resize()
|
inline |
Resizes the buffer capacity and size.
- Note
- Externally memory can not resize.
- Parameters
-
newSize The new size for this buffer. bReserve If true then the content of the old buffer is copied over to the new buffer.
Member Data Documentation
◆ m_allocator
|
private |
◆ m_bOwnMem
|
private |
◆ m_pRawBuffer
|
private |
◆ m_sSize
|
private |
◆ m_sUsed
|
private |
The documentation for this class was generated from the following file: