Skip to content

Commit b4f4376

Browse files
Merge pull request #156 from martinfantini/xetra_fast_timestamp
Xetra fast timestamp
2 parents e5093f5 + cbad7d6 commit b4f4376

File tree

8 files changed

+91
-2
lines changed

8 files changed

+91
-2
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
run: curl -L https://archives.boost.io/release/1.72.0/source/boost_1_72_0.tar.gz | tar zx
1717
shell: bash
1818
- name: configure
19-
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
19+
run: cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DXETRA_FAST_SPECIFICATION=ON
2020
- name: build
2121
run: cmake --build build --parallel 2
2222
- name: test

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ project (mFAST VERSION 1.3.0 LANGUAGES CXX)
99
option(BUILD_TESTS "Build tests" ON)
1010
option(BUILD_EXAMPLES "Build examples" ON)
1111
option(BUILD_PACKAGES "Build packages" ON)
12+
option(XETRA_FAST_SPECIFICATION "Xetra Fast 1.2 specification" OFF)
1213

1314
# global options
1415
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
@@ -96,4 +97,5 @@ message(STATUS "BUILD_SHARED_LIBS: " ${BUILD_SHARED_LIBS})
9697
message(STATUS "BUILD_TESTS: " ${BUILD_TESTS})
9798
message(STATUS "BUILD_EXAMPLES: " ${BUILD_EXAMPLES})
9899
message(STATUS "BUILD_PACKAGES: " ${BUILD_PACKAGES})
100+
message(STATUS "XETRA_FAST_SPECIFICATION: " ${XETRA_FAST_SPECIFICATION})
99101
message(STATUS "")

src/mfast/xml_parser/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ if (UNIX)
2222
set_target_properties(mfast_xml_parser_static PROPERTIES OUTPUT_NAME mfast_xml_parser)
2323
endif()
2424

25+
26+
if(XETRA_FAST_SPECIFICATION)
27+
target_compile_definitions(mfast_xml_parser_static PRIVATE XETRA_FAST_SPECIFICATION)
28+
endif(XETRA_FAST_SPECIFICATION)
29+
2530
install(TARGETS mfast_xml_parser_static
2631
EXPORT mFASTTargets
2732
FILE_SET HEADERS)
@@ -40,6 +45,10 @@ if (BUILD_SHARED_LIBS)
4045
set_property(TARGET mfast_xml_parser PROPERTY VERSION ${MFAST_VERSION})
4146
set_property(TARGET mfast_xml_parser PROPERTY SOVERSION ${MFAST_VERSION})
4247

48+
if(XETRA_FAST_SPECIFICATION)
49+
target_compile_definitions(mfast_xml_parser PRIVATE XETRA_FAST_SPECIFICATION)
50+
endif(XETRA_FAST_SPECIFICATION)
51+
4352
install(TARGETS mfast_xml_parser
4453
EXPORT mFASTTargets
4554
FILE_SET HEADERS)

src/mfast/xml_parser/templates_builder.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ templates_builder::templates_builder(dynamic_templates_description *definition,
6767
string_value_storage());
6868
this->member["string"] = &ascii_field_instruction_prototype;
6969

70+
#ifdef XETRA_FAST_SPECIFICATION
71+
static const int64_field_instruction timestamp_field_instruction_prototype(
72+
operator_none, presence_mandatory, 0, nullptr, "", nullptr,
73+
int_value_storage<int64_t>());
74+
this->member["timestamp"] = &timestamp_field_instruction_prototype;
75+
#endif
76+
7077
static const byte_vector_field_instruction
7178
byte_vector_field_instruction_prototype(
7279
operator_none, presence_mandatory, 0, nullptr, "", nullptr,

tests/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ FASTTYPEGEN_TARGET(simple_types14 simple14.xml)
2626
FASTTYPEGEN_TARGET(simple_types15 simple15.xml)
2727
FASTTYPEGEN_TARGET(simple_types16 simple16.xml)
2828

29+
if(XETRA_FAST_SPECIFICATION)
30+
FASTTYPEGEN_TARGET(simple_types17 simple17.xml)
31+
endif(XETRA_FAST_SPECIFICATION)
32+
2933
FASTTYPEGEN_TARGET(test_types1 test1.xml test2.xml)
3034
FASTTYPEGEN_TARGET(test_types3 test3.xml)
3135
FASTTYPEGEN_TARGET(test_types4 test4.xml)
3236
FASTTYPEGEN_TARGET(test_types5 test5.xml)
3337
FASTTYPEGEN_TARGET(test_scp scp.xml)
3438

35-
add_executable (mfast_test
39+
set(test_sources
3640
test_main.cpp
3741
arena_allocator_test.cpp
3842
field_ref_test.cpp
@@ -87,6 +91,16 @@ add_executable (mfast_test
8791
enum_encoder_decoder.cpp
8892
)
8993

94+
if(XETRA_FAST_SPECIFICATION)
95+
set(test_sources ${test_sources}
96+
${FASTTYPEGEN_simple_types17_OUTPUTS}
97+
timestamp_encoder_decoder_v2.cpp
98+
timestamp_encoder_decoder.cpp
99+
)
100+
endif(XETRA_FAST_SPECIFICATION)
101+
102+
add_executable (mfast_test ${test_sources})
103+
90104
target_link_libraries (mfast_test
91105
mfast_static
92106
mfast_coder_static

tests/simple17.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
<templates xmlns="http://www.fixprotocol.org/ns/template-definition"
3+
templateNs="http://www.fixprotocol.org/ns/templates/sample"
4+
ns="http://www.fixprotocol.org/ns/fix">
5+
<template name="Test_1" id="1">
6+
<uInt32 name="field1" id="11"><copy/></uInt32>
7+
<timestamp name="TransactTime" unit="nanosecond" id="60" presence="optional"><copy/></timestamp>
8+
</template>
9+
<template name="Test_2" id="2">
10+
<uInt32 name="field4" id="21"><copy/></uInt32>
11+
<uInt32 name="field5" id="22"><copy/></uInt32>
12+
<uInt32 name="field6" id="23"><copy/></uInt32>
13+
</template>
14+
</templates>

tests/timestamp_encoder_decoder.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "catch.hpp"
2+
#include <mfast.h>
3+
4+
#include "fast_test_coding_case.hpp"
5+
#include "byte_stream.h"
6+
7+
#include "simple17.h"
8+
9+
using namespace test::coding;
10+
11+
TEST_CASE("timestamp test encoder/decoder","[timestamp_encoder_decoder]")
12+
{
13+
fast_test_coding_case<simple17::templates_description> test_case;
14+
simple17::Test_1 test_1;
15+
simple17::Test_1_mref test_1_mref = test_1.mref();
16+
test_1_mref.set_field1().as(1);
17+
test_1_mref.set_TransactTime().as(2);
18+
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x81\x83",true));
19+
REQUIRE(test_case.decoding("\xF0\x81\x81\x83",test_1.cref(),true));
20+
}
21+
22+
23+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "catch.hpp"
2+
#include <mfast.h>
3+
4+
#include "fast_test_coding_case_v2.hpp"
5+
#include "byte_stream.h"
6+
7+
#include "simple17.h"
8+
9+
using namespace test::coding;
10+
11+
TEST_CASE("timestamp test encoder_V2/decoder_v2","[timestamp_encoder_v2_decoder_v2]")
12+
{
13+
fast_test_coding_case_v2<simple17::templates_description> test_case;
14+
simple17::Test_1 test_1;
15+
simple17::Test_1_mref test_1_mref = test_1.mref();
16+
test_1_mref.set_field1().as(1);
17+
test_1_mref.set_TransactTime().as(2);
18+
REQUIRE(test_case.encoding(test_1.cref(),"\xF0\x81\x81\x83",true));
19+
REQUIRE(test_case.decoding("\xF0\x81\x81\x83",test_1.cref(),true));
20+
}

0 commit comments

Comments
 (0)