sbepp
Loading...
Searching...
No Matches
sbepp::message_traits< T > Class Template Reference

Provides various traits/attributes of a <message> element. More...

Public Types

template<typename Byte >
using value_type = MessageType<Byte>
 Representation type.
 
using schema_tag = SchemaTag
 Schema tag.
 

Static Public Member Functions

static constexpr const char * name () noexcept
 Returns name attribute.
 
static constexpr const char * description () noexcept
 Returns description attribute.
 
static constexpr message_id_t id () noexcept
 Returns id attribute.
 
static constexpr block_length_t block_length () noexcept
 Returns blockLength attribute.
 
static constexpr const char * semantic_type () noexcept
 Returns semanticType attribute.
 
static constexpr version_t since_version () noexcept
 Returns addedSince attribute.
 
static constexpr version_t deprecated () noexcept
 Returns deprecated attribute. Available only if provided in schema.
 
static constexpr std::size_t size_bytes (...) noexcept
 Returns number of bytes required to represent the message in given configuration.
 

Detailed Description

template<typename T>
class sbepp::message_traits< T >

Provides various traits/attributes of a <message> element.

For example: sbepp::message_traits<market_schema::schema::messages::msg1>::name();

Template Parameters
Tmessage tag

Member Typedef Documentation

◆ value_type

template<typename T >
template<typename Byte >
using sbepp::message_traits< T >::value_type = MessageType<Byte>

Representation type.

Template Parameters
Bytebyte type

Member Function Documentation

◆ size_bytes()

template<typename T >
static constexpr std::size_t sbepp::message_traits< T >::size_bytes ( ...)
staticconstexprnoexcept

Returns number of bytes required to represent the message in given configuration.

Parameters
...parameter list depends on the message structure
Returns
size in bytes

Parameter list is built as follows:

  • for each <group> within the message, in a top-to-bottom order, there will be a parameter in form of NumInGroupType <group_path>_num_in_group[_<n>] where <group_path> is built like <parent_group_path>_<child_group_name>. Optional _<n> part is added to disambiguate names that otherwise would be the same. This parameter represents the total number of group entries (even if they are spread across multiple enclosing group entries).
  • if there exists a <data> member on any level within the message, there will be additional std::size_t total_data_size parameter at the end of parameter list, representing the total payload size from all the <data> elements within the message.

Here's the example with different cases:

<!-- size_bytes() -->
<sbe:message>
<!-- only fields... -->
</sbe:message>
<!-- size_bytes(std::uint32_t group_num_in_group) -->
<sbe:message>
<group name="group">
<!-- only fields... -->
</group>
</sbe:message>
<!-- size_bytes(
std::uint32_t group_1_num_in_group,
std::uint32_t group_2_num_in_group) -->
<sbe:message>
<group name="group_1">
<!-- only fields... -->
</group>
<group name="group_2">
<!-- only fields... -->
</group>
</sbe:message>
<!-- size_bytes(
std::uint32_t group_1_num_in_group,
std::uint32_t group_1_group_2_num_in_group,
std::uint32_t group_3_num_in_group) -->
<sbe:message>
<group name="group_1">
<group name="group_2">
<!-- only fields... -->
</group>
</group>
<group name="group_3">
<!-- only fields... -->
</group>
</sbe:message>
<!-- size_bytes(
std::uint32_t group_num_in_group,
std::size_t total_data_size) -->
<sbe:message>
<group name="group">
<data name="data_1"/>
</group>
<data name="data_2"/>
</sbe:message>

For usage example, see Estimating buffer size to encode a message.

Warning
This function provides correct results only for the current schema version.

The documentation for this class was generated from the following file: