FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
serial::vita49::ByteWriter Class Reference

#include "vita49_serializer.h"

Public Member Functions

 ByteWriter (std::size_t reserve_bytes=0)
 
void writeU16 (std::uint16_t value)
 
void writeI16 (std::int16_t value)
 
void writeU32 (std::uint32_t value)
 
void writeU64 (std::uint64_t value)
 
void writeF64 (RealType value)
 
void writeAsciiMetadata (std::string_view value)
 
void writeBytes (std::span< const std::uint8_t > bytes)
 
const std::vector< std::uint8_t > & bytes () const noexcept
 
std::vector< std::uint8_t > takeBytes () noexcept
 

Detailed Description

Definition at line 19 of file vita49_serializer.h.

Constructor & Destructor Documentation

◆ ByteWriter()

serial::vita49::ByteWriter::ByteWriter ( std::size_t  reserve_bytes = 0)
explicit

Definition at line 237 of file vita49_serializer.cpp.

238 {
239 if (reserve_bytes > 0u)
240 {
241 _bytes.reserve(reserve_bytes);
242 }
243 }
math::Vec3 max

References max.

Member Function Documentation

◆ bytes()

const std::vector< std::uint8_t > & serial::vita49::ByteWriter::bytes ( ) const
noexcept

Definition at line 305 of file vita49_serializer.cpp.

305{ return _bytes; }

Referenced by writeBytes().

+ Here is the caller graph for this function:

◆ takeBytes()

std::vector< std::uint8_t > serial::vita49::ByteWriter::takeBytes ( )
noexcept

Definition at line 307 of file vita49_serializer.cpp.

307{ return std::move(_bytes); }

◆ writeAsciiMetadata()

void serial::vita49::ByteWriter::writeAsciiMetadata ( std::string_view  value)

Definition at line 279 of file vita49_serializer.cpp.

280 {
281 if (value.size() >= std::numeric_limits<std::uint32_t>::max())
282 {
283 throw std::length_error("VITA ASCII metadata field too large");
284 }
285 for (const auto ch : value)
286 {
287 if (static_cast<unsigned char>(ch) > 0x7Fu)
288 {
289 throw std::invalid_argument("VITA ASCII metadata must contain ASCII bytes only");
290 }
291 }
292 _bytes.insert(_bytes.end(), value.begin(), value.end());
293 _bytes.push_back(0);
294 while (_bytes.size() % sizeof(std::uint32_t) != 0u)
295 {
296 _bytes.push_back(0);
297 }
298 }

References max.

◆ writeBytes()

void serial::vita49::ByteWriter::writeBytes ( std::span< const std::uint8_t >  bytes)

Definition at line 300 of file vita49_serializer.cpp.

301 {
302 _bytes.insert(_bytes.end(), bytes.begin(), bytes.end());
303 }
const std::vector< std::uint8_t > & bytes() const noexcept

References bytes().

+ Here is the call graph for this function:

◆ writeF64()

void serial::vita49::ByteWriter::writeF64 ( RealType  value)

Definition at line 267 of file vita49_serializer.cpp.

268 {
269 static_assert(sizeof(RealType) == sizeof(std::uint64_t));
270 static_assert(std::numeric_limits<RealType>::is_iec559,
271 "VITA F64 context serialization requires IEEE 754 binary64 RealType");
272 // VRT context doubles are serialized from their IEEE 754 bit pattern as a
273 // big-endian unsigned integer. This assumes the host uses a conventional
274 // IEEE representation for RealType.
275 const auto bits = std::bit_cast<std::uint64_t>(value);
276 writeU64(bits);
277 }
void writeU64(std::uint64_t value)
double RealType
Type for real numbers.
Definition config.h:27

References max, and writeU64().

+ Here is the call graph for this function:

◆ writeI16()

void serial::vita49::ByteWriter::writeI16 ( std::int16_t  value)

Definition at line 251 of file vita49_serializer.cpp.

251{ writeU16(static_cast<std::uint16_t>(value)); }
void writeU16(std::uint16_t value)

References writeU16().

+ Here is the call graph for this function:

◆ writeU16()

void serial::vita49::ByteWriter::writeU16 ( std::uint16_t  value)

Definition at line 245 of file vita49_serializer.cpp.

246 {
247 _bytes.push_back(static_cast<std::uint8_t>((value >> 8u) & 0xFFu));
248 _bytes.push_back(static_cast<std::uint8_t>(value & 0xFFu));
249 }

Referenced by writeI16().

+ Here is the caller graph for this function:

◆ writeU32()

void serial::vita49::ByteWriter::writeU32 ( std::uint32_t  value)

Definition at line 253 of file vita49_serializer.cpp.

254 {
255 _bytes.push_back(static_cast<std::uint8_t>((value >> 24u) & 0xFFu));
256 _bytes.push_back(static_cast<std::uint8_t>((value >> 16u) & 0xFFu));
257 _bytes.push_back(static_cast<std::uint8_t>((value >> 8u) & 0xFFu));
258 _bytes.push_back(static_cast<std::uint8_t>(value & 0xFFu));
259 }

Referenced by writeU64().

+ Here is the caller graph for this function:

◆ writeU64()

void serial::vita49::ByteWriter::writeU64 ( std::uint64_t  value)

Definition at line 261 of file vita49_serializer.cpp.

262 {
263 writeU32(static_cast<std::uint32_t>((value >> 32u) & 0xFFFFFFFFull));
264 writeU32(static_cast<std::uint32_t>(value & 0xFFFFFFFFull));
265 }
void writeU32(std::uint32_t value)

References writeU32().

Referenced by writeF64().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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