OleksandrKvl / sbepp

C++ implementation of the FIX Simple Binary Encoding
https://oleksandrkvl.github.io/sbepp/
MIT License
39 stars 4 forks source link

`traits_tag` implementation #44

Closed OleksandrKvl closed 3 months ago

OleksandrKvl commented 3 months ago

This PR implements a mapping from representation types to their tags. Doesn't work for <data> members because they don't have a dedicated SBE type, only their encoding has it (e.g. varDataEncoding). At the moment, variable-length arrays are represented with dynamic_array_ref<ByteType, ValueType, LengthType, Endianness>, meaning that data members from the same schema and encoding type will have the same representation type. It's not physically possible to map this single type to multiple <data> field tags. Now, consider the following situation:

<data name="data_1" id="1" type="varDataEncoding"/>
<data name="data_2" id="2" type="varDataEncoding"/>

Straightforward logic implies that they represent the same type, a data buffer, used in multiple places. So even logically it's not clear that such mapping would make any sense. The only way to implement it is to add another Tag template parameter to dynamic_array_ref to make the latter a different type for each field. At the moment I don't it's justified, hence not implemented here.

OleksandrKvl commented 3 months ago

@ujos you might be interested in this feature if you don't like to type both type and its tag in code.