Class astutedds::cdr::XCDR2Encoder

ClassList > astutedds > cdr > XCDR2Encoder

XCDR2 encoding (CDR encapsulation version 2) More...

  • #include <xcdr2_codec.hpp>

Public Functions

Type Name
XCDR2Encoder (std::vector< uint8_t > & buffer, bool big_endian=false, ExtensibilityKind extensibility=ExtensibilityKind::FINAL)
void begin_delimited ()
Begin encoding a delimited type (appendable or mutable)
void encode_bool (bool value)
void encode_double (double value)
void encode_float (float value)
void encode_int16 (int16_t value)
void encode_int32 (int32_t value)
void encode_int64 (int64_t value)
void encode_int8 (int8_t value)
void encode_member (uint32_t member_id, bool must_understand, WriteMemberFn && write_member)
Encode a mutable-struct member: EMHEADER (with correct Length Code) + payload.
void encode_member_header (uint32_t member_id, bool must_understand=false)
Encode member header for mutable types ( EMHEADER ) — legacy raw form.
void encode_sequence_length (uint32_t length)
void encode_string (const std::string & str)
void encode_uint16 (uint16_t value)
void encode_uint32 (uint32_t value)
void encode_uint64 (uint64_t value)
void encode_uint8 (uint8_t value)
void encode_wstring (const std::wstring & str)
void end_delimited ()
End encoding a delimited type.
size_t size () const

Detailed Description

XCDR2 supports delimited headers (DHEADER) for appendable and mutable types, enabling better type evolution and interoperability.

Key features: * 4-byte alignment for all members * DHEADER for appendable/mutable types * EMHEADER for mutable struct members

Public Functions Documentation

function XCDR2Encoder

inline astutedds::cdr::XCDR2Encoder::XCDR2Encoder (
    std::vector< uint8_t > & buffer,
    bool big_endian=false,
    ExtensibilityKind extensibility=ExtensibilityKind::FINAL
) 

function begin_delimited

Begin encoding a delimited type (appendable or mutable)

inline void astutedds::cdr::XCDR2Encoder::begin_delimited () 

Writes a DHEADER placeholder and pushes position to stack. Must be paired with end_delimited().


function encode_bool

inline void astutedds::cdr::XCDR2Encoder::encode_bool (
    bool value
) 

function encode_double

inline void astutedds::cdr::XCDR2Encoder::encode_double (
    double value
) 

function encode_float

inline void astutedds::cdr::XCDR2Encoder::encode_float (
    float value
) 

function encode_int16

inline void astutedds::cdr::XCDR2Encoder::encode_int16 (
    int16_t value
) 

function encode_int32

inline void astutedds::cdr::XCDR2Encoder::encode_int32 (
    int32_t value
) 

function encode_int64

inline void astutedds::cdr::XCDR2Encoder::encode_int64 (
    int64_t value
) 

function encode_int8

inline void astutedds::cdr::XCDR2Encoder::encode_int8 (
    int8_t value
) 

function encode_member

Encode a mutable-struct member: EMHEADER (with correct Length Code) + payload.

template<typename WriteMemberFn>
inline void astutedds::cdr::XCDR2Encoder::encode_member (
    uint32_t member_id,
    bool must_understand,
    WriteMemberFn && write_member
) 

Per DDS-XTypes 1.3 §7.4.3.4.4, the EMHEADER's 3-bit Length Code (LC) tells a reader that does not recognise member_id exactly how many bytes to skip in order to reach the next member. This method measures the size of the data written by write_member and selects LC 0-3 for the four fixed sizes (1/2/4/8 bytes) or LC 4 (NEXTINT-prefixed, arbitrary byte count) for everything else, then backpatches the EMHEADER accordingly. This is the only correct way to produce a header a future/other reader can skip past, since the final size is not known until after the member has been serialized.

Parameters:

  • member_id Member ID
  • must_understand Must-understand flag
  • write_member Callable that serializes exactly this member's payload

function encode_member_header

Encode member header for mutable types ( EMHEADER ) — legacy raw form.

inline void astutedds::cdr::XCDR2Encoder::encode_member_header (
    uint32_t member_id,
    bool must_understand=false
) 

Deprecated

Always writes Length Code 0, which is only correct when the member payload that immediately follows is exactly 1 byte. Prefer encode_member(), which measures the actual payload size and selects a Length Code a reader can use to skip an unrecognised member. Kept for existing direct callers.

Parameters:

  • member_id Member ID
  • must_understand Must-understand flag

function encode_sequence_length

inline void astutedds::cdr::XCDR2Encoder::encode_sequence_length (
    uint32_t length
) 

function encode_string

inline void astutedds::cdr::XCDR2Encoder::encode_string (
    const std::string & str
) 

function encode_uint16

inline void astutedds::cdr::XCDR2Encoder::encode_uint16 (
    uint16_t value
) 

function encode_uint32

inline void astutedds::cdr::XCDR2Encoder::encode_uint32 (
    uint32_t value
) 

function encode_uint64

inline void astutedds::cdr::XCDR2Encoder::encode_uint64 (
    uint64_t value
) 

function encode_uint8

inline void astutedds::cdr::XCDR2Encoder::encode_uint8 (
    uint8_t value
) 

function encode_wstring

inline void astutedds::cdr::XCDR2Encoder::encode_wstring (
    const std::wstring & str
) 

function end_delimited

End encoding a delimited type.

inline void astutedds::cdr::XCDR2Encoder::end_delimited () 

Updates the DHEADER with actual size.


function size

inline size_t astutedds::cdr::XCDR2Encoder::size () const


The documentation for this class was generated from the following file include/astutedds/cdr/xcdr2_codec.hpp