Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ksergey committed Oct 20, 2024
1 parent dce9769 commit 1aaa5ac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/generation/cppng/templates/generate.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ public:

explicit constexpr {{ enum_class_name }}({{ underlying_type }} value) noexcept : value_(value) {}

[[nodiscard]] constexpr {{ underlying_type }} rawValue() const noexcept {
return value_;
}

constexpr void setRawValue({{ underlying_type }} value) noexcept {
value_ = value;
}

[[nodiscard]] constexpr enumerated value() const noexcept {
return enumerated(value_);
}
Expand Down Expand Up @@ -255,7 +263,7 @@ public:
{{ composite_definition(contained_type) | indent(2) }}
{% endif %}

{% endfor %}
{%- endfor %}
using Fields = MP_List<
{% for contained_type in type.contained_types %}
MP_Pair<MP_Str<"{{ contained_type.reference_name }}">, {{ field_encoding(contained_type) }}>{% if not loop.last %},{% endif +%}
Expand Down
14 changes: 14 additions & 0 deletions tests/real-logic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ std::size_t encodeMessageHeader(MessageHeader& header) noexcept {
return header.encodedLength();
}

std::size_t encodeCar(Car& body) {
body.field<"serialNumber">().setValue(1234);
body.field<"modelYear">().setValue(2013);
body.field<"available">().setValue(BooleanType::T);
body.field<"code">().setValue(Model::A);
body.field<"vehicleCode">().setValue("abcdef");
{
std::array<std::uint32_t, 4> data = {0, 1, 2, 3};
body.field<"someNumbers">().setValue(std::span(data));
}

return body.encodedLength();
}

TEST_CASE("MessageHeader") {
std::array<std::byte, 4096> storage;

Expand Down

0 comments on commit 1aaa5ac

Please sign in to comment.