Base module

RawPacket

RawPacket is the default data packet type which consists of an optionally managed char

#include <icy/packet.h>

class RawPacket

Defined in src/base/include/icy/packet.h:182

Inherits
IPacket

RawPacket is the default data packet type which consists of an optionally managed char pointer and a size value.

List of all members

NameKindOwner
RawPacketfunctionDeclared here
RawPacketfunctionDeclared here
RawPacketfunctionDeclared here
~RawPacketfunctionDeclared here
clonefunctionDeclared here
copyDatafunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
datafunctionDeclared here
sizefunctionDeclared here
classNamefunctionDeclared here
ownsBufferfunctionDeclared here
_datavariableDeclared here
_sizevariableDeclared here
_ownedvariableDeclared here
operator<<friendInherited from IPacket
opaquevariableInherited from IPacket
infovariableInherited from IPacket
flagsvariableInherited from IPacket
IPacketfunctionInherited from IPacket
IPacketfunctionInherited from IPacket
operator=functionInherited from IPacket
clonefunctionInherited from IPacket
~IPacketfunctionInherited from IPacket
readfunctionInherited from IPacket
writefunctionInherited from IPacket
sizefunctionInherited from IPacket
hasDatafunctionInherited from IPacket
datafunctionInherited from IPacket
constDatafunctionInherited from IPacket
classNamefunctionInherited from IPacket
printfunctionInherited from IPacket

Inherited from IPacket

KindNameDescription
friendoperator<< inlineStream insertion operator; delegates to print().
variableopaqueOptional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime.
variableinfoOptional extra information about the packet.
variableflagsProvides basic information about the packet.
functionIPacket inline
functionIPacket inlineCopy constructor; clones the info object if present.
functionoperator= inlineCopy assignment; clones the info object if present.
functionclone virtual constReturns a heap-allocated deep copy of this packet.
function~IPacket virtualDefaulted destructor.
functionread virtualRead/parse to the packet from the given input buffer. The number of bytes read is returned.
functionwrite virtual constCopy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer.
functionsize virtual const inlineThe size of the packet in bytes.
functionhasData virtual const inlineReturns true if the packet has a non-null data pointer.
functiondata virtual const inlineThe packet data pointer for buffered packets.
functionconstData virtual const inlineThe const packet data pointer for buffered packets.
functionclassName virtual constReturns the class name of this packet type for logging and diagnostics.
functionprint virtual const inlinePrints a human-readable representation to the given stream.

Public Methods

ReturnNameDescription
RawPacket inlineConstruct with borrowed (non-owning) buffer.
RawPacket inlineConstruct with const data (copied, owning).
RawPacket inlineCopy constructor (always copies data).
~RawPacket virtualDefaulted destructor.
std::unique_ptr< IPacket >clone virtual const inline override
voidcopyData virtual inlineCopies data into an internally owned buffer, replacing any prior content.
ssize_tread virtual inline overrideReads from the buffer by copying its contents into an owned buffer.
voidwrite virtual const inline overrideAppends the packet data to the given output buffer.
char *data virtual const inline override
size_tsize virtual const inline override
const char *className virtual const inline overrideReturns the class name of this packet type for logging and diagnostics.
boolownsBuffer const inline

RawPacket

inline

inline RawPacket(char * data = nullptr, size_t size = 0, unsigned flags = 0, std::unique_ptr< IPacketInfo > info = nullptr)

Defined in src/base/include/icy/packet.h:186

Construct with borrowed (non-owning) buffer.


RawPacket

inline

inline RawPacket(const char * data, size_t size = 0, unsigned flags = 0, std::unique_ptr< IPacketInfo > info = nullptr)

Defined in src/base/include/icy/packet.h:195

Construct with const data (copied, owning).


RawPacket

inline

inline RawPacket(const RawPacket & that)

Defined in src/base/include/icy/packet.h:205

Copy constructor (always copies data).


~RawPacket

virtual

virtual ~RawPacket() = default

Defined in src/base/include/icy/packet.h:213

Defaulted destructor.


clone

virtual const inline override

virtual inline std::unique_ptr< IPacket > clone() const override

Defined in src/base/include/icy/packet.h:216

Returns

Owning pointer to a deep copy of this packet (always copies data).

Reimplements

Reimplemented by


copyData

virtual inline

virtual inline void copyData(const void * data, size_t size)

Defined in src/base/include/icy/packet.h:224

Copies data into an internally owned buffer, replacing any prior content.

Parameters

ParameterTypeDescription
dataconst void *Source data pointer.
sizesize_tNumber of bytes to copy.

read

virtual inline override

virtual inline ssize_t read(const ConstBuffer & buf) override

Defined in src/base/include/icy/packet.h:237

Reads from the buffer by copying its contents into an owned buffer.

Returns

Number of bytes consumed (equal to buf.size()).

Reimplements

Reimplemented by

Parameters

ParameterTypeDescription
bufconst ConstBuffer &Input buffer to read from.

write

virtual const inline override

virtual inline void write(Buffer & buf) const override

Defined in src/base/include/icy/packet.h:245

Appends the packet data to the given output buffer.

Reimplements

Reimplemented by

Parameters

ParameterTypeDescription
bufBuffer &Buffer to write into.

data

virtual const inline override

virtual inline char * data() const override

Defined in src/base/include/icy/packet.h:251

Returns

Mutable pointer to the raw packet data, or nullptr if empty.

Reimplements


size

virtual const inline override

virtual inline size_t size() const override

Defined in src/base/include/icy/packet.h:254

Returns

Size of the packet data in bytes.

Reimplements


className

virtual const inline override

virtual inline const char * className() const override

Defined in src/base/include/icy/packet.h:256

Returns the class name of this packet type for logging and diagnostics.

Reimplements

Reimplemented by


ownsBuffer

const inline

inline bool ownsBuffer() const

Defined in src/base/include/icy/packet.h:259

Returns

True if this packet owns (manages) its data buffer.

Protected Attributes

ReturnNameDescription
char *_data
size_t_size
std::unique_ptr< char[]>_owned

_data

char * _data

Defined in src/base/include/icy/packet.h:262


_size

size_t _size

Defined in src/base/include/icy/packet.h:263


_owned

std::unique_ptr< char[]> _owned

Defined in src/base/include/icy/packet.h:264