StormByte 2.0.0
C++26 foundation of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Detail::Codec< Safe::CString > Struct Reference

StormByte::Detail::Codec specialization for StormByte::Safe::CString. More...

#include <StormByte/serializable.hxx>

Static Public Member Functions

static ByteSize Size (const Safe::CString &data) noexcept
 Serialized size of data.
 
static BinaryData Write (const Safe::CString &data) noexcept
 Encodes data.
 
static Expected< Safe::CString, DeserializeError > Read (std::span< const std::byte > data) noexcept
 Decodes a StormByte::Safe::CString from the start of data.
 

Detailed Description

StormByte::Detail::Codec specialization for StormByte::Safe::CString.

Same wire as std::string: uint64 byte count (LE) + raw bytes. A null StormByte::Safe::CString is written as an empty payload (operator std::string). Decode always yields a non-null buffer ("" when the payload is empty).

Member Function Documentation

◆ Read()

static Expected< Safe::CString, DeserializeError > StormByte::Detail::Codec< Safe::CString >::Read ( std::span< const std::byte >  data)
staticnoexcept

Decodes a StormByte::Safe::CString from the start of data.

Parameters
dataInput span.
Returns
Value, or StormByte::DeserializeError.

◆ Size()

static ByteSize StormByte::Detail::Codec< Safe::CString >::Size ( const Safe::CString &  data)
staticnoexcept

Serialized size of data.

Parameters
dataValue to measure.
Returns
Size in bytes as ByteSize.

◆ Write()

static BinaryData StormByte::Detail::Codec< Safe::CString >::Write ( const Safe::CString &  data)
staticnoexcept

Encodes data.

Parameters
dataValue to encode.
Returns
Blob owned by Base.

The documentation for this struct was generated from the following file: