Skip to content

Constant field getter static constexpr cpp #591

Closed

Description

@kdoherty2

Using SBE Tool v1.7.9:

Because the field is not constexpr we cannot use this methods in template metaprogramming, and instead we have created python scripts to post process and fix the generated code

Given the following schema: (escaped < below)
<types>
<enum name="EnumSBESample" encodingType="uint8" semanticType="EnumSBESample">
<validValue name="a">0</validValue>
<validValue name="b">1</validValue>
</enum>
</types>

<sbe:message name="MsgSBESample" id="1023" semanticType="MsgSBESample">
<field name="fieldConstant" id="1" type="EnumSBESample" presence="constant" semanticType="EnumSBESample" valueRef="EnumSBESample.a" />
</sbe:message>

Consider generating
static SBE_CONSTEXPR EnumSBESample::Value fieldConstant() SBE_NOEXCEPT

{ return EnumSBESample::Value::a; }

Instead of
EnumSBESample::Value fieldConstant() const SBE_NOEXCEPT

{ return EnumSBESample::Value::a; }

Activity

  1. mjpt777 commented on Oct 9, 2018

    @mjpt777
    Contributor

    This will need to be used carefully. If using the constant method then this will not be able to change in a later version as existing code will be bound to the constant method and not pick up a change if the presence becomes "required".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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