class PacketWriter
Defined at line 16 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.h
Writes values into a binary packet.
Public Members
static const size_t npos
Public Methods
void PacketWriter ()
Creates a packet writer with an empty packet vector.
Defined at line 12 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
void PacketWriter (std::vector<uint8_t> packet)
Creates a packet writer that writes to the supplied vector. The intended
pattern here is that a buffer is moved into the writer using a call like
|PacketWriter(std::move(my_buffer))| and moved back out when writing is
complete using |GetPacket|. Call |position| before calling |GetPacket| to
retrieve the size of the written data. In this way, a fixed-length buffer
may be used repeatedly without the allocations implied by creating a new
buffer or resizing an existing one. Note that the buffer *will* be resized
if it's too small to accommodate the written packet.
Defined at line 14 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
void ~PacketWriter ()
Defined at line 16 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
std::vector<uint8_t> GetResizedPacket ()
Gets the packet vector and resets this |PacketWriter| after resizing the
vector to |position()| bytes. If the caller is using the default
constructor, allowing the writer to create its own buffer, this is a
good way to get that buffer out of the writer once writing is complete.
To reuse a fixed-size buffer, use the constructor that takes a packet
parameter, |position| to get the written size and |GetPacket| to take back
the buffer.
Defined at line 18 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
template <typename T>
std::vector<uint8_t> Write (const T & t)
Defined at line 21 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.h
std::vector<uint8_t> GetPacket ()
Gets the unresized packet vector and resets this |PacketWriter|. To
get the size of the written packet, call |position()| before calling this
method.
Defined at line 25 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
void PutBytes (size_t count, const void * source)
Puts |count| bytes from |source| into the packet.
Defined at line 31 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
size_t position ()
Gets the current position.
Defined at line 43 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.h
void SetPosition (size_t position)
Sets the current position.
Defined at line 46 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.h
void CreateBookmark (const std::string & name)
Creates a bookmark for the current position.
Defined at line 47 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
size_t GetBookmarkPosition (const std::string & name)
Gets the position for a bookmark (established by calling |CreateBookmark|).
Returns |npos| if the bookmark isn't found.
Defined at line 51 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (bool value)
Defined at line 60 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (uint8_t value)
Defined at line 65 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (uint16_t value)
Defined at line 70 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (uint32_t value)
Defined at line 76 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (uint64_t value)
Defined at line 82 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (int8_t value)
Defined at line 88 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
void PacketWriter (const PacketWriter & )
Disallow copy, assign and move.
Defined at line 90 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.h
void PacketWriter (PacketWriter && )
Defined at line 91 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.h
PacketWriter & operator= (const PacketWriter & )
Defined at line 92 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.h
PacketWriter & operator= (PacketWriter && )
Defined at line 93 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.h
PacketWriter & operator<< (int16_t value)
Defined at line 93 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (int32_t value)
Defined at line 99 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (int64_t value)
Defined at line 105 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc
PacketWriter & operator<< (const std::vector<uint8_t> & value)
Defined at line 111 of file ../../src/connectivity/network/mdns/service/encoding/packet_writer.cc