![]() |
TSDuck v3.46-4930
MPEG Transport Stream Toolkit
|
#include <tsByteBlock.h>


Classes | |
| class | Overlap |
Public Types | |
| using | ByteVector = std::vector<uint8_t> |
Public Member Functions | |
| ByteBlock (ByteBlock &&bb) | |
| ByteBlock (const ByteBlock &bb, size_type start=0, size_type count=NPOS) | |
| ByteBlock (const char *str) | |
| ByteBlock (const void *data, size_type size) | |
| ByteBlock (size_type size, uint8_t value) | |
| ByteBlock (size_type size=0) | |
| ByteBlock (std::initializer_list< uint8_t > init) | |
| void | append (const ByteBlock &bb, size_type start=0, size_type count=NPOS) |
| void | append (const std::string &s) |
| void | append (const void *data, size_type size) |
| template<typename INT> requires std::integral<INT> | |
| void | append (INT i) |
| std::istream & | append (std::istream &strm, size_t max_size=std::numeric_limits< size_t >::max()) |
| void | append (uint8_t i, size_type size) |
| void | appendBCD (uint32_t value, size_t bcd_count, bool left_justified=true, uint8_t pad_nibble=0) |
| bool | appendFromFile (const UString &file_name, size_t max_size=std::numeric_limits< size_t >::max(), Report *report=nullptr) |
| void | appendInt16 (int16_t i) |
| void | appendInt16BE (int16_t i) |
| void | appendInt16LE (int16_t i) |
| void | appendInt24 (int32_t i) |
| void | appendInt24BE (int32_t i) |
| void | appendInt24LE (int32_t i) |
| void | appendInt32 (int32_t i) |
| void | appendInt32BE (int32_t i) |
| void | appendInt32LE (int32_t i) |
| void | appendInt64 (int64_t i) |
| void | appendInt64BE (int64_t i) |
| void | appendInt64LE (int64_t i) |
| void | appendInt8 (int8_t i) |
| bool | appendToFile (const UString &file_name, Report *report=nullptr) const |
| void | appendUInt16 (uint16_t i) |
| void | appendUInt16BE (uint16_t i) |
| void | appendUInt16LE (uint16_t i) |
| void | appendUInt24 (uint32_t i) |
| void | appendUInt24BE (uint32_t i) |
| void | appendUInt24LE (uint32_t i) |
| void | appendUInt32 (uint32_t i) |
| void | appendUInt32BE (uint32_t i) |
| void | appendUInt32LE (uint32_t i) |
| void | appendUInt40 (uint64_t i) |
| void | appendUInt40BE (uint64_t i) |
| void | appendUInt40LE (uint64_t i) |
| void | appendUInt48 (uint64_t i) |
| void | appendUInt48BE (uint64_t i) |
| void | appendUInt48LE (uint64_t i) |
| void | appendUInt64 (uint64_t i) |
| void | appendUInt64BE (uint64_t i) |
| void | appendUInt64LE (uint64_t i) |
| void | appendUInt8 (uint8_t i) |
| void | appendUTF8 (const UString &s) |
| void | appendUTF8WithByteLength (const UString &s) |
| void | binAnd (const ByteBlock &bb1, const ByteBlock &bb2, size_type start1=0, size_type count1=NPOS, size_type start2=0, size_type count2=NPOS, uint8_t pad=0xFF) |
| void | binAnd (uint8_t value) |
| void | binNot () |
| void | binOr (const ByteBlock &bb1, const ByteBlock &bb2, size_type start1=0, size_type count1=NPOS, size_type start2=0, size_type count2=NPOS, uint8_t pad=0x00) |
| void | binOr (uint8_t value) |
| void | binXor (const ByteBlock &bb1, const ByteBlock &bb2, size_type start1=0, size_type count1=NPOS, size_type start2=0, size_type count2=NPOS, uint8_t pad=0x00) |
| void | binXor (uint8_t value) |
| void | copy (const ByteBlock &bb, size_type start=0, size_type count=NPOS) |
| void | copy (const void *data, size_type size) |
| uint8_t * | dataEnd () |
| const uint8_t * | dataEnd () const |
| uint8_t * | enlarge (size_type n) |
| void | erase (size_type first, size_type size) |
| size_type | find (uint8_t value, size_type start=0, size_type end=NPOS) const |
| bool | loadFromFile (const UString &file_name, size_t max_size=std::numeric_limits< size_t >::max(), Report *report=nullptr) |
| std::istream & | read (std::istream &strm, size_t max_size=std::numeric_limits< size_t >::max()) |
| bool | saveToFile (const UString &file_name, Report *report=nullptr) const |
| void | set (uint8_t value) |
| void | set (uint8_t value, size_type size) |
| std::ostream & | write (std::ostream &strm) const |
Static Public Member Functions | |
| static const ByteBlock & | EMPTY () |
Definition of a generic block of bytes.
This is a subclass of std::vector on uint8_t.
| using ts::ByteBlock::ByteVector = std::vector<uint8_t> |
Explicit name of superclass, std::vector on uint8_t.
|
explicit |
Default constructor.
| [in] | size | Initial size in bytes of the block. |
| ts::ByteBlock::ByteBlock | ( | size_type | size, |
| uint8_t | value ) |
Constructor, initialized with bytes of specified value.
| [in] | size | Initial size in bytes of the block. |
| [in] | value | Value of each byte. |
| ts::ByteBlock::ByteBlock | ( | const void * | data, |
| size_type | size ) |
Constructor from a data block.
| [in] | data | Address of area to copy. |
| [in] | size | Initial size of the block. |
| ts::ByteBlock::ByteBlock | ( | const ByteBlock & | bb, |
| size_type | start = 0, | ||
| size_type | count = NPOS ) |
Copy constructor, from a partial data block.
| [in] | bb | Data block to copy. |
| [in] | start | Start index in bb. Copy nothing if after end of bb. |
| [in] | count | Number of bytes to copy. Extra bytes after end of bb are ignored. |
| ts::ByteBlock::ByteBlock | ( | ByteBlock && | bb | ) |
Move constructor.
| [in,out] | bb | Data block to move. |
| ts::ByteBlock::ByteBlock | ( | const char * | str | ) |
Constructor from a C string.
| [in] | str | Address of a nul-terminated string. The content of the byte block is the content of the string, excluding the terminating nul character. |
| ts::ByteBlock::ByteBlock | ( | std::initializer_list< uint8_t > | init | ) |
Constructor from an initializer list.
| [in] | init | Initializer list. |
|
static |
|
inline |
Get a pointer after the last byte in the block.
|
inline |
Get a pointer after the last byte in the block.
| void ts::ByteBlock::binAnd | ( | uint8_t | value | ) |
And operator: binary "and" of all bytes with a given value.
| [in] | value | The value to "and" with all bytes. |
| void ts::ByteBlock::binAnd | ( | const ByteBlock & | bb1, |
| const ByteBlock & | bb2, | ||
| size_type | start1 = 0, | ||
| size_type | count1 = NPOS, | ||
| size_type | start2 = 0, | ||
| size_type | count2 = NPOS, | ||
| uint8_t | pad = 0xFF ) |
Binary "and" operator from two other byte blocks. The result in this object will have the longest size of bb1 and bb2.
| [in] | bb1 | First byte block. |
| [in] | bb2 | Second byte block. |
| [in] | start1 | First index in bb1. |
| [in] | count1 | Number of bytes to use in bb1. |
| [in] | start2 | First index in bb2. |
| [in] | count2 | Number of bytes to use in bb2. |
| [in] | pad | If bb1 and bb2 don't have the same size, use this value to "and" the part in excess (default: unchanged). |
| void ts::ByteBlock::binOr | ( | uint8_t | value | ) |
Or operator: binary "or" of all bytes with a given value.
| [in] | value | The value to "or" with all bytes. |
| void ts::ByteBlock::binOr | ( | const ByteBlock & | bb1, |
| const ByteBlock & | bb2, | ||
| size_type | start1 = 0, | ||
| size_type | count1 = NPOS, | ||
| size_type | start2 = 0, | ||
| size_type | count2 = NPOS, | ||
| uint8_t | pad = 0x00 ) |
Binary "or" operator from two other byte blocks. The result in this object will have the longest size of bb1 and bb2.
| [in] | bb1 | First byte block. |
| [in] | bb2 | Second byte block. |
| [in] | start1 | First index in bb1. |
| [in] | count1 | Number of bytes to use in bb1. |
| [in] | start2 | First index in bb2. |
| [in] | count2 | Number of bytes to use in bb2. |
| [in] | pad | If bb1 and bb2 don't have the same size, use this value to "or" the part in excess (default: unchanged). |
| void ts::ByteBlock::binXor | ( | uint8_t | value | ) |
Xor operator: binary "xor" of all bytes with a given value.
| [in] | value | The value to "xor" with all bytes. |
| void ts::ByteBlock::binXor | ( | const ByteBlock & | bb1, |
| const ByteBlock & | bb2, | ||
| size_type | start1 = 0, | ||
| size_type | count1 = NPOS, | ||
| size_type | start2 = 0, | ||
| size_type | count2 = NPOS, | ||
| uint8_t | pad = 0x00 ) |
Binary "xor" operator from two other byte blocks. The result in this object will have the longest size of bb1 and bb2.
| [in] | bb1 | First byte block. |
| [in] | bb2 | Second byte block. |
| [in] | start1 | First index in bb1. |
| [in] | count1 | Number of bytes to use in bb1. |
| [in] | start2 | First index in bb2. |
| [in] | count2 | Number of bytes to use in bb2. |
| [in] | pad | If bb1 and bb2 don't have the same size, use this value to "xor" the part in excess (default: unchanged). |
| void ts::ByteBlock::binNot | ( | ) |
Not operator: binary "not" or "complement" of all bytes.
| size_type ts::ByteBlock::find | ( | uint8_t | value, |
| size_type | start = 0, | ||
| size_type | end = NPOS ) const |
Find the first occurrence of a byte value in a byte block.
| [in] | value | The byte value to search. |
| [in] | start | Index where to start (at the beginning by default). |
| [in] | end | Index where to stop the search (at the end by default). |
|
inline |
Set all bytes to a given value, without changing the size.
| [in] | value | The value to set to all bytes. |
|
inline |
Replace the content of a byte block with all bytes set to a given value.
| [in] | value | The value to set to all bytes. |
| [in] | size | New size of the byte block. |
| void ts::ByteBlock::copy | ( | const void * | data, |
| size_type | size ) |
Replace the content of a byte block.
| [in] | data | Address of the new area to copy. |
| [in] | size | Size of the area to copy. |
Replace the content of a byte block from another byte block.
| [in] | bb | Copy data from this byte block. |
| [in] | start | Start index in bb. Copy nothing if after end of bb. |
| [in] | count | Number of bytes to copy. Extra bytes after end of bb are ignored. |
| void ts::ByteBlock::erase | ( | size_type | first, |
| size_type | size ) |
Remove 'size' elements at index 'first'. The STL equivalent uses iterators, not indices.
| [in] | first | Index of the first byte to erase. |
| [in] | size | Number of bytes to erase. |
| uint8_t * ts::ByteBlock::enlarge | ( | size_type | n | ) |
Increase size return pointer to new area at end of block.
| [in] | n | Number of bytes to add at the end of the block. |
| void ts::ByteBlock::append | ( | const void * | data, |
| size_type | size ) |
Append raw data to a byte block.
| [in] | data | Address of the new area to append. |
| [in] | size | Size of the area to append. |
Append a slice of a byte block to a byte block.
| [in] | bb | Append data from this byte block. |
| [in] | start | Start index in bb. Copy nothing if after end of bb. |
| [in] | count | Number of bytes to copy. Extra bytes afet end of bb are ignored. |
|
inline |
Append a string to a byte block.
| [in] | s | String to append. |
| void ts::ByteBlock::appendUTF8 | ( | const UString & | s | ) |
Append a unicode string in UTF-8 representation to a byte block.
| [in] | s | String to append. |
| void ts::ByteBlock::appendUTF8WithByteLength | ( | const UString & | s | ) |
Append a unicode string in UTF-8 representation to a byte block with one-byte preceding length.
| [in] | s | String to append. UTF-8 representation is trunctated to 255 if necessary so that the length fits in one byte. |
|
inline |
Append n bytes with value i.
| [in] | i | Value of each byte. |
| [in] | size | Number of bytes to append. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in big endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
|
inline |
Append an integer in little endian representation at the end.
| [in] | i | Integer value to serialize at the end of the block. |
| void ts::ByteBlock::appendBCD | ( | uint32_t | value, |
| size_t | bcd_count, | ||
| bool | left_justified = true, | ||
| uint8_t | pad_nibble = 0 ) |
Append an integer in Binary Coded Decimal (BCD) representation at the end.
| [in] | value | Integer value to serialize at the end of the block. |
| [in] | bcd_count | Number of BCD digits. Note that bcd_count can be even. |
| [in] | left_justified | When true (the default), the first BCD digit starts in the first half of the first byte. When false and bcd_count is odd, the first BCD digit starts in the second half of the first byte. This parameter is ignored when bcd_count is even. |
| [in] | pad_nibble | A value in the range 0..15 to set in the unused nibble when bcd_count is odd. This is the first half of the first byte when left_justified is false. This is the second half of the last byte when left_justified is true. This parameter is ignored when bcd_count is even. |
| bool ts::ByteBlock::loadFromFile | ( | const UString & | file_name, |
| size_t | max_size = std::numeric_limits< size_t >::max(), | ||
| Report * | report = nullptr ) |
Read a byte block from a binary file.
| [in] | file_name | Input file name. |
| [in] | max_size | Maximum size to read. By default, read up to end of file or error. |
| [in,out] | report | If not null, where to report errors. |
| bool ts::ByteBlock::appendFromFile | ( | const UString & | file_name, |
| size_t | max_size = std::numeric_limits< size_t >::max(), | ||
| Report * | report = nullptr ) |
Read a byte block from a binary file and append to existing content.
| [in] | file_name | Input file name. |
| [in] | max_size | Maximum size to read. By default, read up to end of file or error. |
| [in,out] | report | If not null, where to report errors. |
Save a byte block to a binary file.
| [in] | file_name | Output file name. |
| [in,out] | report | If not null, where to report errors. |
Save a byte block to a binary file, append to existing file content.
| [in] | file_name | Output file name. |
| [in,out] | report | If not null, where to report errors. |
| std::istream & ts::ByteBlock::read | ( | std::istream & | strm, |
| size_t | max_size = std::numeric_limits< size_t >::max() ) |
Read a byte block from standard streams (binary mode).
| [in,out] | strm | A standard stream in input mode. |
| [in] | max_size | Maximum size to read. By default, read up to end of file or error. |
| std::istream & ts::ByteBlock::append | ( | std::istream & | strm, |
| size_t | max_size = std::numeric_limits< size_t >::max() ) |
Read a byte block from standard streams and append to existing content (binary mode).
| [in,out] | strm | A standard stream in input mode. |
| [in] | max_size | Maximum size to read. By default, read up to end of file or error. |
| std::ostream & ts::ByteBlock::write | ( | std::ostream & | strm | ) | const |
Write a byte to standard streams (binary mode).
| [in,out] | strm | A standard stream in output mode. |