A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/aeron-io/simple-binary-encoding/issues/529 below:

C++ constant value gets serialized · Issue #529 · aeron-io/simple-binary-encoding · GitHub

Having the following enum definition

<enum name="Enum1" encodingType="uint8">
    <validValue name="Val1">0</validValue>
    <validValue name="Val2">1</validValue>
    <validValue name="Val3">2</validValue>
</enum> 

and message with single constant field

<message name="Msg1" id="1" description="TestMessage">
    <field name="field1" id="20" type="uint8" presence="constant" valueRef="Enum1.Val2"/>
</message>

generates code that serializes the field:

std::uint8_t field1() const
{
    return (*((std::uint8_t *)(m_buffer + m_offset + 0)));
}

Msg1 &field1(const std::uint8_t value)
{
    *((std::uint8_t *)(m_buffer + m_offset + 0)) = (value);
    return *this;
}

while realizing that the field is constant:

    static const char *field1MetaAttribute(const MetaAttribute::Attribute metaAttribute) SBE_NOEXCEPT
    {
        switch (metaAttribute)
        {
            case MetaAttribute::EPOCH: return "unix";
            case MetaAttribute::TIME_UNIT: return "nanosecond";
            case MetaAttribute::SEMANTIC_TYPE: return "";
            case MetaAttribute::PRESENCE: return "constant";   // <----- HERE
        }

        return "";
    }

The only difference from #528 is that the type of the field is specified "uint8" directly instead of "Enum1".

Reproduced with v1.7.4


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4