PcapPlusPlus  Next
pcpp::PacketSerializer Class Reference

#include <PacketUtils.h>

Public Member Functions

 PacketSerializer (ISerializer &serializer)
 
void addPacket (const Packet &packet)
 
void addPacket (const Packet *packet)
 
void addPackets (const PointerVector< Packet > &packets)
 
void addPackets (const std::vector< Packet > &packets)
 

Detailed Description

Serializes a collection of packets into a single array. The array is opened immediately in the constructor and closed when the PacketSerializer is destroyed, so all packets must be added within its lifetime. Not copyable, since copying would either double-write the array or leave one copy's array permanently unclosed.

Constructor & Destructor Documentation

◆ PacketSerializer()

pcpp::PacketSerializer::PacketSerializer ( ISerializer &  serializer)
inlineexplicit

Opens the "packets" array field on the given serializer.

Parameters
[in]serializerThe serializer to write the array into

Member Function Documentation

◆ addPacket() [1/2]

void pcpp::PacketSerializer::addPacket ( const Packet &  packet)

Serializes one packet and appends it to the array.

Parameters
[in]packetThe packet to add

◆ addPacket() [2/2]

void pcpp::PacketSerializer::addPacket ( const Packet *  packet)

Serializes one packet and appends it to the array.

Parameters
[in]packetThe packet to add

◆ addPackets() [1/2]

void pcpp::PacketSerializer::addPackets ( const PointerVector< Packet > &  packets)

Serializes every packet in the vector and appends them to the array, in order.

Parameters
[in]packetsThe packets to add

◆ addPackets() [2/2]

void pcpp::PacketSerializer::addPackets ( const std::vector< Packet > &  packets)

Serializes every packet in the vector and appends them to the array, in order.

Parameters
[in]packetsThe packets to add