TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
Representation of an ATSC multiple_string_structure. More...
#include <tsATSCMultipleString.h>
Public Member Functions | |
ATSCMultipleString ()=default | |
Default constructor. | |
ATSCMultipleString (const UString &language, const UString &text) | |
Constructor with one string. | |
void | add (const UString &language, const UString &text) |
Add a new string. | |
bool | append (size_t index, const UString &text) |
Append text to an existing string. | |
void | clear () |
Clear all strings. | |
bool | deserialize (DuckContext &duck, const uint8_t *&buffer, size_t &buffer_size, size_t mss_size=NPOS, bool ignore_empty=false) |
Deserialize a binary multiple_string_structure. | |
bool | empty () const |
Check if this instance has strings. | |
bool | fromXML (DuckContext &duck, const xml::Element *elem) |
Decode an XML structure and assign the result to this instance. | |
bool | fromXML (DuckContext &duck, const xml::Element *parent, const UString &name, bool required) |
Decode an XML structure and assign the result to this instance. | |
bool | hasLanguage (const UString &language) const |
Check if a given language is present. | |
UString | language (size_t index=0) const |
Get the language of the specified string (first string by default). | |
bool | lengthDeserialize (DuckContext &duck, const uint8_t *&buffer, size_t &buffer_size, size_t length_bytes=1) |
Deserialize a binary multiple_string_structure with a leading length field. | |
size_t | lengthSerialize (DuckContext &duck, ByteBlock &data, size_t length_bytes=1) const |
Serialize a binary multiple_string_structure and append to a byte block with a leading length field. | |
size_t | lengthSerialize (DuckContext &duck, uint8_t *&data, size_t &size, size_t length_bytes=1) const |
Serialize a binary multiple_string_structure with a leading length field. | |
void | reserve (size_t count) |
Allocate the appropriate memory for a target number of strings. | |
void | resize (size_t count) |
Set the number of strings in this instance. | |
size_t | searchLanguage (const UString &language) const |
Search the first string with a given language. | |
size_t | serialize (DuckContext &duck, ByteBlock &data, size_t max_size=NPOS, bool ignore_empty=false) const |
Serialize a binary multiple_string_structure and append to a byte block. | |
size_t | serialize (DuckContext &duck, uint8_t *&data, size_t &size, size_t max_size=NPOS, bool ignore_empty=false) const |
Serialize a binary multiple_string_structure. | |
bool | set (size_t index, const UString &language, const UString &text) |
Set the value of an existing string. | |
size_t | size () const |
Get the number of strings in this instance. | |
UString | text (const UString &language=UString()) const |
Get the concatenation of all texts of the specified language. | |
UString | text (size_t index) const |
Get the text of the specified string. | |
xml::Element * | toXML (DuckContext &duck, xml::Element *parent, const UString &name, bool ignore_empty) const |
Convert to an XML structure. | |
Static Public Member Functions | |
static void | Display (TablesDisplay &display, const UString &title, const UString &margin, const uint8_t *&buffer, size_t &buffer_size, size_t mss_size=NPOS) |
A static method to display a binary multiple_string_structure. | |
Representation of an ATSC multiple_string_structure.
An ATSC multiple_string_structure is a set of strings. Each string has a language code and a compression mode. In this implementation, we only support non-compressed text.
Constructor with one string.
[in] | language | 3-character ISO-639 language code. |
[in] | text | Text string. |
|
inline |
Check if this instance has strings.
|
inline |
Get the number of strings in this instance.
Set the number of strings in this instance.
[in] | count | The new number of strings. Either truncate current list of strings or create additional empty strings. |
Allocate the appropriate memory for a target number of strings.
The actual number of strings in unchanged.
[in] | count | The target number of strings. |
Get the language of the specified string (first string by default).
[in] | index | String index. |
Get the concatenation of all texts of the specified language.
[in] | language | 3-character ISO-639 language code. If empty, use the language code of the first string. |
Get the text of the specified string.
[in] | index | String index. |
Search the first string with a given language.
[in] | language | 3-character ISO-639 language code. |
NPOS
if not found. Check if a given language is present.
[in] | language | 3-character ISO-639 language code. |
Add a new string.
[in] | language | 3-character ISO-639 language code. |
[in] | text | Text string. |
Set the value of an existing string.
[in] | index | String index. |
[in] | language | 3-character ISO-639 language code. |
[in] | text | Text string. |
Append text to an existing string.
[in] | index | String index. |
[in] | text | Text string to append. |
xml::Element * ts::ATSCMultipleString::toXML | ( | DuckContext & | duck, |
xml::Element * | parent, | ||
const UString & | name, | ||
bool | ignore_empty | ||
) | const |
Convert to an XML structure.
[in,out] | duck | TSDuck execution context. |
[in,out] | parent | Parent XML node. |
[in] | name | Name of the XML node to create. |
[in] | ignore_empty | Do not insert the node if the structure is empty. |
nullptr
on error or empty and ignore_empty is true.An ATSC multiple_string_structure can be represented as an XML element with a predefined structure. The name is application-dependent. The XML structure is the following:
bool ts::ATSCMultipleString::fromXML | ( | DuckContext & | duck, |
const xml::Element * | elem | ||
) |
Decode an XML structure and assign the result to this instance.
[in,out] | duck | TSDuck execution context. |
[in] | elem | XML node to decode as an ATSC multiple_string_structure. |
bool ts::ATSCMultipleString::fromXML | ( | DuckContext & | duck, |
const xml::Element * | parent, | ||
const UString & | name, | ||
bool | required | ||
) |
Decode an XML structure and assign the result to this instance.
[in,out] | duck | TSDuck execution context. |
[in] | parent | Parent XML node. |
[in] | name | Name of the child XML node to decode as an ATSC multiple_string_structure. |
[in] | required | When true, the name node shall be present. When false, if the node if not present, simply clear this object. |
size_t ts::ATSCMultipleString::serialize | ( | DuckContext & | duck, |
uint8_t *& | data, | ||
size_t & | size, | ||
size_t | max_size = NPOS , |
||
bool | ignore_empty = false |
||
) | const |
Serialize a binary multiple_string_structure.
[in,out] | duck | TSDuck execution context. |
[in,out] | data | Address of the buffer where to serialize the structure. On return, it is updated to point after the structure. |
[in,out] | size | Size in bytes of the buffer. On return, it is updated to the remaining size in the buffer. |
[in] | max_size | Max size to serialize, possibly lower than the buffer size. |
[in] | ignore_empty | If true and the multiple_string_structure is empty, do nothing. |
size_t ts::ATSCMultipleString::serialize | ( | DuckContext & | duck, |
ByteBlock & | data, | ||
size_t | max_size = NPOS , |
||
bool | ignore_empty = false |
||
) | const |
Serialize a binary multiple_string_structure and append to a byte block.
[in,out] | duck | TSDuck execution context. |
[in,out] | data | Byte block where to serialize the structure. The structure is added at the end. |
[in] | max_size | Max size to serialize. |
[in] | ignore_empty | If true and the multiple_string_structure is empty, do nothing. |
size_t ts::ATSCMultipleString::lengthSerialize | ( | DuckContext & | duck, |
uint8_t *& | data, | ||
size_t & | size, | ||
size_t | length_bytes = 1 |
||
) | const |
Serialize a binary multiple_string_structure with a leading length field.
[in,out] | duck | TSDuck execution context. |
[in,out] | data | Address of the buffer where to serialize the structure. On return, it is updated to point after the structure. |
[in,out] | size | Size in bytes of the buffer. On return, it is updated to the remaining size in the buffer. |
[in] | length_bytes | Size in bytes of the leading length field (1 byte by default). |
size_t ts::ATSCMultipleString::lengthSerialize | ( | DuckContext & | duck, |
ByteBlock & | data, | ||
size_t | length_bytes = 1 |
||
) | const |
Serialize a binary multiple_string_structure and append to a byte block with a leading length field.
[in,out] | duck | TSDuck execution context. |
[in,out] | data | Byte block where to serialize the structure. The structure is added at the end. |
[in] | length_bytes | Size in bytes of the leading length field (1 byte by default). |
bool ts::ATSCMultipleString::deserialize | ( | DuckContext & | duck, |
const uint8_t *& | buffer, | ||
size_t & | buffer_size, | ||
size_t | mss_size = NPOS , |
||
bool | ignore_empty = false |
||
) |
Deserialize a binary multiple_string_structure.
[in,out] | duck | TSDuck execution context. |
[in,out] | buffer | Address of the structure to deserialize. On return, it is updated to point after the structure. |
[in,out] | buffer_size | Size in bytes of the data buffer. On return, it is updated to the remaining size in the buffer. |
[in] | mss_size | Size of the multiple_string_structure to deserialize, possibly lower than the buffer size. If lower than buffer_size, adjust data and buffer_size to skip mss_size bytes. |
[in] | ignore_empty | If true and the size is zero, then this is a valid empty multiple_string_structure. |
bool ts::ATSCMultipleString::lengthDeserialize | ( | DuckContext & | duck, |
const uint8_t *& | buffer, | ||
size_t & | buffer_size, | ||
size_t | length_bytes = 1 |
||
) |
Deserialize a binary multiple_string_structure with a leading length field.
[in,out] | duck | TSDuck execution context. |
[in,out] | buffer | Address of the structure to deserialize. On return, it is updated to point after the structure. |
[in,out] | buffer_size | Size in bytes of the data buffer. On return, it is updated to the remaining size in the buffer. |
[in] | length_bytes | Size in bytes of the leading length field (1 byte by default). |
|
static |
A static method to display a binary multiple_string_structure.
[in,out] | display | Display engine. |
[in] | title | Leading title to display. Can be empty. |
[in] | margin | Left margin content. |
[in,out] | buffer | Address of the binary structure to display. On return, it is updated to point after the structure. |
[in,out] | buffer_size | Size in bytes of the data buffer. On return, it is updated to the remaining size in the buffer. |
[in] | mss_size | Size of the multiple_string_structure to deserialize, possibly lower than the buffer size. If lower than buffer_size, adjust data and buffer_size to skip mss_size bytes. |