|
PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
|
Lightweight cursor for parsing a big-endian byte buffer without copies. More...
#include <wire.h>
Collaboration diagram for profinet::wire::Reader:Public Member Functions | |
| Reader (const std::uint8_t *data, std::size_t len) | |
| Construct a reader over a raw pointer/length pair. | |
| Reader (std::span< const std::uint8_t > bytes) | |
| Construct a reader over a byte span. | |
| Reader (const std::vector< std::uint8_t > &v) | |
| Construct a reader over an existing byte vector. | |
| std::size_t | Remaining () const |
| Number of bytes not yet consumed. | |
| std::size_t | Position () const |
| Current read offset from the start of the buffer. | |
| const std::uint8_t * | Cursor () const |
| Pointer to the next unread byte. | |
| void | Need (std::size_t n) const |
Assert that at least n bytes remain. | |
| std::uint8_t | U8 () |
| Read and consume one byte. | |
| std::uint16_t | U16 () |
| Read and consume a big-endian 16-bit value. | |
| std::uint32_t | U32 () |
| Read and consume a big-endian 32-bit value. | |
| std::uint16_t | U16LittleEndian () |
| Read and consume a little-endian 16-bit value. | |
| std::uint32_t | U32LittleEndian () |
| Read and consume a little-endian 32-bit value. | |
| std::vector< std::uint8_t > | ReadBytes (std::size_t n) |
| Read and consume a variable-length byte range. | |
| template<std::size_t N> | |
| std::array< std::uint8_t, N > | Fixed () |
| Read and consume a fixed-size byte array. | |
| void | Skip (std::size_t n) |
| Advance the read position without returning the skipped bytes. | |
| void | SkipTo (std::size_t offset) |
| Move the read position to an absolute byte offset. | |
Private Attributes | |
| const std::uint8_t * | data |
| Pointer to the start of the underlying buffer (not owned). | |
| std::size_t | len |
| Total length of the underlying buffer in bytes. | |
| std::size_t | pos = 0 |
| Current read offset from the start of the buffer. | |
Lightweight cursor for parsing a big-endian byte buffer without copies.
Every read method advances the internal position and throws std::out_of_range if the buffer doesn't have enough remaining bytes.
|
inline |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
Pointer to the next unread byte.
Definition at line 232 of file wire.h.
Referenced by profinet::wire::TEST().
Here is the caller graph for this function:
|
inline |
Read and consume a fixed-size byte array.
| N | Number of bytes to read. |
Definition at line 316 of file wire.h.
References data, Need(), and pos.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription(), profinet::rpc::RPCCon::EpmLookup(), profinet::EthernetHeader::Parse(), profinet::EthernetVLANHeader::Parse(), profinet::PNRPCHeader::Parse(), profinet::PNIODHeader::Parse(), profinet::PNARBlockRequest::Parse(), profinet::PNIODReleaseBlock::Parse(), profinet::PNInM0::Parse(), profinet::PNInM1::Parse(), profinet::PNInM2::Parse(), profinet::PNInM3::Parse(), profinet::PNInM4::Parse(), profinet::PNInM5::Parse(), profinet::PNInMReserved< Idx >::Parse(), profinet::PNIOCRBlockRes::Parse(), profinet::PNIOCRBlockReqHeader::Parse(), profinet::PNAlarmCRBlockReq::Parse(), profinet::PNAlarmCRBlockRes::Parse(), profinet::PNAlarmNotificationPDU::Parse(), profinet::PNIODWriteRes::Parse(), profinet::sim::VirtualProfinetRpcDevice::ParseArIdentity(), profinet::rpc::ParseEpmTower(), profinet::rpc::raw::ParseRawRpcHeader(), profinet::TEST(), profinet::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::TEST_F(), and profinet::rpc::UuidBytesToString().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Assert that at least n bytes remain.
| n | Number of bytes required. |
Throws std::out_of_range if fewer than n bytes remain.
Definition at line 240 of file wire.h.
References Remaining().
Referenced by Fixed(), ReadBytes(), Skip(), profinet::wire::TEST(), profinet::wire::TEST(), U16(), U16LittleEndian(), U32(), U32LittleEndian(), and U8().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Current read offset from the start of the buffer.
Definition at line 225 of file wire.h.
References pos.
Referenced by profinet::diagnosis::ParseDiagnosisBlock(), profinet::SkipVlanTags(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), and profinet::wire::TEST().
Here is the caller graph for this function:
|
inline |
Read and consume a variable-length byte range.
| n | Number of bytes to read. |
n bytes. Definition at line 304 of file wire.h.
References data, Need(), and pos.
Referenced by profinet::rt::RTFrame::FromBytes(), profinet::EthernetHeader::Parse(), profinet::EthernetVLANHeader::Parse(), profinet::PNDCPHeader::Parse(), profinet::PNDCPBlockRequest::Parse(), profinet::PNDCPBlock::Parse(), profinet::PNRPCHeader::Parse(), profinet::PNNRDData::Parse(), profinet::PNIODHeader::Parse(), profinet::PNARBlockRequest::Parse(), profinet::PNInM0::Parse(), profinet::PNInM1::Parse(), profinet::PNInM2::Parse(), profinet::PNInM3::Parse(), profinet::PNInM5::Parse(), profinet::PNInMReserved< Idx >::Parse(), profinet::PNAlarmNotificationPDU::Parse(), profinet::PNRTAHeader::Parse(), profinet::rpc::ParseEpmTower(), profinet::TEST(), profinet::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), and profinet::wire::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Number of bytes not yet consumed.
Definition at line 218 of file wire.h.
Referenced by profinet::rt::RTFrame::FromBytes(), Need(), profinet::EthernetHeader::Parse(), profinet::EthernetVLANHeader::Parse(), profinet::PNDCPHeader::Parse(), profinet::PNDCPBlockRequest::Parse(), profinet::PNDCPBlock::Parse(), profinet::PNRPCHeader::Parse(), profinet::PNNRDData::Parse(), profinet::PNIODHeader::Parse(), profinet::PNARBlockRequest::Parse(), profinet::PNInMReserved< Idx >::Parse(), profinet::PNAlarmNotificationPDU::Parse(), profinet::PNRTAHeader::Parse(), profinet::rpc::ParseEpmTower(), profinet::blocks::ParseModuleDiffBlock(), profinet::blocks::ParseRealIdentificationData(), profinet::SkipVlanTags(), profinet::TEST(), profinet::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), and profinet::wire::TEST().
Here is the caller graph for this function:
|
inline |
Advance the read position without returning the skipped bytes.
| n | Number of bytes to skip. |
Definition at line 330 of file wire.h.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription(), profinet::rt::ParseEthernetFrame(), profinet::blocks::ParseModuleDiffBlock(), profinet::blocks::ParseMultipleBlockHeader(), profinet::dcp::ParseSetResponse(), profinet::blocks::ParseWriteMultipleResponse(), profinet::dcp::ReadResponse(), profinet::dcp::ReceiveHello(), profinet::dcp::RecvSetResponse(), profinet::SkipVlanTags(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), TEST_F(), TEST_F(), and TEST_F().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Move the read position to an absolute byte offset.
| offset | Zero-based byte offset from the start of the buffer. |
The requested offset must be within the buffer. Moving to exactly the end of the buffer is valid and leaves no bytes remaining.
| std::out_of_range | if offset is greater than the buffer length. |
Definition at line 343 of file wire.h.
Referenced by profinet::rpc::RPCCon::ApplicationReady(), profinet::rpc::RPCCon::EpmLookup(), profinet::sim::VirtualProfinetRpcDevice::HandleControl(), profinet::AlarmListener::HandleLayer2Frame(), profinet::PNBlockHeader::Parse(), profinet::ParseAlarmItem(), profinet::sim::VirtualProfinetRpcDevice::ParseArIdentity(), profinet::diagnosis::ParseDiagnosisBlock(), profinet::diagnosis::ParseDiagnosisSimple(), profinet::rpc::ParseEpmTower(), profinet::rt::ParseEthernetFrame(), profinet::blocks::ParsePdPortDataReal(), profinet::rpc::raw::ParseRawRpcHeader(), profinet::blocks::ParseWriteMultipleResponse(), profinet::rpc::PeekBlockHeader(), profinet::cyclic::CyclicController::ProcessInputFrame(), profinet::SkipVlanTags(), profinet::CyclicCaptureTests::TEST(), profinet::dcp::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), profinet::rpc::TEST_F(), and profinet::rpc::TEST_F().
Here is the caller graph for this function:
|
inline |
Read and consume a big-endian 16-bit value.
Definition at line 258 of file wire.h.
References data, Need(), and pos.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription(), profinet::rpc::RPCCon::ApplicationReady(), profinet::rt::RTFrame::FromBytes(), profinet::sim::VirtualProfinetRpcDevice::HandleControl(), profinet::AlarmListener::HandleLayer2Frame(), profinet::EthernetHeader::Parse(), profinet::EthernetVLANHeader::Parse(), profinet::PNDCPHeader::Parse(), profinet::PNDCPBlockRequest::Parse(), profinet::PNDCPBlock::Parse(), profinet::PNRPCHeader::Parse(), profinet::PNIODHeader::Parse(), profinet::PNBlockHeader::Parse(), profinet::PNARBlockRequest::Parse(), profinet::PNIODReleaseBlock::Parse(), profinet::PNInM0::Parse(), profinet::IOCRAPIObject::Parse(), profinet::PNIOCRBlockRes::Parse(), profinet::PNIOCRBlockReqHeader::Parse(), profinet::PNAlarmCRBlockReq::Parse(), profinet::PNAlarmCRBlockRes::Parse(), profinet::PNAlarmNotificationPDU::Parse(), profinet::PNRTAHeader::Parse(), profinet::PNIODWriteRes::Parse(), profinet::ParseAlarmItem(), profinet::ParseAlarmNotification(), profinet::sim::VirtualProfinetRpcDevice::ParseArIdentity(), profinet::blocks::ParseBlockHeader(), profinet::diagnosis::ParseDiagnosisBlock(), profinet::diagnosis::ParseDiagnosisSimple(), profinet::rpc::ParseEpmTower(), profinet::rt::ParseEthernetFrame(), profinet::blocks::ParseModuleDiffBlock(), profinet::blocks::ParseMultipleBlockHeader(), profinet::blocks::ParsePdPortDataReal(), profinet::blocks::ParsePortStatistics(), profinet::rpc::raw::ParseRawRpcHeader(), profinet::blocks::ParseRealIdentificationData(), profinet::dcp::ParseSetResponse(), profinet::blocks::ParseWriteMultipleResponse(), profinet::rpc::PeekBlockHeader(), profinet::cyclic::CyclicController::ProcessInputFrame(), profinet::dcp::ReadResponse(), profinet::dcp::ReceiveHello(), profinet::dcp::RecvSetResponse(), profinet::SkipVlanTags(), profinet::CyclicCaptureTests::TEST(), profinet::dcp::TEST(), profinet::TEST(), profinet::TEST(), profinet::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), profinet::device::TEST_F(), profinet::device::TEST_F(), profinet::device::TEST_F(), and profinet::rpc::UuidBytesToString().
Here is the call graph for this function:
|
inline |
Read and consume a little-endian 16-bit value.
Definition at line 279 of file wire.h.
References data, Need(), and pos.
Referenced by profinet::rpc::RPCCon::EpmLookup(), profinet::rpc::ParseEpmTower(), profinet::rpc::raw::ParseRawRpcHeader(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), and profinet::rpc::UuidBytesToString().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Read and consume a big-endian 32-bit value.
Definition at line 268 of file wire.h.
References data, Need(), and pos.
Referenced by profinet::rpc::RPCCon::ApplicationReady(), profinet::PNDCPHeader::Parse(), profinet::PNRPCHeader::Parse(), profinet::PNNRDData::Parse(), profinet::PNIODHeader::Parse(), profinet::PNARBlockRequest::Parse(), profinet::PNIOCRBlockReqHeader::Parse(), profinet::PNAlarmCRBlockReq::Parse(), profinet::PNAlarmNotificationPDU::Parse(), profinet::PNIODWriteRes::Parse(), profinet::ParseAlarmNotification(), profinet::diagnosis::ParseDiagnosisBlock(), profinet::blocks::ParseModuleDiffBlock(), profinet::blocks::ParseMultipleBlockHeader(), profinet::blocks::ParsePdPortDataReal(), profinet::blocks::ParsePortStatistics(), profinet::rpc::raw::ParseRawRpcHeader(), profinet::blocks::ParseRealIdentificationData(), profinet::blocks::ParseWriteMultipleResponse(), profinet::wire::TEST(), profinet::wire::TEST(), and TEST_F().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Read and consume a little-endian 32-bit value.
Definition at line 291 of file wire.h.
References data, Need(), and pos.
Referenced by profinet::rpc::RPCCon::ApplicationReady(), profinet::rpc::RPCCon::EpmLookup(), profinet::rpc::raw::ParseRawRpcHeader(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::rpc::TEST_F(), profinet::rpc::TEST_F(), and profinet::rpc::UuidBytesToString().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Read and consume one byte.
Definition at line 250 of file wire.h.
References data, Need(), and pos.
Referenced by profinet::dcp::DCPDeviceDescription::DCPDeviceDescription(), profinet::rt::RTFrame::FromBytes(), profinet::PNDCPHeader::Parse(), profinet::PNDCPBlockRequest::Parse(), profinet::PNDCPBlock::Parse(), profinet::PNRPCHeader::Parse(), profinet::PNBlockHeader::Parse(), profinet::PNInM0::Parse(), profinet::PNRTAHeader::Parse(), profinet::blocks::ParseBlockHeader(), profinet::rpc::raw::ParseRawRpcHeader(), profinet::TEST(), profinet::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), profinet::wire::TEST(), and profinet::wire::TEST().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Pointer to the start of the underlying buffer (not owned).
Definition at line 355 of file wire.h.
Referenced by Cursor(), Fixed(), ReadBytes(), U16(), U16LittleEndian(), U32(), U32LittleEndian(), and U8().
|
private |
Total length of the underlying buffer in bytes.
Definition at line 358 of file wire.h.
Referenced by Remaining(), and SkipTo().
|
private |
Current read offset from the start of the buffer.
Definition at line 361 of file wire.h.
Referenced by Cursor(), Fixed(), Position(), ReadBytes(), Remaining(), Skip(), SkipTo(), U16(), U16LittleEndian(), U32(), U32LittleEndian(), and U8().