Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
.vscode
*.bak
5 changes: 4 additions & 1 deletion src/mfast/coder/encoder/fast_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,11 @@ void fast_encoder_impl::visit(message_cref cref, bool force_reset) {
aggregate_cref message(cref.field_storage(0), instruction);

for (auto &&field : message)
if (field.present() || field.instruction()->field_operator() == operator_none)
{
const operator_enum_t op = field.instruction()->field_operator();
if (field.present() || op == operator_none || op == operator_default || (op == operator_constant && field.instruction()->pmap_size() > 0))
apply_accessor(*this, field);
}

pmap.commit();
}
Expand Down
1 change: 1 addition & 0 deletions src/mfast/field_mref.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ template <typename T> void field_mref::as(T value) {
static_cast<uint64_mref>(*this).as(static_cast<uint64_t>(value));
break;
case field_type_decimal:
case field_type_exponent:
static_cast<decimal_mref>(*this).as(value);
break;
default:
Expand Down
21 changes: 21 additions & 0 deletions tests/coder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,24 @@ TEST_CASE("test fast coder for a template with zero segment size", "[segment_pma
}


TEST_CASE("test fast coder without code generation for a simple template with constant and default","[manual_reset_test]")
{
fast_coding_test_case test_case (
"<?xml version=\" 1.0 \"?>\n"
"<templates xmlns=\"http://www.fixprotocol.org/ns/template-definition\" "
"templateNs=\"http://www.fixprotocol.org/ns/templates/sample\" ns=\"http://www.fixprotocol.org/ns/fix\">\n"
"<template name=\"Test\" id=\"1\">\n"
"<uInt32 name=\"field1\" id=\"11\"><constant value=\"77\"/></uInt32>\n"
"<uInt32 name=\"field2\" id=\"12\" presence=\"optional\"><default value=\"50\"/></uInt32>\n"
"<uInt32 name=\"field3\" id=\"13\" presence=\"optional\"><constant value=\"89\"/></uInt32>\n"
"</template>\n"
"</templates>\n");

debug_allocator alloc;
message_type msg(&alloc, test_case.template_with_id(1));
message_mref msg_ref = msg.mref();

// Not setting fields...
REQUIRE(test_case.encoding(msg_ref, "\xa0\x80"));
REQUIRE(test_case.decoding("\xa0\x80", msg_ref));
}