TSDuck Version 3.32-2769 (TSDuck - The MPEG Transport Stream Toolkit)
ts::tlv::Serializer Class Reference

Serialization of TLV messages. More...

Public Member Functions

 Serializer (const ByteBlockPtr &bb)
 Constructor. More...
 
 Serializer (const Serializer &s)
 Constructor. More...
 
 ~Serializer ()
 Destructor. More...
 
void closeTLV ()
 Close a TLV structure. More...
 
void openTLV (TAG tag)
 Open a TLV structure. More...
 
void put (const ByteBlock &bl)
 Insert a byte block in the stream. More...
 
void put (const std::string &val)
 Insert a string in the stream. More...
 
void put (const void *pval, size_t len)
 Insert raw data in the stream. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void put (INT i)
 Insert an integer value in the stream (template variant). More...
 
void put (TAG tag, const ByteBlock &bl)
 Insert a TLV field containing a byte block in the stream. More...
 
void put (TAG tag, const std::string &val)
 Insert a TLV field containing a string in the stream. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void put (TAG tag, const std::vector< INT > &val)
 Insert a TLV field containing a vector of integer values in the stream (template variant). More...
 
void put (TAG tag, const std::vector< std::string > &val)
 Insert a TLV field containing a vector of strings in the stream. More...
 
void put (TAG tag, const void *pval, size_t len)
 Insert a TLV field containing raw data in the stream. More...
 
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void put (TAG tag, INT i)
 Insert a TLV field containing an integer value in the stream (template variant). More...
 
void putBool (bool val)
 Insert a boolean value in the stream. More...
 
void putBool (TAG tag, bool val)
 Insert a TLV field containing a boolean value in the stream. More...
 
void putBool (TAG tag, const std::vector< bool > &val)
 Insert a TLV field containing a vector of boolean values in the stream. More...
 
void putInt16 (int16_t i)
 Insert a signed 16-bit integer value in the stream. More...
 
void putInt16 (TAG tag, const std::vector< int16_t > &v)
 Insert a TLV field containing a vector of signed 16-bit integer values in the stream. More...
 
void putInt16 (TAG tag, int16_t i)
 Insert a TLV field containing a signed 16-bit integer value in the stream. More...
 
void putInt32 (int32_t i)
 Insert a signed 32-bit integer value in the stream. More...
 
void putInt32 (TAG tag, const std::vector< int32_t > &v)
 Insert a TLV field containing a vector of signed 32-bit integer values in the stream. More...
 
void putInt32 (TAG tag, int32_t i)
 Insert a TLV field containing a signed 32-bit integer value in the stream. More...
 
void putInt64 (int64_t i)
 Insert a signed 64-bit integer value in the stream. More...
 
void putInt64 (TAG tag, const std::vector< int64_t > &v)
 Insert a TLV field containing a vector of signed 64-bit integer values in the stream. More...
 
void putInt64 (TAG tag, int64_t i)
 Insert a TLV field containing a signed 64-bit integer value in the stream. More...
 
void putInt8 (int8_t i)
 Insert a signed 8-bit integer value in the stream. More...
 
void putInt8 (TAG tag, const std::vector< int8_t > &v)
 Insert a TLV field containing a vector of signed 8-bit integer values in the stream. More...
 
void putInt8 (TAG tag, int8_t i)
 Insert a TLV field containing a signed 8-bit integer value in the stream. More...
 
void putUInt16 (TAG tag, const std::vector< uint16_t > &v)
 Insert a TLV field containing a vector of unsigned 16-bit integer values in the stream. More...
 
void putUInt16 (TAG tag, uint16_t i)
 Insert a TLV field containing an unsigned 16-bit integer value in the stream. More...
 
void putUInt16 (uint16_t i)
 Insert an unsigned 16-bit integer value in the stream. More...
 
void putUInt32 (TAG tag, const std::vector< uint32_t > &v)
 Insert a TLV field containing a vector of unsigned 32-bit integer values in the stream. More...
 
void putUInt32 (TAG tag, uint32_t i)
 Insert a TLV field containing an unsigned 32-bit integer value in the stream. More...
 
void putUInt32 (uint32_t i)
 Insert an unsigned 16-bit integer value in the stream. More...
 
void putUInt64 (TAG tag, const std::vector< uint64_t > &v)
 Insert a TLV field containing a vector of unsigned 64-bit integer values in the stream. More...
 
void putUInt64 (TAG tag, uint64_t i)
 Insert a TLV field containing an unsigned 64-bit integer value in the stream. More...
 
void putUInt64 (uint64_t i)
 Insert an unsigned 64-bit integer value in the stream. More...
 
void putUInt8 (TAG tag, const std::vector< uint8_t > &v)
 Insert a TLV field containing a vector of unsigned 8-bit integer values in the stream. More...
 
void putUInt8 (TAG tag, uint8_t i)
 Insert a TLV field containing an unsigned 8-bit integer value in the stream. More...
 
void putUInt8 (uint8_t i)
 Insert an unsigned 8-bit integer value in the stream. More...
 
UString toString () const
 Convert to a string (for debug purpose). More...
 

Detailed Description

Serialization of TLV messages.

A DVB message is serialized in TLV into a ByteBlock. A Serializer is always associated to a ByteBlock.

Constructor & Destructor Documentation

◆ Serializer() [1/2]

ts::tlv::Serializer::Serializer ( const ByteBlockPtr bb)
inline

Constructor.

Associates an existing message block.

Parameters
[in]bbSafe pointer to an existing message block. The messages will be serialized in this block.

◆ Serializer() [2/2]

ts::tlv::Serializer::Serializer ( const Serializer s)
inline

Constructor.

Use the same message block as another Serializer. Useful to nest serializer when building compound TLV parameters.

Parameters
[in]sAnother serializer, will use the same byte block for serialization.

◆ ~Serializer()

ts::tlv::Serializer::~Serializer ( )
inline

Destructor.

Close potential pending TLV.

Member Function Documentation

◆ openTLV()

void ts::tlv::Serializer::openTLV ( TAG  tag)

Open a TLV structure.

The tag field and a placeholder for the length field are inserted. Cannot be nested in the same serializer. Use nested factories but not nested TLV into one serializer.

Parameters
[in]tagMessage or parameter tag.

◆ closeTLV()

void ts::tlv::Serializer::closeTLV ( )

Close a TLV structure.

The length field is updated.

◆ putUInt8() [1/3]

void ts::tlv::Serializer::putUInt8 ( uint8_t  i)
inline

Insert an unsigned 8-bit integer value in the stream.

Parameters
[in]iInteger value to insert.

◆ putUInt16() [1/3]

void ts::tlv::Serializer::putUInt16 ( uint16_t  i)
inline

Insert an unsigned 16-bit integer value in the stream.

Parameters
[in]iInteger value to insert.

◆ putUInt32() [1/3]

void ts::tlv::Serializer::putUInt32 ( uint32_t  i)
inline

Insert an unsigned 16-bit integer value in the stream.

Parameters
[in]iInteger value to insert.

◆ putUInt64() [1/3]

void ts::tlv::Serializer::putUInt64 ( uint64_t  i)
inline

Insert an unsigned 64-bit integer value in the stream.

Parameters
[in]iInteger value to insert.

◆ putInt8() [1/3]

void ts::tlv::Serializer::putInt8 ( int8_t  i)
inline

Insert a signed 8-bit integer value in the stream.

Parameters
[in]iInteger value to insert.

◆ putInt16() [1/3]

void ts::tlv::Serializer::putInt16 ( int16_t  i)
inline

Insert a signed 16-bit integer value in the stream.

Parameters
[in]iInteger value to insert.

◆ putInt32() [1/3]

void ts::tlv::Serializer::putInt32 ( int32_t  i)
inline

Insert a signed 32-bit integer value in the stream.

Parameters
[in]iInteger value to insert.

◆ putInt64() [1/3]

void ts::tlv::Serializer::putInt64 ( int64_t  i)
inline

Insert a signed 64-bit integer value in the stream.

Parameters
[in]iInteger value to insert.

◆ putUInt8() [2/3]

void ts::tlv::Serializer::putUInt8 ( TAG  tag,
uint8_t  i 
)
inline

Insert a TLV field containing an unsigned 8-bit integer value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ putUInt16() [2/3]

void ts::tlv::Serializer::putUInt16 ( TAG  tag,
uint16_t  i 
)
inline

Insert a TLV field containing an unsigned 16-bit integer value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ putUInt32() [2/3]

void ts::tlv::Serializer::putUInt32 ( TAG  tag,
uint32_t  i 
)
inline

Insert a TLV field containing an unsigned 32-bit integer value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ putUInt64() [2/3]

void ts::tlv::Serializer::putUInt64 ( TAG  tag,
uint64_t  i 
)
inline

Insert a TLV field containing an unsigned 64-bit integer value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ putInt8() [2/3]

void ts::tlv::Serializer::putInt8 ( TAG  tag,
int8_t  i 
)
inline

Insert a TLV field containing a signed 8-bit integer value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ putInt16() [2/3]

void ts::tlv::Serializer::putInt16 ( TAG  tag,
int16_t  i 
)
inline

Insert a TLV field containing a signed 16-bit integer value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ putInt32() [2/3]

void ts::tlv::Serializer::putInt32 ( TAG  tag,
int32_t  i 
)
inline

Insert a TLV field containing a signed 32-bit integer value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ putInt64() [2/3]

void ts::tlv::Serializer::putInt64 ( TAG  tag,
int64_t  i 
)
inline

Insert a TLV field containing a signed 64-bit integer value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ putUInt8() [3/3]

void ts::tlv::Serializer::putUInt8 ( TAG  tag,
const std::vector< uint8_t > &  v 
)

Insert a TLV field containing a vector of unsigned 8-bit integer values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]vVector of integer values to insert.

◆ putUInt16() [3/3]

void ts::tlv::Serializer::putUInt16 ( TAG  tag,
const std::vector< uint16_t > &  v 
)

Insert a TLV field containing a vector of unsigned 16-bit integer values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]vVector of integer values to insert.

◆ putUInt32() [3/3]

void ts::tlv::Serializer::putUInt32 ( TAG  tag,
const std::vector< uint32_t > &  v 
)

Insert a TLV field containing a vector of unsigned 32-bit integer values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]vVector of integer values to insert.

◆ putUInt64() [3/3]

void ts::tlv::Serializer::putUInt64 ( TAG  tag,
const std::vector< uint64_t > &  v 
)

Insert a TLV field containing a vector of unsigned 64-bit integer values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]vVector of integer values to insert.

◆ putInt8() [3/3]

void ts::tlv::Serializer::putInt8 ( TAG  tag,
const std::vector< int8_t > &  v 
)

Insert a TLV field containing a vector of signed 8-bit integer values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]vVector of integer values to insert.

◆ putInt16() [3/3]

void ts::tlv::Serializer::putInt16 ( TAG  tag,
const std::vector< int16_t > &  v 
)

Insert a TLV field containing a vector of signed 16-bit integer values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]vVector of integer values to insert.

◆ putInt32() [3/3]

void ts::tlv::Serializer::putInt32 ( TAG  tag,
const std::vector< int32_t > &  v 
)

Insert a TLV field containing a vector of signed 32-bit integer values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]vVector of integer values to insert.

◆ putInt64() [3/3]

void ts::tlv::Serializer::putInt64 ( TAG  tag,
const std::vector< int64_t > &  v 
)

Insert a TLV field containing a vector of signed 64-bit integer values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]vVector of integer values to insert.

◆ putBool() [1/3]

void ts::tlv::Serializer::putBool ( bool  val)
inline

Insert a boolean value in the stream.

Parameters
[in]valBoolean value to insert.

◆ putBool() [2/3]

void ts::tlv::Serializer::putBool ( TAG  tag,
bool  val 
)
inline

Insert a TLV field containing a boolean value in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]valBoolean value to insert.

◆ putBool() [3/3]

void ts::tlv::Serializer::putBool ( TAG  tag,
const std::vector< bool > &  val 
)

Insert a TLV field containing a vector of boolean values in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]valVector of boolean values to insert.

◆ put() [1/10]

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::tlv::Serializer::put ( INT  i)
inline

Insert an integer value in the stream (template variant).

Template Parameters
INTInteger type.
Parameters
[in]iInteger value to insert.

◆ put() [2/10]

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::tlv::Serializer::put ( TAG  tag,
INT  i 
)
inline

Insert a TLV field containing an integer value in the stream (template variant).

Template Parameters
INTInteger type.
Parameters
[in]tagMessage or parameter tag.
[in]iInteger value to insert.

◆ put() [3/10]

template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr>
void ts::tlv::Serializer::put ( TAG  tag,
const std::vector< INT > &  val 
)
inline

Insert a TLV field containing a vector of integer values in the stream (template variant).

Template Parameters
INTInteger type.
Parameters
[in]tagMessage or parameter tag.
[in]valVector of integer values to insert.

◆ put() [4/10]

void ts::tlv::Serializer::put ( const std::string &  val)
inline

Insert a string in the stream.

Parameters
[in]valString to insert.

◆ put() [5/10]

void ts::tlv::Serializer::put ( TAG  tag,
const std::string &  val 
)
inline

Insert a TLV field containing a string in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]valString to insert.

◆ put() [6/10]

void ts::tlv::Serializer::put ( TAG  tag,
const std::vector< std::string > &  val 
)

Insert a TLV field containing a vector of strings in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]valVector of strings to insert.

◆ put() [7/10]

void ts::tlv::Serializer::put ( const ByteBlock bl)
inline

Insert a byte block in the stream.

Parameters
[in]blByte block to insert.

◆ put() [8/10]

void ts::tlv::Serializer::put ( TAG  tag,
const ByteBlock bl 
)
inline

Insert a TLV field containing a byte block in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]blByte block to insert.

◆ put() [9/10]

void ts::tlv::Serializer::put ( const void *  pval,
size_t  len 
)
inline

Insert raw data in the stream.

Parameters
[in]pvalAddress of data to insert.
[in]lenLength of data to insert.

◆ put() [10/10]

void ts::tlv::Serializer::put ( TAG  tag,
const void *  pval,
size_t  len 
)
inline

Insert a TLV field containing raw data in the stream.

Parameters
[in]tagMessage or parameter tag.
[in]pvalAddress of data to insert.
[in]lenLength of data to insert.

◆ toString()

UString ts::tlv::Serializer::toString ( ) const

Convert to a string (for debug purpose).

Returns
A string representing the internal state of the Serializer.

The documentation for this class was generated from the following file: