Skip to content

Parsing enum fields with name not a number - FAST v1.2 #86

Description

@benjaminfaul2

Hello, I am trying to use mFAST with FAST v1.2 templates and it seems to throw a static error when an enum type has element names that are not numbers.
E.g.

<define name="Answer">
    <enum>
      <element name="N" id="No"/>
      <element name="Y" id="Yes"/>
    </enum>
  </define>

Is there a way I can fix this? I'm trying to understand the code but it just seems to assume the element names must be a number.

Error:

Throw in function virtual void mfast::xml_parser::field_builder::visit(const mfast::enum_field_instruction*, void*)
Dynamic exception type: boost::exception_detail::clone_impl<mfast::fast_static_error>
std::exception::what: std::exception
[mfast::xml_parser::tag_value*] = 0
[mfast::tag_error_code*] = Unrecognized enum initial value :

Note: I am using the latest master as of 9-Sept-2019.
Thanks

Activity

  1. benjaminfaul2 commented on Sep 10, 2019

    @benjaminfaul2
    Author

    After further digging it appears that later in the template file, a message is defined using this value but with a default that doesn't correspond to any of the named values.
    E.g

    <template id="123" name="ReplyMessage">
        <field name="ReplyAnswer" id="1234" presence="optional">
            <type name="Answer">
                <default value="0"/>
            </type>
        </field>
    </template>
    

    Is this invalid syntax?

    Thanks

  2. benjaminfaul2 commented on Sep 11, 2019

    @benjaminfaul2
    Author

    It seems the mFAST implementation of handling the default enum value is incorrect. See this link:

    https://forum.fixtrading.org/t/default-value-for-enumeration-fast-1-2-extension/1236/2

    The default value is the "on the wire" value not a enum field name.

  3. SBAM commented on Nov 24, 2021

    @SBAM

    Hi, if you're interested, I addressed this in this fork SBAM@4a427bd
    If an id attribute is provided and matches, it will be selected, otherwise it falls back to the name attribute.

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