Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run: curl -L https://archives.boost.io/release/1.72.0/source/boost_1_72_0.tar.gz | tar zx
shell: bash
- name: configure
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DXETRA_FAST_SPECIFICATION=ON
- name: build
run: cmake --build build --parallel 2
- name: test
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ project (mFAST VERSION 1.3.0 LANGUAGES CXX)
option(BUILD_TESTS "Build tests" ON)
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_PACKAGES "Build packages" ON)
option(XETRA_FAST_SPECIFICATION "Xetra Fast 1.2 specification" OFF)

# global options
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
Expand Down Expand Up @@ -96,4 +97,5 @@ message(STATUS "BUILD_SHARED_LIBS: " ${BUILD_SHARED_LIBS})
message(STATUS "BUILD_TESTS: " ${BUILD_TESTS})
message(STATUS "BUILD_EXAMPLES: " ${BUILD_EXAMPLES})
message(STATUS "BUILD_PACKAGES: " ${BUILD_PACKAGES})
message(STATUS "XETRA_FAST_SPECIFICATION: " ${XETRA_FAST_SPECIFICATION})
message(STATUS "")
1 change: 1 addition & 0 deletions src/mfast/coder/decoder/fast_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ message_type *fast_decoder_impl::decode_segment(fast_istreambuf &sb) {
for (auto &&field : message->ref()) {
apply_mutator(*this, field);
}
this->current_ = nullptr;
return message;
}

Expand Down
10 changes: 10 additions & 0 deletions src/mfast/enum_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class MFAST_EXPORT enum_cref : public field_cref {
}
bool is_boolean() const;

protected:
friend class mfast::detail::codec_helper;

void save_to(value_storage &v) const {
v.of_uint64.content_ = this->storage()->of_uint64.content_;
v.defined(true);
v.present(this->present());
}

private:
enum_cref &operator=(const enum_cref &);
};
Expand All @@ -70,6 +79,7 @@ class enum_mref : public make_field_mref<enum_cref> {

enum_mref(const enum_mref &) = default;

explicit enum_mref(const field_mref_base &other) : base_type(other) {}
void as(const enum_cref &cref) const {
if (cref.absent()) {
this->omit();
Expand Down
2 changes: 0 additions & 2 deletions src/mfast/ext_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,10 @@ class ext_mref : public ext_ref_properties<OpType, Properties> {
storage->present(true);
}
return mref_type(base_);
;
}

cref_type get() const {
return cref_type(base_);
;
}

bool present() const { return !this->optional() || base_.present(); }
Expand Down
9 changes: 9 additions & 0 deletions src/mfast/xml_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ if (UNIX)
set_target_properties(mfast_xml_parser_static PROPERTIES OUTPUT_NAME mfast_xml_parser)
endif()


if(XETRA_FAST_SPECIFICATION)
target_compile_definitions(mfast_xml_parser_static PRIVATE XETRA_FAST_SPECIFICATION)
endif(XETRA_FAST_SPECIFICATION)

install(TARGETS mfast_xml_parser_static
EXPORT mFASTTargets
FILE_SET HEADERS)
Expand All @@ -40,6 +45,10 @@ if (BUILD_SHARED_LIBS)
set_property(TARGET mfast_xml_parser PROPERTY VERSION ${MFAST_VERSION})
set_property(TARGET mfast_xml_parser PROPERTY SOVERSION ${MFAST_VERSION})

if(XETRA_FAST_SPECIFICATION)
target_compile_definitions(mfast_xml_parser PRIVATE XETRA_FAST_SPECIFICATION)
endif(XETRA_FAST_SPECIFICATION)

install(TARGETS mfast_xml_parser
EXPORT mFASTTargets
FILE_SET HEADERS)
Expand Down
7 changes: 7 additions & 0 deletions src/mfast/xml_parser/templates_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ templates_builder::templates_builder(dynamic_templates_description *definition,
string_value_storage());
this->member["string"] = &ascii_field_instruction_prototype;

#ifdef XETRA_FAST_SPECIFICATION
static const int64_field_instruction timestamp_field_instruction_prototype(
operator_none, presence_mandatory, 0, nullptr, "", nullptr,
int_value_storage<int64_t>());
this->member["timestamp"] = &timestamp_field_instruction_prototype;
#endif

static const byte_vector_field_instruction
byte_vector_field_instruction_prototype(
operator_none, presence_mandatory, 0, nullptr, "", nullptr,
Expand Down
19 changes: 18 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ FASTTYPEGEN_TARGET(simple_types12 simple12.xml)
FASTTYPEGEN_TARGET(simple_types13 simple13.xml)
FASTTYPEGEN_TARGET(simple_types14 simple14.xml)
FASTTYPEGEN_TARGET(simple_types15 simple15.xml)
FASTTYPEGEN_TARGET(simple_types16 simple16.xml)

if(XETRA_FAST_SPECIFICATION)
FASTTYPEGEN_TARGET(simple_types17 simple17.xml)
endif(XETRA_FAST_SPECIFICATION)

FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
FASTTYPEGEN_TARGET(test_types3 test3.xml)
FASTTYPEGEN_TARGET(test_types4 test4.xml)
FASTTYPEGEN_TARGET(test_types5 test5.xml)
FASTTYPEGEN_TARGET(test_scp scp.xml)

add_executable (mfast_test
set(test_sources
test_main.cpp
arena_allocator_test.cpp
field_ref_test.cpp
Expand Down Expand Up @@ -70,6 +74,7 @@ add_executable (mfast_test
${FASTTYPEGEN_simple_types13_OUTPUTS}
${FASTTYPEGEN_simple_types14_OUTPUTS}
${FASTTYPEGEN_simple_types15_OUTPUTS}
${FASTTYPEGEN_simple_types16_OUTPUTS}
fast_type_gen_test.cpp
dictionary_builder_test.cpp
json_test.cpp
Expand All @@ -82,8 +87,20 @@ add_executable (mfast_test
scp_reset_test.cpp
template_repo_base.cpp
message_pmap_test.cpp
enum_encoder_decoder_v2.cpp
enum_encoder_decoder.cpp
)

if(XETRA_FAST_SPECIFICATION)
set(test_sources ${test_sources}
${FASTTYPEGEN_simple_types17_OUTPUTS}
timestamp_encoder_decoder_v2.cpp
timestamp_encoder_decoder.cpp
)
endif(XETRA_FAST_SPECIFICATION)

add_executable (mfast_test ${test_sources})

target_link_libraries (mfast_test
mfast_static
mfast_coder_static
Expand Down
19 changes: 19 additions & 0 deletions tests/enum_encoder_decoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "catch.hpp"
#include <mfast.h>

#include "fast_test_coding_case.hpp"
#include "byte_stream.h"

#include "simple16.h"

using namespace test::coding;

TEST_CASE("enum test encoder/decoder","[enum_encoder_decoder]")
{
fast_test_coding_case<simple16::templates_description> test_case;
simple16::Test_1 test_1;
simple16::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_discrete().as_Three();
REQUIRE(test_case.encoding(test_1.cref(),"\xC0\x81\x83",true));
REQUIRE(test_case.decoding("\xC0\x81\x83",test_1.cref(),true));
}
19 changes: 19 additions & 0 deletions tests/enum_encoder_decoder_v2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "catch.hpp"
#include <mfast.h>

#include "fast_test_coding_case_v2.hpp"
#include "byte_stream.h"

#include "simple16.h"

using namespace test::coding;

TEST_CASE("enum test encoder_V2/decoder_v2","[enum_encoder_v2_decoder_v2]")
{
fast_test_coding_case_v2<simple16::templates_description> test_case;
simple16::Test_1 test_1;
simple16::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_discrete().as_Three();
REQUIRE(test_case.encoding(test_1.cref(),"\xC0\x81\x83",true));
REQUIRE(test_case.decoding("\xC0\x81\x83",test_1.cref(),true));
}
2 changes: 1 addition & 1 deletion tests/fast_test_coding_case.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class fast_test_coding_case
if (result == byte_stream(buffer, encoded_size))
return true;

INFO( "Got \"" << byte_stream(buffer, encoded_size) << "\" instead." );
INFO( "Got \"" << byte_stream(buffer, encoded_size) << "\" instead." );
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fast_test_coding_case_v2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class fast_test_coding_case_v2
if (result == byte_stream(buffer, encoded_size))
return true;

INFO( "Got \"" << byte_stream(buffer, encoded_size) << "\" instead." );
INFO( "Got \"" << byte_stream(buffer, encoded_size) << "\" instead." );
return false;
}

Expand Down
21 changes: 21 additions & 0 deletions tests/simple16.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates
xmlns="http://www.fixprotocol.org/ns/fast/td/1.2"
xmlns:scp="http://www.fixprotocol.org/ns/fast/scp/1.2"
templateNs="https://www.deutsche-boerse.com/rta">
<define name="DiscreteEnum">
<enum>
<element name="One" value="1"/>
<element name="Three" value="3"/>
<element name="Five" value="5"/>
</enum>
</define>
<!-- Define templates-->
<template name="Test_1" id="1">
<string name="MsgType" id="35"><constant value="DP"/></string>
<field name="discrete" id="2477"><type name="DiscreteEnum"></type></field>
</template>
<template name="Test_2" id="2">
<string name="MsgType" id="36"><constant value="DQ"/></string>
</template>
</templates>
14 changes: 14 additions & 0 deletions tests/simple17.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<templates xmlns="http://www.fixprotocol.org/ns/template-definition"
templateNs="http://www.fixprotocol.org/ns/templates/sample"
ns="http://www.fixprotocol.org/ns/fix">
<template name="Test_1" id="1">
<uInt32 name="field1" id="11"><copy/></uInt32>
<timestamp name="TransactTime" unit="nanosecond" id="60" presence="optional"><copy/></timestamp>
</template>
<template name="Test_2" id="2">
<uInt32 name="field4" id="21"><copy/></uInt32>
<uInt32 name="field5" id="22"><copy/></uInt32>
<uInt32 name="field6" id="23"><copy/></uInt32>
</template>
</templates>
23 changes: 23 additions & 0 deletions tests/timestamp_encoder_decoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "catch.hpp"
#include <mfast.h>

#include "fast_test_coding_case.hpp"
#include "byte_stream.h"

#include "simple17.h"

using namespace test::coding;

TEST_CASE("timestamp test encoder/decoder","[timestamp_encoder_decoder]")
{
fast_test_coding_case<simple17::templates_description> test_case;
simple17::Test_1 test_1;
simple17::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_field1().as(1);
test_1_mref.set_TransactTime().as(2);
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x81\x83",true));
REQUIRE(test_case.decoding("\xF0\x81\x81\x83",test_1.cref(),true));
}



20 changes: 20 additions & 0 deletions tests/timestamp_encoder_decoder_v2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "catch.hpp"
#include <mfast.h>

#include "fast_test_coding_case_v2.hpp"
#include "byte_stream.h"

#include "simple17.h"

using namespace test::coding;

TEST_CASE("timestamp test encoder_V2/decoder_v2","[timestamp_encoder_v2_decoder_v2]")
{
fast_test_coding_case_v2<simple17::templates_description> test_case;
simple17::Test_1 test_1;
simple17::Test_1_mref test_1_mref = test_1.mref();
test_1_mref.set_field1().as(1);
test_1_mref.set_TransactTime().as(2);
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x81\x83",true));
REQUIRE(test_case.decoding("\xF0\x81\x81\x83",test_1.cref(),true));
}