Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

fix impossibility of a compound choice inside a set/sequence#34

Open
GrigoriySokolov wants to merge 1 commit intocppden:master from
GrigoriySokolov:M_compound_choice_in_container
Open

fix impossibility of a compound choice inside a set/sequence #34
GrigoriySokolov wants to merge 1 commit intocppden:master from
GrigoriySokolov:M_compound_choice_in_container

Conversation

@GrigoriySokolov
Copy link

@GrigoriySokolov GrigoriySokolov commented Apr 11, 2025

  • The bug was inspired by N1 codec migration to the new version of MED. As it was discovered, a med::choice with a compound header could not be placed into a med::set or med::sequence as a mandatory member.

  • It happened because of a process of postponed compound header tag filling. A tag was filled out during a med::choice encode process, just before encoding. That is, by the moment an outer container encoding, the choice header tag remained untouched. Hereby, pre-encode check of all mandatory fields filled caused an error reporting the emptyness of the mandatory field.

  • The fix moves the compound header tag filling from the encode stage to the earlier stage, namely while choice::ref() API is called.

  • this change a protocol of working with a choice. Now a user can call med::choice::ref() only once. To reuse a choice / refill some choice member, med::choice::clear() must be called prior to it..

  • The change also requires to distinguish a context within the ref() call happens. The decode stage, when the choice::ref() API is called by the engine, is the case. During the choice::ref call the header tag was already filled by the recent binary data reading and must not be touched.

  • To achieve it the new member method bool is_tag_set() was introduced. The new method must be presented in every class/struct where the get_tag() method is defined.

- The bug was inspired by N1 codec migration to the new version of MED.
As it was discovered, a med::choice with a compound header could not be
placed into a med::set or med::sequence as a mandatory member.
- It happened because of a process of postponed compound header tag filling.
A tag was filled out during a med::choice encode process, just before
encoding. That is, by the moment an outer container encoding, the choice
header tag remained untouched. Hereby, pre-encode check of all mandatory
fields filled caused an error reporting the emptyness of the mandatory
field.
- The fix moves the compound header tag filling from the encode stage to
 the earlier stage, namely while choice::ref() API is called.
- this change a protocol of working with a choice. Now a user can call
med::choice::ref() only once. To reuse a choice / refill some choice
member, med::choice::clear() must be called prior to it..
- The change also requires to distinguish a context within the ref()
 call happens. The decode stage, when the choice::ref() API is called
by the engine, is the case. During the choice::ref call the header tag
was already filled by the recent binary data reading and must not be
touched.
- To achieve it the new member method bool is_tag_set() was introduced.
 The new method must be presented in every class/struct where the
get_tag() method is defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /