TSDuck v3.40-4034
MPEG Transport Stream Toolkit
|
Factory class for TLV messages. More...
#include <tstlvMessageFactory.h>
Classes | |
class | Parameter |
Location of one parameter value inside the message block. More... | |
Public Member Functions | |
MessageFactory (const ByteBlock &bb, const Protocol &protocol) | |
Constructor: Analyze a TLV message in memory. | |
MessageFactory (const void *addr, size_t size, const Protocol &protocol) | |
Constructor: Analyze a TLV message in memory. | |
void | buildErrorResponse (MessagePtr &msg) const |
Return the error response for the peer. | |
TAG | commandTag () const |
Get the message tag. | |
size_t | count (TAG tag) const |
Get actual number of occurences of a parameter. | |
uint16_t | errorInformation () const |
Get the "error information" resulting from the analysis of the message. | |
MessagePtr | errorResponse () const |
Return the error response for the peer. | |
tlv::Error | errorStatus () const |
Get the "error status" resulting from the analysis of the message. | |
MessagePtr | factory () const |
Return the fully rebuilt message. | |
void | factory (MessagePtr &msg) const |
Return the fully rebuilt message. | |
template<typename INT > requires std::integral<INT> | |
INT | get (TAG tag) const |
Get an integer parameter. | |
void | get (TAG tag, ByteBlock ¶m) const |
Get an opaque byte block parameter. | |
void | get (TAG tag, Parameter ¶m) const |
Get the location of a parameter. | |
void | get (TAG tag, std::string ¶m) const |
Get a string parameter. | |
void | get (TAG tag, std::vector< bool > ¶m) const |
Get a boolean parameter. | |
template<typename INT > requires std::integral<INT> | |
void | get (TAG tag, std::vector< INT > ¶m) const |
Get an integer parameter. | |
void | get (TAG tag, std::vector< Parameter > ¶m) const |
Get the location of all occurences of a parameter. | |
void | get (TAG tag, std::vector< std::string > ¶m) const |
Get a string parameter. | |
void | getCompound (TAG tag, MessagePtr ¶m) const |
Get a compound TLV parameter. | |
template<class MSG > | |
void | getCompound (TAG tag, MSG ¶m) const |
Get a compound TLV parameter (template version). | |
void | getCompound (TAG tag, std::vector< MessagePtr > ¶m) const |
Get a compound TLV parameter. | |
template<class MSG > | |
void | getCompound (TAG tag, std::vector< MSG > ¶m) const |
Get a compound TLV parameter (template version). | |
VERSION | protocolVersion () const |
Get the protocol version number. | |
Factory class for TLV messages.
The following methods should be used by the application to deserialize messages:
The following types and methods should be used by the constructors of the ts::tlv::Message subclasses.
The get() and getCompound() methods retrieve the value of parameters. For each parameter type, two versions are available.
An exception is thrown when the parameter is not present (first version) or when the actual size of the parameter does not match the expected size of the type. In both cases, this should not happen in properly written message classes since the validity of the parameters were checked by the constructor of the MessageFactory.
ts::tlv::MessageFactory::MessageFactory | ( | const void * | addr, |
size_t | size, | ||
const Protocol & | protocol | ||
) |
Constructor: Analyze a TLV message in memory.
[in] | addr | Address of a binary TLV message. |
[in] | size | Size in bytes of the message. |
[in] | protocol | The message is validated according to this protocol. |
Constructor: Analyze a TLV message in memory.
[in] | bb | Binary TLV message. |
[in] | protocol | The message is validated according to this protocol. |
|
inline |
Get the "error status" resulting from the analysis of the message.
|
inline |
Get the "error information" resulting from the analysis of the message.
|
inline |
Get the message tag.
|
inline |
Get the protocol version number.
void ts::tlv::MessageFactory::factory | ( | MessagePtr & | msg | ) | const |
Return the fully rebuilt message.
Valid only when errorStatus() == OK.
[out] | msg | Safe pointer to the rebuilt message. Set a null pointer on error. |
MessagePtr ts::tlv::MessageFactory::factory | ( | ) | const |
Return the fully rebuilt message.
Valid only when errorStatus() == OK.
void ts::tlv::MessageFactory::buildErrorResponse | ( | MessagePtr & | msg | ) | const |
Return the error response for the peer.
Valid only when errorStatus() != OK.
[out] | msg | Safe pointer to the error response message. Set a null pointer without error. |
MessagePtr ts::tlv::MessageFactory::errorResponse | ( | ) | const |
Return the error response for the peer.
Valid only when errorStatus() != OK.
|
inline |
Get actual number of occurences of a parameter.
[in] | tag | Parameter tag to search. |
Get the location of a parameter.
Address and size point into the original message buffer, use with care!
[in] | tag | Parameter tag to search. |
[out] | param | Description of the parameter value. |
Get the location of all occurences of a parameter.
Address and size point into the original message buffer, use with care!
[in] | tag | Parameter tag to search. |
[out] | param | Vector of descriptions of the parameter values. |
void ts::tlv::MessageFactory::get | ( | TAG | tag, |
std::vector< bool > & | param | ||
) | const |
Get a boolean parameter.
This method returns a vector of booleans. For one single boolean value, use the template version.
[in] | tag | Parameter tag to search. |
[out] | param | All parameter values. |
|
inline |
void ts::tlv::MessageFactory::get | ( | TAG | tag, |
std::vector< std::string > & | param | ||
) | const |
Get a string parameter.
[in] | tag | Parameter tag to search. |
[out] | param | All parameter values. |
void ts::tlv::MessageFactory::getCompound | ( | TAG | tag, |
MessagePtr & | param | ||
) | const |
Get a compound TLV parameter.
[in] | tag | Parameter tag to search. |
[out] | param | Safe pointer to the parameter value. |
void ts::tlv::MessageFactory::getCompound | ( | TAG | tag, |
std::vector< MessagePtr > & | param | ||
) | const |
Get a compound TLV parameter.
[in] | tag | Parameter tag to search. |
[out] | param | Vector of safe pointers to all parameter values. |
void ts::tlv::MessageFactory::getCompound | ( | TAG | tag, |
MSG & | param | ||
) | const |
Get a compound TLV parameter (template version).
MSG | Expected class of parameter value, a subclass of ts::tlv::Message. |
void ts::tlv::MessageFactory::getCompound | ( | TAG | tag, |
std::vector< MSG > & | param | ||
) | const |
Get a compound TLV parameter (template version).
MSG | Expected class of parameter value, a subclass of ts::tlv::Message. |
[in] | tag | Parameter tag to search. |
[out] | param | Vector of all parameter values. |