Skip to content

[C++] operator<< for schema version X can't print messages with schema version Y #839

Closed
@lukeocamden

Description

@lukeocamden

From CppGenerator.java:

            "template<typename CharT, typename Traits>\n" +
            "friend std::basic_ostream<CharT, Traits> & operator << (\n" +
            "    std::basic_ostream<CharT, Traits> &builder, %1$s _writer)\n" +
            "{\n" +
            "    %1$s writer(_writer.m_buffer, _writer.m_offset,\n" +
            "        _writer.m_bufferLength, _writer.sbeBlockLength(), _writer.m_actingVersion);\n" +

I think the problem here is use of sbeBlockLength which is the decoder's block length and not the message's block length, which means if the block length has changed between the two versions then we will misinterpret the message. In contrast, we use the message's schema version via m_actingVersion, instead of the decoder's schema version.

Is there a simple way to fix this? Or - if by design - at least to compare m_actingVersion against sbeSchemaVersion to detect misuse of operator<<?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions