Skip to main content

cpp_source_with_both_versions

Function cpp_source_with_both_versions 

Source
pub fn cpp_source_with_both_versions(
    ast: &Ast,
    key: LayoutKey,
    options: CodecOptions,
    codec_namespace: &str,
) -> Result<CppSource, GenerateError>
Expand description

The C++ header with the codec key plans in codec_namespace and the other XCDR version’s decoders beside it, in a nested namespace named for that version (xcdr1 or xcdr2).

A peer chooses its representation (DDS-XTypes 1.3 §7.6.3.1.2) and a reader takes what arrives; one codec per file left a C++ reader refusing every sample a peer wrote in the other version. C++ keeps the two sets apart by namespace, so neither set is renamed: the routines of each call their own by unqualified name, and the topic_type_support<T>::decode the front end emits chooses by the version the encapsulation announces. The other version is planned with key’s every other axis — the dialect is one choice for the file.

§Errors

As source, for the version key names. A model the other version cannot carry is not an error: the header then holds one codec, and CppSource::other says so.