Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | List of all members
jau::POctets Class Reference

Persistent endian aware octet data, i.e. More...

#include <octets.hpp>

Inheritance diagram for jau::POctets:
Collaboration diagram for jau::POctets:

Public Member Functions

 POctets (const lb_endian_t byte_order) noexcept
 Zero sized POctets instance. More...
 
 POctets (const nsize_t capacity_, const nsize_t size_, const lb_endian_t byte_order)
 New buffer (malloc(capacity), free) More...
 
 POctets (const nsize_t size, const lb_endian_t byte_order)
 New buffer (malloc, free) More...
 
 POctets (const POctets &source)
 Copy constructor. More...
 
 POctets (const POctets &source, const nsize_t capacity_)
 Copy constructor (explicit), allowing to set a higher capacity than source.size() in contrast to the copy-constructor. More...
 
 POctets (const TOctetSlice &_source)
 Makes a persistent POctets by copying the data from TOctetSlice. More...
 
 POctets (const TROOctets &_source)
 Makes a persistent POctets by copying the data from TROOctets. More...
 
 POctets (const uint8_t *source_, const nsize_t size_, const lb_endian_t byte_order)
 Takes ownership (malloc(size) and copy, free) . More...
 
 POctets (POctets &&o) noexcept
 Move constructor. More...
 
 POctets (std::initializer_list< uint8_t > sourcelist, const lb_endian_t byte_order)
 Takes ownership (malloc(size) and copy, free) . More...
 
 ~POctets () noexcept override
 
constexpr nsize_t capacity () const noexcept
 Returns the memory capacity, never zero, greater or equal size(). More...
 
POctetsoperator+= (const TOctetSlice &b)
 Append and assign operator. More...
 
POctetsoperator+= (const TROOctets &b)
 Append and assign operator. More...
 
POctetsoperator= (const POctets &_source)
 Assignment operator. More...
 
POctetsoperator= (const TOctetSlice &_source)
 Assignment operator for TOctetSlice. More...
 
POctetsoperator= (const TROOctets &_source)
 Assignment operator for TROOctets. More...
 
POctetsoperator= (POctets &&o) noexcept
 Move assignment operator. More...
 
POctetsrecapacity (const nsize_t newCapacity)
 Changes the capacity. More...
 
constexpr nsize_t remaining () const noexcept
 Returns the remaining octets for put left, i.e. More...
 
POctetsresize (const nsize_t newCapacity, const nsize_t newSize)
 Resizes this instance, including its capacity. More...
 
POctetsresize (const nsize_t newSize)
 Sets a new size for this instance. More...
 
std::string toString () const
 
- Public Member Functions inherited from jau::TOctets
 TOctets (const TOctets &o) noexcept=default
 
 TOctets (TOctets &&o) noexcept=default
 
 TOctets (uint8_t *source, const nsize_t len, const lb_endian_t byte_order) noexcept
 Transient passthrough r/w memory, w/o ownership . More...
 
 ~TOctets () noexcept override=default
 
void bzero () noexcept
 
void bzero (const nsize_t i, const nsize_t byte_count)
 
void bzero_nc (const nsize_t i, const nsize_t byte_count) noexcept
 
uint8_t * get_wptr () noexcept
 
uint8_t * get_wptr (const nsize_t i)
 
uint8_t * get_wptr_nc (const nsize_t i) noexcept
 
void memmove (const nsize_t i, const uint8_t *source, const nsize_t byte_count)
 
void memmove_nc (const nsize_t i, const uint8_t *source, const nsize_t byte_count) noexcept
 
void memset (const nsize_t i, const uint8_t c, const nsize_t byte_count)
 
void memset_nc (const nsize_t i, const uint8_t c, const nsize_t byte_count) noexcept
 
TOctetsoperator= (const TOctets &o) noexcept=default
 
TOctetsoperator= (TOctets &&o) noexcept=default
 
void put_bytes (const nsize_t i, const uint8_t *source, const nsize_t byte_count)
 
void put_bytes_nc (const nsize_t i, const uint8_t *source, const nsize_t byte_count) noexcept
 
void put_eui48 (const nsize_t i, const EUI48 &v)
 
void put_eui48_nc (const nsize_t i, const EUI48 &v) noexcept
 
void put_int8 (const nsize_t i, const int8_t v)
 
constexpr void put_int8_nc (const nsize_t i, const int8_t v) noexcept
 
void put_octets (const nsize_t i, const TROOctets &v)
 
void put_octets (const nsize_t i, const TROOctets &v, const nsize_t v_off, const nsize_t v_len) noexcept
 
void put_octets_nc (const nsize_t i, const TROOctets &v) noexcept
 
void put_octets_nc (const nsize_t i, const TROOctets &v, const nsize_t v_off, const nsize_t v_len) noexcept
 
void put_string (const nsize_t i, const std::string &v, const nsize_t max_len, const bool includeEOS)
 
void put_string_nc (const nsize_t i, const std::string &v, const nsize_t max_len, const bool includeEOS) noexcept
 
void put_uint128 (const nsize_t i, const uint128dp_t &v)
 
constexpr void put_uint128_nc (const nsize_t i, const uint128dp_t &v) noexcept
 
void put_uint16 (const nsize_t i, const uint16_t v)
 
constexpr void put_uint16_nc (const nsize_t i, const uint16_t v) noexcept
 
void put_uint192 (const nsize_t i, const uint192dp_t &v)
 
constexpr void put_uint192_nc (const nsize_t i, const uint192dp_t &v) noexcept
 
void put_uint256 (const nsize_t i, const uint256dp_t &v)
 
constexpr void put_uint256_nc (const nsize_t i, const uint256dp_t &v) noexcept
 
void put_uint32 (const nsize_t i, const uint32_t v)
 
constexpr void put_uint32_nc (const nsize_t i, const uint32_t v) noexcept
 
void put_uint64 (const nsize_t i, const uint64_t &v)
 
constexpr void put_uint64_nc (const nsize_t i, const uint64_t &v) noexcept
 
void put_uint8 (const nsize_t i, const uint8_t v)
 
constexpr void put_uint8_nc (const nsize_t i, const uint8_t v) noexcept
 
void put_uuid (const nsize_t i, const uuid_t &v)
 
void put_uuid_nc (const nsize_t i, const uuid_t &v) noexcept
 
std::string toString () const noexcept
 
- Public Member Functions inherited from jau::TROOctets
 TROOctets () noexcept
 Default constructor with nullptr memory, zero size and lb_endian::native byte order. More...
 
 TROOctets (const TROOctets &o) noexcept=default
 
 TROOctets (const uint8_t *source, const nsize_t len, const lb_endian_t byte_order_val) noexcept
 Transient passthrough read-only memory, w/o ownership . More...
 
 TROOctets (TROOctets &&o) noexcept=default
 
virtual ~TROOctets () noexcept=default
 
constexpr lb_endian_t byte_order () const noexcept
 Returns byte order of this octet store. More...
 
void check_range (const nsize_t i, const nsize_t count, const char *file, int line) const
 
EUI48 get_eui48 (const nsize_t i) const
 
EUI48 get_eui48_nc (const nsize_t i) const noexcept
 
int8_t get_int8 (const nsize_t i) const
 
constexpr int8_t get_int8_nc (const nsize_t i) const noexcept
 
constexpr uint8_t const * get_ptr () const noexcept
 
uint8_t const * get_ptr (const nsize_t i) const
 
constexpr uint8_t const * get_ptr_nc (const nsize_t i) const noexcept
 
std::string get_string (const nsize_t i) const
 Assumes a null terminated string. More...
 
std::string get_string (const nsize_t i, const nsize_t length) const
 Assumes a string with defined length, not necessarily null terminated. More...
 
std::string get_string_nc (const nsize_t i) const noexcept
 Assumes a null terminated string. More...
 
uint128dp_t get_uint128 (const nsize_t i) const
 
constexpr uint128dp_t get_uint128_nc (const nsize_t i) const noexcept
 
uint16_t get_uint16 (const nsize_t i) const
 
constexpr uint16_t get_uint16_nc (const nsize_t i) const noexcept
 
uint192dp_t get_uint192 (const nsize_t i) const
 
constexpr uint192dp_t get_uint192_nc (const nsize_t i) const noexcept
 
uint256dp_t get_uint256 (const nsize_t i) const
 
constexpr uint256dp_t get_uint256_nc (const nsize_t i) const noexcept
 
uint32_t get_uint32 (const nsize_t i) const
 
constexpr uint32_t get_uint32_nc (const nsize_t i) const noexcept
 
uint64_t get_uint64 (const nsize_t i) const
 
constexpr uint64_t get_uint64_nc (const nsize_t i) const noexcept
 
uint8_t get_uint8 (const nsize_t i) const
 
constexpr uint8_t get_uint8_nc (const nsize_t i) const noexcept
 
std::unique_ptr< const uuid_tget_uuid (const nsize_t i, const uuid_t::TypeSize tsize) const
 
uuid128_t get_uuid128 (const nsize_t i) const
 
uuid128_t get_uuid128_nc (const nsize_t i) const noexcept
 
uuid16_t get_uuid16 (const nsize_t i) const
 
uuid16_t get_uuid16_nc (const nsize_t i) const noexcept
 
constexpr bool is_range_valid (const nsize_t i, const nsize_t count) const noexcept
 
bool operator!= (const TROOctets &rhs) const noexcept
 
TROOctetsoperator= (const TROOctets &o) noexcept=default
 
TROOctetsoperator= (TROOctets &&o) noexcept=default
 
bool operator== (const TROOctets &rhs) const noexcept
 
constexpr nsize_t size () const noexcept
 Returns the used memory size for read and write operations, may be zero. More...
 
std::string toString () const noexcept
 

Additional Inherited Members

- Protected Member Functions inherited from jau::TROOctets
constexpr uint8_t * data () noexcept
 
void setData (uint8_t *data_, nsize_t size_, const lb_endian_t byte_order) noexcept
 Internally sets the _size and _data fields after validation. More...
 
constexpr void setSize (nsize_t s) noexcept
 
- Static Protected Member Functions inherited from jau::TROOctets
static void checkPtr (uint8_t *data_, nsize_t size_) noexcept
 Validates the given data_ and size_. More...
 

Detailed Description

Persistent endian aware octet data, i.e.

owned memory allocation.

Endian byte order is passed at construction.

Constructor and assignment operations are not completely noexcept and may throw exceptions. This is a design choice based on dynamic resource allocation performed by this class.

Examples
dbt_peripheral00.cpp, and dbt_scanner10.cpp.

Definition at line 559 of file octets.hpp.

Constructor & Destructor Documentation

◆ POctets() [1/10]

jau::POctets::POctets ( const lb_endian_t  byte_order)
inlinenoexcept

Zero sized POctets instance.

Will not throw an OutOfMemoryError exception due to no allocation.

Parameters
byte_orderlb_endian::little or lb_endian::big byte order, one may pass lb_endian::native.

Definition at line 603 of file octets.hpp.

◆ POctets() [2/10]

jau::POctets::POctets ( const uint8_t *  source_,
const nsize_t  size_,
const lb_endian_t  byte_order 
)
inline

Takes ownership (malloc(size) and copy, free) .

Capacity and size will be of given source size.

Parameters
source_source data to be copied into this new instance
size_length of source data
byte_orderlb_endian::little or lb_endian::big byte order, one may pass lb_endian::native.
Exceptions
IllegalArgumentExceptionif source_ is nullptr and size_ > 0
OutOfMemoryErrorif allocation fails

Definition at line 620 of file octets.hpp.

◆ POctets() [3/10]

jau::POctets::POctets ( std::initializer_list< uint8_t >  sourcelist,
const lb_endian_t  byte_order 
)
inline

Takes ownership (malloc(size) and copy, free) .

Capacity and size will be of given source size.

Parameters
sourcelistsource initializer list data to be copied into this new instance with implied size
byte_orderlb_endian::little or lb_endian::big byte order, one may pass lb_endian::native.
Exceptions
IllegalArgumentExceptionif source_ is nullptr and size_ > 0
OutOfMemoryErrorif allocation fails

Definition at line 643 of file octets.hpp.

◆ POctets() [4/10]

jau::POctets::POctets ( const nsize_t  capacity_,
const nsize_t  size_,
const lb_endian_t  byte_order 
)
inline

New buffer (malloc(capacity), free)

Parameters
capacity_new capacity
size_new size with size <= capacity
byte_orderlb_endian::little or lb_endian::big byte order, one may pass lb_endian::native.
Exceptions
IllegalArgumentExceptionif capacity_ < size_
OutOfMemoryErrorif allocation fails

Definition at line 662 of file octets.hpp.

◆ POctets() [5/10]

jau::POctets::POctets ( const nsize_t  size,
const lb_endian_t  byte_order 
)
inline

New buffer (malloc, free)

Parameters
sizenew size and capacity
byte_orderlb_endian::little or lb_endian::big byte order, one may pass lb_endian::native.
Exceptions
OutOfMemoryErrorif allocation fails

Definition at line 679 of file octets.hpp.

◆ POctets() [6/10]

jau::POctets::POctets ( const POctets source)
inline

Copy constructor.

Capacity of this new instance will be of source.size() only.

Parameters
sourcePOctet source to be copied
Exceptions
OutOfMemoryErrorif allocation fails

Definition at line 693 of file octets.hpp.

◆ POctets() [7/10]

jau::POctets::POctets ( const POctets source,
const nsize_t  capacity_ 
)
inlineexplicit

Copy constructor (explicit), allowing to set a higher capacity than source.size() in contrast to the copy-constructor.

Parameters
sourcePOctet source to be copied
capacity_used to determine new capacity std::max(capacity_, source.size())
Exceptions
OutOfMemoryErrorif allocation fails

Definition at line 709 of file octets.hpp.

◆ POctets() [8/10]

jau::POctets::POctets ( POctets &&  o)
inlinenoexcept

Move constructor.

Parameters
oPOctet source to be taken over

Definition at line 721 of file octets.hpp.

◆ ~POctets()

jau::POctets::~POctets ( )
inlineoverridenoexcept

Definition at line 766 of file octets.hpp.

◆ POctets() [9/10]

jau::POctets::POctets ( const TROOctets _source)
inline

Makes a persistent POctets by copying the data from TROOctets.

Parameters
_sourceTROOctets to be copied
Exceptions
OutOfMemoryErrorif allocation fails

Definition at line 777 of file octets.hpp.

◆ POctets() [10/10]

jau::POctets::POctets ( const TOctetSlice _source)
inline

Makes a persistent POctets by copying the data from TOctetSlice.

Parameters
_sourceTROOctetSlice to be copied
Exceptions
OutOfMemoryErrorif allocation fails

Definition at line 808 of file octets.hpp.

Member Function Documentation

◆ capacity()

constexpr nsize_t jau::POctets::capacity ( ) const
inlineconstexprnoexcept

Returns the memory capacity, never zero, greater or equal size().

Definition at line 591 of file octets.hpp.

Here is the caller graph for this function:

◆ remaining()

constexpr nsize_t jau::POctets::remaining ( ) const
inlineconstexprnoexcept

Returns the remaining octets for put left, i.e.

capacity() - size().

Definition at line 594 of file octets.hpp.

◆ operator=() [1/4]

POctets & jau::POctets::operator= ( const POctets _source)
inline

Assignment operator.

Parameters
_sourcePOctet source to be copied
Returns
Exceptions
OutOfMemoryErrorif allocation fails

Definition at line 738 of file octets.hpp.

◆ operator=() [2/4]

POctets & jau::POctets::operator= ( POctets &&  o)
inlinenoexcept

Move assignment operator.

Parameters
oPOctet source to be taken over
Returns

Definition at line 755 of file octets.hpp.

◆ operator=() [3/4]

POctets & jau::POctets::operator= ( const TROOctets _source)
inline

Assignment operator for TROOctets.

Parameters
_sourceTROOctets to be copied
Returns
Exceptions
OutOfMemoryErrorif allocation fails

Definition at line 791 of file octets.hpp.

◆ operator=() [4/4]

POctets & jau::POctets::operator= ( const TOctetSlice _source)
inline

Assignment operator for TOctetSlice.

Parameters
_sourceTOctetSlice to be copied
Returns
Exceptions
OutOfMemoryErrorif allocation fails

Definition at line 822 of file octets.hpp.

◆ resize() [1/2]

POctets & jau::POctets::resize ( const nsize_t  newCapacity,
const nsize_t  newSize 
)
inline

Resizes this instance, including its capacity.

Parameters
newCapacitynew capacity, must be >= newSize
newSizenew size, must be < newCapacity
Returns
Exceptions
OutOfMemoryErrorif allocation fails
IllegalArgumentExceptionif newCapacity < newSize

Definition at line 839 of file octets.hpp.

Here is the caller graph for this function:

◆ resize() [2/2]

POctets & jau::POctets::resize ( const nsize_t  newSize)
inline

Sets a new size for this instance.

Parameters
newSizenew size, must be <= current capacity()
Returns
Exceptions
IllegalArgumentExceptionif newSize > current capacity()

Definition at line 863 of file octets.hpp.

◆ recapacity()

POctets & jau::POctets::recapacity ( const nsize_t  newCapacity)
inline

Changes the capacity.

Parameters
newCapacitynew capacity, must be >= size()
Returns
Exceptions
OutOfMemoryErrorif allocation fails
IllegalArgumentExceptionif newCapacity < size()

Definition at line 879 of file octets.hpp.

Here is the caller graph for this function:

◆ operator+=() [1/2]

POctets & jau::POctets::operator+= ( const TROOctets b)
inline

Append and assign operator.

Parameters
b
Returns
Exceptions
OutOfMemoryErrorif allocation due to potential recapacity() fails

Definition at line 903 of file octets.hpp.

◆ operator+=() [2/2]

POctets & jau::POctets::operator+= ( const TOctetSlice b)
inline

Append and assign operator.

Parameters
b
Returns
Exceptions
OutOfMemoryErrorif allocation due to potential recapacity() fails

Definition at line 920 of file octets.hpp.

◆ toString()

std::string jau::POctets::toString ( ) const
inline
Examples
dbt_peripheral00.cpp.

Definition at line 932 of file octets.hpp.

Here is the caller graph for this function:

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