BCNP 3.2.1
Batched Command Network Protocol
Loading...
Searching...
No Matches
bcnp::MessageIterator< MsgType > Class Template Reference

Forward iterator for zero-copy message access from packet payload. More...

#include <packet.h>

Public Types

using iterator_category = std::forward_iterator_tag
 
using value_type = MsgType
 
using difference_type = std::ptrdiff_t
 
using pointer = const MsgType*
 
using reference = MsgType
 

Public Member Functions

 MessageIterator (const uint8_t *ptr, std::size_t count)
 Construct iterator at a position in the payload.
 
MsgType operator* () const
 Decode and return the current message.
 
MessageIteratoroperator++ ()
 Advance to the next message (pre-increment).
 
MessageIterator operator++ (int)
 Advance to the next message (post-increment).
 
bool operator== (const MessageIterator &other) const
 Equality comparison (end iterators compare equal).
 
bool operator!= (const MessageIterator &other) const
 Inequality comparison.
 

Detailed Description

template<typename MsgType>
class bcnp::MessageIterator< MsgType >

Forward iterator for zero-copy message access from packet payload.

Allows iterating over messages in a PacketView without copying them to intermediate storage. Each dereference decodes the message on-the-fly from the raw wire bytes.

Template Parameters
MsgTypeThe message struct type (must have Decode() and kWireSize)
for (auto it = view.begin_as<DriveCmd>(); it != view.end_as<DriveCmd>(); ++it) {
DriveCmd cmd = *it; // Decoded on access
// Process cmd...
}

Definition at line 100 of file packet.h.

Member Typedef Documentation

◆ difference_type

template<typename MsgType >
using bcnp::MessageIterator< MsgType >::difference_type = std::ptrdiff_t

Definition at line 104 of file packet.h.

◆ iterator_category

template<typename MsgType >
using bcnp::MessageIterator< MsgType >::iterator_category = std::forward_iterator_tag

Definition at line 102 of file packet.h.

◆ pointer

template<typename MsgType >
using bcnp::MessageIterator< MsgType >::pointer = const MsgType*

Definition at line 105 of file packet.h.

◆ reference

template<typename MsgType >
using bcnp::MessageIterator< MsgType >::reference = MsgType

Definition at line 106 of file packet.h.

◆ value_type

template<typename MsgType >
using bcnp::MessageIterator< MsgType >::value_type = MsgType

Definition at line 103 of file packet.h.

Constructor & Destructor Documentation

◆ MessageIterator()

template<typename MsgType >
bcnp::MessageIterator< MsgType >::MessageIterator ( const uint8_t * ptr,
std::size_t count )
inline

Construct iterator at a position in the payload.

Parameters
ptrPointer to the first message byte
countNumber of messages remaining from this position

Definition at line 113 of file packet.h.

Member Function Documentation

◆ operator!=()

template<typename MsgType >
bool bcnp::MessageIterator< MsgType >::operator!= ( const MessageIterator< MsgType > & other) const
inline

Inequality comparison.

Definition at line 151 of file packet.h.

◆ operator*()

template<typename MsgType >
MsgType bcnp::MessageIterator< MsgType >::operator* ( ) const
inline

Decode and return the current message.

Returns
Decoded message, or default-constructed MsgType on decode failure

Definition at line 120 of file packet.h.

◆ operator++() [1/2]

template<typename MsgType >
MessageIterator & bcnp::MessageIterator< MsgType >::operator++ ( )
inline

Advance to the next message (pre-increment).

Definition at line 126 of file packet.h.

◆ operator++() [2/2]

template<typename MsgType >
MessageIterator bcnp::MessageIterator< MsgType >::operator++ ( int )
inline

Advance to the next message (post-increment).

Definition at line 138 of file packet.h.

◆ operator==()

template<typename MsgType >
bool bcnp::MessageIterator< MsgType >::operator== ( const MessageIterator< MsgType > & other) const
inline

Equality comparison (end iterators compare equal).

Definition at line 145 of file packet.h.


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