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 203 of file vita49_serializer.cpp.

204 {
205 if (reserve_bytes > 0u)
206 {
207 _bytes.reserve(reserve_bytes);
208 }
209 }
math::Vec3 max

References max.

Member Function Documentation

◆ bytes()

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

Definition at line 271 of file vita49_serializer.cpp.

271{ 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 273 of file vita49_serializer.cpp.

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

◆ writeAsciiMetadata()

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

Definition at line 245 of file vita49_serializer.cpp.

246 {
247 if (value.size() >= std::numeric_limits<std::uint32_t>::max())
248 {
249 throw std::length_error("VITA ASCII metadata field too large");
250 }
251 for (const auto ch : value)
252 {
253 if (static_cast<unsigned char>(ch) > 0x7Fu)
254 {
255 throw std::invalid_argument("VITA ASCII metadata must contain ASCII bytes only");
256 }
257 }
258 _bytes.insert(_bytes.end(), value.begin(), value.end());
259 _bytes.push_back(0);
260 while (_bytes.size() % sizeof(std::uint32_t) != 0u)
261 {
262 _bytes.push_back(0);
263 }
264 }

References max.

◆ writeBytes()

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

Definition at line 266 of file vita49_serializer.cpp.

267 {
268 _bytes.insert(_bytes.end(), bytes.begin(), bytes.end());
269 }
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 233 of file vita49_serializer.cpp.

234 {
235 static_assert(sizeof(RealType) == sizeof(std::uint64_t));
236 static_assert(std::numeric_limits<RealType>::is_iec559,
237 "VITA F64 context serialization requires IEEE 754 binary64 RealType");
238 // VRT context doubles are serialized from their IEEE 754 bit pattern as a
239 // big-endian unsigned integer. This assumes the host uses a conventional
240 // IEEE representation for RealType.
241 const auto bits = std::bit_cast<std::uint64_t>(value);
242 writeU64(bits);
243 }
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 217 of file vita49_serializer.cpp.

217{ 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 211 of file vita49_serializer.cpp.

212 {
213 _bytes.push_back(static_cast<std::uint8_t>((value >> 8u) & 0xFFu));
214 _bytes.push_back(static_cast<std::uint8_t>(value & 0xFFu));
215 }

Referenced by writeI16().

+ Here is the caller graph for this function:

◆ writeU32()

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

Definition at line 219 of file vita49_serializer.cpp.

220 {
221 _bytes.push_back(static_cast<std::uint8_t>((value >> 24u) & 0xFFu));
222 _bytes.push_back(static_cast<std::uint8_t>((value >> 16u) & 0xFFu));
223 _bytes.push_back(static_cast<std::uint8_t>((value >> 8u) & 0xFFu));
224 _bytes.push_back(static_cast<std::uint8_t>(value & 0xFFu));
225 }

Referenced by writeU64().

+ Here is the caller graph for this function:

◆ writeU64()

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

Definition at line 227 of file vita49_serializer.cpp.

228 {
229 writeU32(static_cast<std::uint32_t>((value >> 32u) & 0xFFFFFFFFull));
230 writeU32(static_cast<std::uint32_t>(value & 0xFFFFFFFFull));
231 }
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: