Imported from previous forum
Hi,
How do I know if after a PMAP I will have to decode a TemplateID or not? I wanted to code a generic function “DecodeSegment(…)” like
Decoder::DecodeSegment(params)
{
LoadPresenceMAP(); /// PMAP stuff
u32 TID = DecodeTemplateID(); /// But will I have a template ID here ???
Template * pTemplate = Templates::GetTemplate(TID);
pTemplate->Decode(); /// DecodeSegment might be recursively called here, because of sequence elements and groups encoded as segment in stream
}
But it seems this cannot be done because I need to know where I am in a Template.
In other words, how to know while decoding a segment, if this segment is described by a template, or if this segment is the stream of a sequence element / group.
This is maybe completly wrong, but I was more expecting something like this :
stream ::= message* | block*
block ::= BlockSize message+
message ::= segment
segment ::= PresenceMap TemplateIdentifier (field | segment_no_tid)*
segment_no_tid ::= PresenceMap (field | segment_no_tid)*
field ::= integer | string | delta | ScaledNumber | ByteVector
integer ::= UnsignedInteger | SignedInteger
string ::= ASCIIString | UnicodeString
delta ::= IntegerDelta | ScaledNumberDelta | ASCIIStringDelta | ByteVectorDelta
Thanks in advance,
Regards.
How do I know if after a PMAP I will have to decode a TemplateID or not?
The only time that a template id appears in a segment is at the start of a new message, or when a dynamic template reference is encountered. When decoding groups or sequences, segments do not contain a template id.
From Section 10 - Transfer Encoding:
“A segment has a header consisting of a Presence Map followed by an optional Template Identifier. The segment has a template identifier either if it is a message segment, or if the segment appears as the result of a dynamic template reference instruction.”
Your expectations would be correct if not for the dynamic template reference instruction.
Jake
Thank you for that fast answer.
This is clear now.
Olivier
How do I know if after a PMAP I will have to decode a
TemplateID or not?The only time that a template id appears in a segment is at the start of
a new message, or when a dynamic template reference is encountered. When
decoding groups or sequences, segments do not contain a template id.From Section 10 - Transfer Encoding:
“A segment has a header consisting of a Presence Map followed by an
optional Template Identifier. The segment has a template identifier
either if it is a message segment, or if the segment appears as the
result of a dynamic template reference instruction.”Your expectations would be correct if not for the dynamic template
reference instruction.Jake