INET Framework for OMNeT++/OMNEST
inet::MemoryOutputStream Class Reference

This class provides an efficient in memory bit output stream. More...

#include <MemoryOutputStream.h>

Public Member Functions

 MemoryOutputStream (b initialCapacity=B(64))
 
Stream querying functions
b getLength () const
 Returns the length of the bit stream measured in bits. More...
 
const std::vector< uint8_t > & getData () const
 
void copyData (std::vector< bool > &result, b offset=b(0), b length=b(-1)) const
 
void copyData (std::vector< uint8_t > &result, B offset=B(0), B length=B(-1)) const
 
Bit streaming functions
void writeBit (bool value)
 Writes a bit to the end of the stream. More...
 
void writeBitRepeatedly (bool value, size_t count)
 Writes the same bit repeatedly to the end of the stream. More...
 
void writeBits (const std::vector< bool > &bits, b offset=b(0), b length=b(-1))
 Writes a sequence of bits to the end of the stream keeping the original bit order. More...
 
Byte streaming functions
void writeByte (uint8_t value)
 Writes a byte to the end of the stream in MSB to LSB bit order. More...
 
void writeByteRepeatedly (uint8_t value, size_t count)
 Writes the same byte repeatedly to the end of the stream in MSB to LSB bit order. More...
 
void writeBytes (const std::vector< uint8_t > &bytes, B offset=B(0), B length=B(-1))
 Writes a sequence of bytes to the end of the stream keeping the original byte order and in MSB to LSB bit order. More...
 
void writeBytes (const uint8_t *buffer, B length)
 Writes a sequence of bytes to the end of the stream keeping the original byte order and in MSB to LSB bit order. More...
 
Basic type streaming functions
void writeUint2 (uint8_t value)
 Writes a 2 bit unsigned integer to the end of the stream in MSB to LSB bit order. More...
 
void writeUint4 (uint8_t value)
 Writes a 4 bit unsigned integer to the end of the stream in MSB to LSB bit order. More...
 
void writeUint8 (uint8_t value)
 Writes an 8 bit unsigned integer to the end of the stream in MSB to LSB bit order. More...
 
void writeUint16Be (uint16_t value)
 Writes a 16 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 
void writeUint16Le (uint16_t value)
 Writes a 16 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order. More...
 
void writeUint24Be (uint32_t value)
 Writes a 24 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 
void writeUint24Le (uint32_t value)
 Writes a 24 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order. More...
 
void writeUint32Be (uint32_t value)
 Writes a 32 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 
void writeUint32Le (uint32_t value)
 Writes a 32 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order. More...
 
void writeUint48Be (uint64_t value)
 Writes a 48 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 
void writeUint48Le (uint64_t value)
 Writes a 48 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order. More...
 
void writeUint64Be (uint64_t value)
 Writes a 64 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 
void writeUint64Le (uint64_t value)
 Writes a 64 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order. More...
 
INET specific type streaming functions
void writeMacAddress (MacAddress address)
 Writes a MAC address to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 
void writeIpv4Address (Ipv4Address address)
 Writes an Ipv4 address to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 
void writeIpv6Address (Ipv6Address address)
 Writes an Ipv6 address to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 
other useful streaming functions
void writeString (std::string s)
 Writes a zero terminated string in the order of the characters. More...
 
void writeNBitsOfUint64Be (uint64_t value, uint8_t n)
 Writes n bits of a 64 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order. More...
 

Protected Member Functions

bool isByteAligned ()
 

Protected Attributes

std::vector< uint8_t > data
 This vector contains the bits that were written to this stream so far. More...
 
b length
 The length of the bit stream measured in bits. More...
 

Detailed Description

This class provides an efficient in memory bit output stream.

The stream provides a set of write functions that write data to the end of the stream. Most functions are implemented in the header to allow inlining.

Constructor & Destructor Documentation

◆ MemoryOutputStream()

inet::MemoryOutputStream::MemoryOutputStream ( b  initialCapacity = B(64))
inline
51  :
52  length(b(0))
53  {
54  data.reserve((b(initialCapacity).get() + 7) >> 3);
55  }

Member Function Documentation

◆ copyData() [1/2]

void inet::MemoryOutputStream::copyData ( std::vector< bool > &  result,
b  offset = b(0),
b  length = b(-1) 
) const
inline
66  {
67  size_t end = b(length == b(-1) ? this->length : offset + length).get();
68  for (size_t i = b(offset).get(); i < end; i++) {
69  size_t byteIndex = i / 8;
70  size_t bitIndex = i % 8;
71  uint8_t byte = data.at(byteIndex);
72  uint8_t mask = 1 << (7 - bitIndex);
73  bool bit = byte & mask;
74  result.push_back(bit);
75  }
76  }

Referenced by inet::BitsChunk::convertChunk(), inet::Chunk::getBinDumpLine(), inet::Chunk::getHexDumpLine(), and inet::FieldsChunkSerializer::serialize().

◆ copyData() [2/2]

void inet::MemoryOutputStream::copyData ( std::vector< uint8_t > &  result,
B  offset = B(0),
B  length = B(-1) 
) const
inline
78  {
79  auto end = length == B(-1) ? B(data.size()) : offset + length;
80  assert(b(0) <= offset && offset <= B(data.size()));
81  assert(b(0) <= end && end <= B(data.size()));
82  assert(offset <= end);
83  result.insert(result.begin(), data.begin() + B(offset).get(), data.begin() + B(end).get());
84  }

◆ getData()

◆ getLength()

◆ isByteAligned()

bool inet::MemoryOutputStream::isByteAligned ( )
inlineprotected
46  {
47  return b(length).get() % 8 == 0;
48  }

◆ writeBit()

◆ writeBitRepeatedly()

void inet::MemoryOutputStream::writeBitRepeatedly ( bool  value,
size_t  count 
)
inline

◆ writeBits()

void inet::MemoryOutputStream::writeBits ( const std::vector< bool > &  bits,
b  offset = b(0),
b  length = b(-1) 
)
inline

Writes a sequence of bits to the end of the stream keeping the original bit order.

115  {
116  auto end = length == b(-1) ? bits.size() : b(offset + length).get();
117  for (size_t i = b(offset).get(); i < end; i++)
118  writeBit(bits.at(i));
119  }

Referenced by inet::BitsChunkSerializer::serialize().

◆ writeByte()

void inet::MemoryOutputStream::writeByte ( uint8_t  value)
inline

Writes a byte to the end of the stream in MSB to LSB bit order.

127  {
128  if (isByteAligned())
129  data.push_back(value);
130  else {
131  int l1 = b(length).get() % 8;
132  int l2 = 8 - l1;
133  data.back() |= (value & (0xFF << l2)) >> l2;
134  data.push_back((value & (0xFF >> l1)) << l1);
135  }
136  length += B(1);
137  }

Referenced by inet::Ieee8021aeTagTpidHeaderSerializer::serialize(), inet::Ieee8022LlcHeaderSerializer::serialize(), inet::Ipv6HeaderSerializer::serialize(), inet::rtp::RtcpPacketSerializer::serialize(), inet::XMacHeaderSerializer::serialize(), inet::GenericAppMsgSerializer::serialize(), inet::TransportPseudoHeaderSerializer::serialize(), inet::VoipStreamPacketSerializer::serialize(), inet::BMacHeaderSerializer::serialize(), inet::IcmpHeaderSerializer::serialize(), inet::Ieee8021dBpduSerializer::serialize(), inet::IgmpHeaderSerializer::serialize(), inet::DhcpMessageSerializer::serialize(), inet::Icmpv6HeaderSerializer::serialize(), inet::PimPacketSerializer::serialize(), inet::aodv::AodvControlPacketsSerializer::serialize(), inet::CsmaCaMacHeaderSerializer::serialize(), inet::bgp::BgpHeaderSerializer::serialize(), inet::ieee80211::Ieee80211MacHeaderSerializer::serialize(), inet::ArpPacketSerializer::serialize(), inet::ieee80211::Ieee80211MgmtFrameSerializer::serialize(), inet::Ieee8021aeTagEpdHeaderSerializer::serialize(), inet::physicallayer::EthernetPhyHeaderSerializer::serialize(), inet::ospfv2::Ospfv2PacketSerializer::serialize(), inet::physicallayer::Ieee80211DsssPhyHeaderSerializer::serialize(), inet::physicallayer::EthernetFragmentPhyHeaderSerializer::serialize(), inet::ieee80211::Ieee80211MpduSubframeHeaderSerializer::serialize(), inet::physicallayer::Ieee80211HrDsssPhyHeaderSerializer::serialize(), inet::serializeIpv6NdOptions(), inet::ospfv2::Ospfv2PacketSerializer::serializeLsaHeader(), inet::Ipv4HeaderSerializer::serializeOption(), inet::tcp::TcpHeaderSerializer::serializeOption(), inet::ospfv2::Ospfv2PacketSerializer::serializeOspfHeader(), inet::ospfv2::Ospfv2PacketSerializer::serializeRouterLsa(), and inet::ospfv2::Ospfv2PacketSerializer::serializeSummaryLsa().

◆ writeByteRepeatedly()

◆ writeBytes() [1/2]

void inet::MemoryOutputStream::writeBytes ( const std::vector< uint8_t > &  bytes,
B  offset = B(0),
B  length = B(-1) 
)
inline

Writes a sequence of bytes to the end of the stream keeping the original byte order and in MSB to LSB bit order.

152  {
153  assert(isByteAligned());
154  auto end = length == B(-1) ? B(bytes.size()) : offset + length;
155  assert(b(0) <= offset && offset <= B(bytes.size()));
156  assert(b(0) <= end && end <= B(bytes.size()));
157  assert(offset <= end);
158  data.insert(data.end(), bytes.begin() + B(offset).get(), bytes.begin() + B(end).get());
159  this->length += end - offset;
160  }

Referenced by inet::BytesChunkSerializer::serialize(), inet::sctp::SctpHeaderSerializer::serialize(), inet::ieee80211::Ieee80211MgmtFrameSerializer::serialize(), inet::Ipv4HeaderSerializer::serialize(), inet::tcp::TcpHeaderSerializer::serialize(), and inet::FieldsChunkSerializer::serialize().

◆ writeBytes() [2/2]

void inet::MemoryOutputStream::writeBytes ( const uint8_t *  buffer,
B  length 
)
inline

Writes a sequence of bytes to the end of the stream keeping the original byte order and in MSB to LSB bit order.

166  {
167  assert(isByteAligned());
168  data.insert(data.end(), buffer, buffer + B(length).get());
169  this->length += length;
170  }

◆ writeIpv4Address()

◆ writeIpv6Address()

void inet::MemoryOutputStream::writeIpv6Address ( Ipv6Address  address)
inline

Writes an Ipv6 address to the end of the stream in big endian byte order and MSB to LSB bit order.

343  {
344  for (int i = 0; i < 4; i++)
345  writeUint32Be(address.words()[i]);
346  }

Referenced by inet::Ipv6HeaderSerializer::serialize(), inet::TransportPseudoHeaderSerializer::serialize(), inet::Icmpv6HeaderSerializer::serialize(), inet::aodv::AodvControlPacketsSerializer::serialize(), and inet::serializeIpv6NdOptions().

◆ writeMacAddress()

◆ writeNBitsOfUint64Be()

◆ writeString()

void inet::MemoryOutputStream::writeString ( std::string  s)
inline

Writes a zero terminated string in the order of the characters.

354  {
355  writeBytes(std::vector<uint8_t>(s.begin(), s.end()));
356  writeByte(0);
357  }

◆ writeUint16Be()

void inet::MemoryOutputStream::writeUint16Be ( uint16_t  value)
inline

Writes a 16 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order.

207  {
208  writeByte(static_cast<uint8_t>(value >> 8));
209  writeByte(static_cast<uint8_t>(value >> 0));
210  }

Referenced by inet::Ieee802EpdHeaderSerializer::serialize(), inet::EthernetControlFrameSerializer::serialize(), inet::Ieee8021rTagTpidHeaderSerializer::serialize(), inet::Ieee8022LlcHeaderSerializer::serialize(), inet::Ieee8021aeTagTpidHeaderSerializer::serialize(), inet::Ieee8021qTagTpidHeaderSerializer::serialize(), inet::Ipv6HeaderSerializer::serialize(), inet::rtp::RtcpPacketSerializer::serialize(), inet::rtp::RtpMpegPacketSerializer::serialize(), inet::rtp::RtpPacketSerializer::serialize(), inet::UnitDiskPhyHeaderSerializer::serialize(), inet::physicallayer::ApskPhyHeaderSerializer::serialize(), inet::IcmpHeaderSerializer::serialize(), inet::DhcpMessageSerializer::serialize(), inet::EchoPacketSerializer::serialize(), inet::Icmpv6HeaderSerializer::serialize(), inet::IgmpHeaderSerializer::serialize(), inet::BMacHeaderSerializer::serialize(), inet::PimPacketSerializer::serialize(), inet::PppHeaderSerializer::serialize(), inet::RipPacketSerializer::serialize(), inet::SequenceNumberHeaderSerializer::serialize(), inet::TransportPseudoHeaderSerializer::serialize(), inet::UdpHeaderSerializer::serialize(), inet::VoipStreamPacketSerializer::serialize(), inet::XMacHeaderSerializer::serialize(), inet::CrcHeaderSerializer::serialize(), inet::Ieee8021dBpduSerializer::serialize(), inet::CsmaCaMacHeaderSerializer::serialize(), inet::bgp::BgpHeaderSerializer::serialize(), inet::AckingMacHeaderSerializer::serialize(), inet::physicallayer::Ieee80211FhssPhyHeaderSerializer::serialize(), inet::ieee80211::Ieee80211MacHeaderSerializer::serialize(), inet::ieee80211::Ieee80211MgmtFrameSerializer::serialize(), inet::ArpPacketSerializer::serialize(), inet::Ieee8021qTagEpdHeaderSerializer::serialize(), inet::Ieee8021rTagEpdHeaderSerializer::serialize(), inet::Ieee8021aeTagEpdHeaderSerializer::serialize(), inet::PppTrailerSerializer::serialize(), inet::EthernetTypeOrLengthFieldSerializer::serialize(), inet::physicallayer::Ieee80211IrPhyHeaderSerializer::serialize(), inet::ieee80211::Ieee80211MsduSubframeHeaderSerializer::serialize(), inet::EthernetMacHeaderSerializer::serialize(), inet::ospfv2::Ospfv2PacketSerializer::serialize(), inet::physicallayer::Ieee80211DsssPhyHeaderSerializer::serialize(), inet::physicallayer::Ieee80211HrDsssPhyHeaderSerializer::serialize(), inet::physicallayer::Ieee80211OfdmPhyHeaderSerializer::serialize(), inet::physicallayer::Ieee80211ErpOfdmPhyHeaderSerializer::serialize(), inet::serializeIpv6NdOptions(), inet::ospfv2::Ospfv2PacketSerializer::serializeLsaHeader(), inet::Ipv4HeaderSerializer::serializeOption(), inet::tcp::TcpHeaderSerializer::serializeOption(), inet::ospfv2::Ospfv2PacketSerializer::serializeOspfHeader(), inet::ospfv2::Ospfv2PacketSerializer::serializeRouterLsa(), inet::GptpPacketSerializer::writeGptpBase(), inet::GptpPacketSerializer::writeGptpFollowUpInformationTlv(), and inet::GptpPacketSerializer::writePortIdentity().

◆ writeUint16Le()

void inet::MemoryOutputStream::writeUint16Le ( uint16_t  value)
inline

Writes a 16 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order.

216  {
217  writeByte(static_cast<uint8_t>(value >> 0));
218  writeByte(static_cast<uint8_t>(value >> 8));
219  }

Referenced by inet::ieee80211::Ieee80211MacHeaderSerializer::serialize().

◆ writeUint2()

void inet::MemoryOutputStream::writeUint2 ( uint8_t  value)
inline

Writes a 2 bit unsigned integer to the end of the stream in MSB to LSB bit order.

179  {
180  writeBit(value & 0x2);
181  writeBit(value & 0x1);
182  }

Referenced by inet::Ipv6HeaderSerializer::serialize().

◆ writeUint24Be()

void inet::MemoryOutputStream::writeUint24Be ( uint32_t  value)
inline

Writes a 24 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order.

225  {
226  writeByte(static_cast<uint8_t>(value >> 16));
227  writeByte(static_cast<uint8_t>(value >> 8));
228  writeByte(static_cast<uint8_t>(value >> 0));
229  }

Referenced by inet::ospfv2::Ospfv2PacketSerializer::serializeAsExternalLsa(), inet::ospfv2::Ospfv2PacketSerializer::serializeSummaryLsa(), and inet::GptpPacketSerializer::writeGptpFollowUpInformationTlv().

◆ writeUint24Le()

void inet::MemoryOutputStream::writeUint24Le ( uint32_t  value)
inline

Writes a 24 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order.

235  {
236  writeByte(static_cast<uint8_t>(value >> 0));
237  writeByte(static_cast<uint8_t>(value >> 8));
238  writeByte(static_cast<uint8_t>(value >> 16));
239  }

◆ writeUint32Be()

void inet::MemoryOutputStream::writeUint32Be ( uint32_t  value)
inline

Writes a 32 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order.

245  {
246  writeByte(static_cast<uint8_t>(value >> 24));
247  writeByte(static_cast<uint8_t>(value >> 16));
248  writeByte(static_cast<uint8_t>(value >> 8));
249  writeByte(static_cast<uint8_t>(value >> 0));
250  }

Referenced by inet::Ieee8021aeTagTpidHeaderSerializer::serialize(), inet::rtp::RtcpPacketSerializer::serialize(), inet::rtp::RtpPacketSerializer::serialize(), inet::Ipv6HeaderSerializer::serialize(), inet::VoipStreamPacketSerializer::serialize(), inet::ApplicationPacketSerializer::serialize(), inet::RipPacketSerializer::serialize(), inet::IcmpHeaderSerializer::serialize(), inet::Icmpv6HeaderSerializer::serialize(), inet::TransportPseudoHeaderSerializer::serialize(), inet::DhcpMessageSerializer::serialize(), inet::FcsHeaderSerializer::serialize(), inet::GenericAppMsgSerializer::serialize(), inet::Ieee8021dBpduSerializer::serialize(), inet::DsdvHelloSerializer::serialize(), inet::IgmpHeaderSerializer::serialize(), inet::EtherAppReqSerializer::serialize(), inet::PimPacketSerializer::serialize(), inet::aodv::AodvControlPacketsSerializer::serialize(), inet::bgp::BgpHeaderSerializer::serialize(), inet::ieee80211::Ieee80211MacHeaderSerializer::serialize(), inet::Ieee8021aeTagEpdHeaderSerializer::serialize(), inet::CsmaCaMacTrailerSerializer::serialize(), inet::EtherAppRespSerializer::serialize(), inet::ieee80211::Ieee80211MacTrailerSerializer::serialize(), inet::ospfv2::Ospfv2PacketSerializer::serialize(), inet::EthernetFcsSerializer::serialize(), inet::ospfv2::Ospfv2PacketSerializer::serializeAsExternalLsa(), inet::serializeIpv6NdOptions(), inet::ospfv2::Ospfv2PacketSerializer::serializeLsaHeader(), inet::Ipv4HeaderSerializer::serializeOption(), inet::tcp::TcpHeaderSerializer::serializeOption(), inet::ospfv2::Ospfv2PacketSerializer::serializeRouterLsa(), inet::GptpPacketSerializer::writeGptpBase(), inet::GptpPacketSerializer::writeGptpFollowUpInformationTlv(), inet::GptpPacketSerializer::writeScaledNS(), and inet::GptpPacketSerializer::writeTimestamp().

◆ writeUint32Le()

void inet::MemoryOutputStream::writeUint32Le ( uint32_t  value)
inline

Writes a 32 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order.

256  {
257  writeByte(static_cast<uint8_t>(value >> 0));
258  writeByte(static_cast<uint8_t>(value >> 8));
259  writeByte(static_cast<uint8_t>(value >> 16));
260  writeByte(static_cast<uint8_t>(value >> 24));
261  }

◆ writeUint4()

◆ writeUint48Be()

void inet::MemoryOutputStream::writeUint48Be ( uint64_t  value)
inline

Writes a 48 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order.

267  {
268  writeByte(static_cast<uint8_t>(value >> 40));
269  writeByte(static_cast<uint8_t>(value >> 32));
270  writeByte(static_cast<uint8_t>(value >> 24));
271  writeByte(static_cast<uint8_t>(value >> 16));
272  writeByte(static_cast<uint8_t>(value >> 8));
273  writeByte(static_cast<uint8_t>(value >> 0));
274  }

Referenced by inet::GptpPacketSerializer::writeTimestamp().

◆ writeUint48Le()

void inet::MemoryOutputStream::writeUint48Le ( uint64_t  value)
inline

Writes a 48 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order.

280  {
281  writeByte(static_cast<uint8_t>(value >> 0));
282  writeByte(static_cast<uint8_t>(value >> 8));
283  writeByte(static_cast<uint8_t>(value >> 16));
284  writeByte(static_cast<uint8_t>(value >> 24));
285  writeByte(static_cast<uint8_t>(value >> 32));
286  writeByte(static_cast<uint8_t>(value >> 40));
287  }

◆ writeUint64Be()

void inet::MemoryOutputStream::writeUint64Be ( uint64_t  value)
inline

Writes a 64 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit order.

293  {
294  writeByte(static_cast<uint8_t>(value >> 56));
295  writeByte(static_cast<uint8_t>(value >> 48));
296  writeByte(static_cast<uint8_t>(value >> 40));
297  writeByte(static_cast<uint8_t>(value >> 32));
298  writeByte(static_cast<uint8_t>(value >> 24));
299  writeByte(static_cast<uint8_t>(value >> 16));
300  writeByte(static_cast<uint8_t>(value >> 8));
301  writeByte(static_cast<uint8_t>(value >> 0));
302  }

Referenced by inet::rtp::RtcpPacketSerializer::serialize(), inet::XMacHeaderSerializer::serialize(), inet::BMacHeaderSerializer::serialize(), inet::GenericAppMsgSerializer::serialize(), inet::DhcpMessageSerializer::serialize(), inet::AckingMacHeaderSerializer::serialize(), inet::ieee80211::Ieee80211MgmtFrameSerializer::serialize(), inet::ieee80211::Ieee80211MacHeaderSerializer::serialize(), inet::GptpPacketSerializer::writeClock8(), inet::GptpPacketSerializer::writePortIdentity(), and inet::GptpPacketSerializer::writeScaledNS().

◆ writeUint64Le()

void inet::MemoryOutputStream::writeUint64Le ( uint64_t  value)
inline

Writes a 64 bit unsigned integer to the end of the stream in little endian byte order and MSB to LSB bit order.

308  {
309  writeByte(static_cast<uint8_t>(value >> 0));
310  writeByte(static_cast<uint8_t>(value >> 8));
311  writeByte(static_cast<uint8_t>(value >> 16));
312  writeByte(static_cast<uint8_t>(value >> 24));
313  writeByte(static_cast<uint8_t>(value >> 32));
314  writeByte(static_cast<uint8_t>(value >> 40));
315  writeByte(static_cast<uint8_t>(value >> 48));
316  writeByte(static_cast<uint8_t>(value >> 56));
317  }

◆ writeUint8()

Member Data Documentation

◆ data

std::vector<uint8_t> inet::MemoryOutputStream::data
protected

This vector contains the bits that were written to this stream so far.

The first bit of the bit stream is stored in the most significant bit of the first byte. For the longest possible bit stream given the same number of bytes, the last bit of the bit stream is stored in the least significant bit of the last byte. In other cases some of the lower bits of the last byte are not used.

◆ length

b inet::MemoryOutputStream::length
protected

The length of the bit stream measured in bits.


The documentation for this class was generated from the following file:
inet::MemoryOutputStream::writeBit
void writeBit(bool value)
Writes a bit to the end of the stream.
Definition: MemoryOutputStream.h:92
MAC_ADDRESS_SIZE
#define MAC_ADDRESS_SIZE
Definition: MacAddress.h:16
inet::MemoryOutputStream::data
std::vector< uint8_t > data
This vector contains the bits that were written to this stream so far.
Definition: MemoryOutputStream.h:39
inet::count
int count(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:54
inet::MemoryOutputStream::writeByte
void writeByte(uint8_t value)
Writes a byte to the end of the stream in MSB to LSB bit order.
Definition: MemoryOutputStream.h:127
inet::MemoryOutputStream::length
b length
The length of the bit stream measured in bits.
Definition: MemoryOutputStream.h:43
inet::MemoryOutputStream::writeBytes
void writeBytes(const std::vector< uint8_t > &bytes, B offset=B(0), B length=B(-1))
Writes a sequence of bytes to the end of the stream keeping the original byte order and in MSB to LSB...
Definition: MemoryOutputStream.h:152
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::MemoryOutputStream::writeUint32Be
void writeUint32Be(uint32_t value)
Writes a 32 bit unsigned integer to the end of the stream in big endian byte order and MSB to LSB bit...
Definition: MemoryOutputStream.h:245
inet::MemoryOutputStream::isByteAligned
bool isByteAligned()
Definition: MemoryOutputStream.h:46
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241