TSDuck v3.40-4001
MPEG Transport Stream Toolkit
|
A specialized subclass of ts::Buffer for PSI serialization. More...
#include <tsPSIBuffer.h>
Public Member Functions | |
PSIBuffer (DuckContext &duck, const Section §ion) | |
Constructor over the payload of a read-only section which must remain unmodified as long as the PSIBuffer object is used and not reset. | |
PSIBuffer (DuckContext &duck, const void *data, size_t size) | |
Constructor using a read-only external memory area which must remain valid as long as the PSIBuffer object is used and not reset. | |
PSIBuffer (DuckContext &duck, size_t size=DEFAULT_SIZE) | |
Default constructor. | |
PSIBuffer (DuckContext &duck, void *data, size_t size, bool read_only=false) | |
Constructor using an external memory area which must remain valid as long as the PSIBuffer object is used and not reset. | |
bool | backBits (size_t bits) |
Skip read bits backward. | |
bool | backBytes (size_t bytes) |
Skip read bytes backward. | |
bool | canRead () const |
Check if we can still read from the buffer. | |
bool | canReadBits (size_t bits) const |
Check if we can read at least the specified number of bits from the buffer. | |
bool | canReadBytes (size_t bytes) const |
Check if we can read at least the specified number of bytes from the buffer. | |
bool | canWrite () const |
Check if we can still write in the buffer. | |
bool | canWriteBits (size_t bits) const |
Check if we can write at least the specified number of bits in the buffer. | |
bool | canWriteBytes (size_t bytes) const |
Check if we can write at least the specified number of bytes in the buffer. | |
size_t | capacity () const |
Get the maximum buffer size in bytes. | |
void | clearError () |
Clear all error states. | |
void | clearReadError () |
Clear the read error state. | |
void | clearUserError () |
Clear the user-generated error state. | |
void | clearWriteError () |
Clear the write error state. | |
const uint8_t * | currentReadAddress () const |
Get starting address of current read data (ignoring bit offset inside first byte to read). | |
size_t | currentReadBitOffset () const |
Get current read bit offset from the beginning of the buffer. | |
size_t | currentReadByteOffset () const |
Get current read byte index (ignoring bit offset inside bytes). | |
size_t | currentWriteBitOffset () const |
Get current write bit offset from the beginning of the buffer. | |
size_t | currentWriteByteOffset () const |
Get current write byte index (ignoring bit offset inside bytes). | |
const uint8_t * | data () const |
Get the current base address of the buffer. | |
bool | dropState (size_t level=NPOS) |
Drop the last saved state of the read/write streams from the stack of saved states. | |
DuckContext & | duck () const |
Get a reference to the associated TSDuck execution context. | |
bool | endOfRead () const |
Check end of read stream. | |
bool | endOfWrite () const |
Check end of write stream. | |
bool | error () const |
Check if there was any kind of error. | |
bool | externalMemory () const |
Check if the buffer is linked to some external memory area. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> | |
bool | getBCD (INT &value, size_t bcd_count) |
Read the next 4*n bits as a Binary Coded Decimal (BCD) value and advance the read pointer. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> | |
INT | getBCD (size_t bcd_count) |
Read the next 4*n bits as a Binary Coded Decimal (BCD) value and advance the read pointer. | |
uint8_t | getBit () |
Read the next bit and advance the read pointer. | |
template<class Rep , class Period > | |
void | getBits (cn::duration< Rep, Period > &value, size_t bits) |
Read the next n bits as a std::chrono::duration value and advance the read pointer. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> | |
void | getBits (INT &value, size_t bits) |
Read the next n bits as an integer value and advance the read pointer. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value &&std::is_unsigned< INT >::value >::type * = nullptr> | |
INT | getBits (size_t bits) |
Read the next n bits as an integer value and advance the read pointer. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> | |
void | getBits (std::optional< INT > &value, size_t bits) |
Read the next n bits as an integer value and advance the read pointer. | |
bool | getBool () |
Read the next bit as a boolean and advance the read pointer. | |
void | getBytes (ByteBlock &bb, size_t bytes=NPOS) |
Get bulk bytes from the buffer. | |
ByteBlock | getBytes (size_t bytes=NPOS) |
Get bulk bytes from the buffer. | |
size_t | getBytes (uint8_t *buffer, size_t bytes) |
Get bulk bytes from the buffer. | |
size_t | getBytesAppend (ByteBlock &bb, size_t bytes=NPOS) |
Get bulk bytes from the buffer. | |
Time | getDateMJD () |
Get the date part of a Modified Julian Date (MJD), the time part is ignored, 2 bytes. | |
bool | getDescriptorList (DescriptorList &descs, size_t length=NPOS) |
Get (deserialize) a descriptor list. | |
bool | getDescriptorListWithLength (DescriptorList &descs, size_t length_bits=12) |
Get (deserialize) a descriptor list with a 2-byte length field before the descriptor list. | |
ieee_float32_t | getFloat32 () |
Read the next 32 bits as an IEEE float value and advance the read pointer. | |
ieee_float64_t | getFloat64 () |
Read the next 64 bits as an IEEE float value and advance the read pointer. | |
Time | getFullMJD () |
Get a full Modified Julian Date (MJD), date and time, 5 bytes. | |
int16_t | getInt16 () |
Read the next 16 bits as a signed integer value and advance the read pointer. | |
int32_t | getInt24 () |
Read the next 24 bits as a signed integer value and advance the read pointer. | |
int32_t | getInt32 () |
Read the next 32 bits as a signed integer value and advance the read pointer. | |
int64_t | getInt40 () |
Read the next 40 bits as a signed integer value and advance the read pointer. | |
int64_t | getInt48 () |
Read the next 48 bits as a signed integer value and advance the read pointer. | |
int64_t | getInt64 () |
Read the next 64 bits as a signed integer value and advance the read pointer. | |
int8_t | getInt8 () |
Read the next 8 bits as a signed integer value and advance the read pointer. | |
UString | getLanguageCode () |
Read the next 24 bits as a 3-character language or country code and advance the read pointer. | |
bool | getLanguageCode (UString &str) |
Read the next 24 bits as a 3-character language or country code and advance the read pointer. | |
template<class Rep , class Period > | |
void | getMinutesBCD (cn::duration< Rep, Period > &duration) |
Get (deserialize) a duration in minutes as 4 BCD digits (HHMM), 2 bytes. | |
Time | getMJD (MJDFormat fmt) |
Get a Modified Julian Date (MJD), 2 to 5 bytes. | |
bool | getMultipleString (ATSCMultipleString &mss, size_t mss_size=NPOS, bool ignore_empty=false) |
Get (deserialize) an ATSC multiple_string_structure() as defined in ATSC A/65. | |
bool | getMultipleStringWithLength (ATSCMultipleString &mss, size_t length_bytes=1) |
Get (deserialize) an ATSC multiple_string_structure() as defined in ATSC A/65, with a leading byte length. | |
PID | getPID () |
Deserialize a 13-bit PID value. | |
template<class Rep , class Period > | |
void | getSecondsBCD (cn::duration< Rep, Period > &duration) |
Get (deserialize) a duration in seconds as 6 BCD digits (HHMMSS), 3 bytes. | |
UString | getString (size_t size=NPOS, const Charset *charset=nullptr) |
Get a string using the default input character set. | |
bool | getString (UString &str, size_t size=NPOS, const Charset *charset=nullptr) |
Get a string using the default input character set. | |
UString | getStringWithByteLength (const Charset *charset=nullptr) |
Get a string (preceded by its one-byte length) using the default input character set. | |
bool | getStringWithByteLength (UString &str, const Charset *charset=nullptr) |
Get a string (preceded by its one-byte length) using the default input character set. | |
uint16_t | getUInt16 () |
Read the next 16 bits as an unsigned integer value and advance the read pointer. | |
uint32_t | getUInt24 () |
Read the next 24 bits as an unsigned integer value and advance the read pointer. | |
uint32_t | getUInt32 () |
Read the next 32 bits as an unsigned integer value and advance the read pointer. | |
uint64_t | getUInt40 () |
Read the next 40 bits as an unsigned integer value and advance the read pointer. | |
uint64_t | getUInt48 () |
Read the next 48 bits as an unsigned integer value and advance the read pointer. | |
uint64_t | getUInt64 () |
Read the next 64 bits as an unsigned integer value and advance the read pointer. | |
uint8_t | getUInt8 () |
Read the next 8 bits as an unsigned integer value and advance the read pointer. | |
size_t | getUnalignedLength (size_t length_bits) |
Get a 2-byte integer length field, typically a length before a descriptor list. | |
UString | getUTF16 (size_t bytes=NPOS) |
Get a UTF-16 string. | |
bool | getUTF16 (UString &result, size_t bytes=NPOS) |
Get a UTF-16 string. | |
UString | getUTF16WithLength (size_t length_bits=8) |
Get a UTF-16 string (preceded by its length). | |
bool | getUTF16WithLength (UString &result, size_t length_bits=8) |
Get a UTF-16 string (preceded by its length). | |
UString | getUTF8 (size_t bytes=NPOS) |
Get a UTF-8 string. | |
bool | getUTF8 (UString &result, size_t bytes=NPOS) |
Get a UTF-8 string. | |
UString | getUTF8WithLength (size_t length_bits=8) |
Get a UTF-8 string (preceded by its length). | |
bool | getUTF8WithLength (UString &result, size_t length_bits=8) |
Get a UTF-8 string (preceded by its length). | |
uint64_t | getVluimsbf5 () |
Get (deserialize) an integer value in "vluimsbf5" format. | |
bool | internalMemory () const |
Check if the buffer uses some internal private memory buffer. | |
bool | isBigEndian () const |
Check if read/write operations of integers use big endian representation. | |
bool | isLittleEndian () const |
Check if read/write operations of integers use little endian representation. | |
bool | isNativeEndian () const |
Check if read/write operations of integers use the native endian representation. | |
bool | isValid () const |
Check if the buffer is valid and contains some memory. | |
bool | popState (size_t level=NPOS) |
Pop the current state of the read/write streams from the stack of saved states and perform appropriate actions. | |
size_t | pushedLevels () const |
Get the current number of pushed states of the read/write streams. | |
size_t | pushReadSize (size_t size) |
Temporary reduce the readable size of the buffer. | |
size_t | pushReadSizeFromLength (size_t length_bits) |
Temporary reduce the readable size of the buffer using a length field from the stream. | |
size_t | pushState () |
Push the current state of the read/write streams on a stack of saved states. | |
size_t | pushWriteSequenceWithLeadingLength (size_t length_bits) |
Start a write sequence with a leading length field. | |
size_t | pushWriteSize (size_t size) |
Temporary reduce the writable size of the buffer. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> | |
bool | putBCD (INT value, size_t bcd_count) |
Put the next 4*n bits as a Binary Coded Decimal (BCD) value and advance the write pointer. | |
bool | putBit (uint8_t bit) |
Write the next bit and advance the write pointer. | |
template<class Rep , class Period > | |
bool | putBits (cn::duration< Rep, Period > value, size_t bits) |
Put the next n bits from a std::chrono::duration value and advance the write pointer. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> | |
bool | putBits (const std::optional< INT > &value, size_t bits) |
Put the next n bits from an integer value and advance the write pointer. | |
template<typename INT , typename std::enable_if< std::is_integral< INT >::value >::type * = nullptr> | |
bool | putBits (INT value, size_t bits) |
Put the next n bits from an integer value and advance the write pointer. | |
size_t | putBytes (const ByteBlock &bb, size_t start=0, size_t count=NPOS) |
Put bulk bytes in the buffer. | |
size_t | putBytes (const uint8_t *buffer, size_t bytes) |
Put bytes in the buffer. | |
bool | putDateMJD (const Time &time) |
Put (serialize) the date part of a Modified Julian Date (MJD), the time part is ignored, 2 bytes. | |
bool | putDescriptorList (const DescriptorList &descs, size_t start=0, size_t count=NPOS) |
Put (serialize) a complete descriptor list. | |
bool | putDescriptorListWithLength (const DescriptorList &descs, size_t start=0, size_t count=NPOS, size_t length_bits=12) |
Put (serialize) a complete descriptor list with a 2-byte length field before the descriptor list. | |
bool | putFixedUTF16 (const UString &str, size_t size, uint16_t pad=0, size_t start=0, size_t count=NPOS) |
Put a string using UTF-16 format with a fixed binary size (truncate or pad). | |
bool | putFixedUTF8 (const UString &str, size_t size, uint8_t pad=0, size_t start=0, size_t count=NPOS) |
Put a string using UTF-8 format with a fixed binary size (truncate or pad). | |
bool | putFloat32 (ieee_float32_t f) |
Write a 32-bit IEEE float value and advance the write pointer. | |
bool | putFloat64 (ieee_float64_t f) |
Write a 64-bit IEEE float value and advance the write pointer. | |
bool | putFullMJD (const Time &time) |
Put (serialize) a full Modified Julian Date (MJD), date and time, 5 bytes. | |
bool | putInt16 (int16_t i) |
Write a 16-bit signed integer value and advance the write pointer. | |
bool | putInt24 (int32_t i) |
Write a 24-bit signed integer value and advance the write pointer. | |
bool | putInt32 (int32_t i) |
Write a 32-bit signed integer value and advance the write pointer. | |
bool | putInt40 (int64_t i) |
Write a 40-bit signed integer value and advance the write pointer. | |
bool | putInt48 (int64_t i) |
Write a 48-bit signed integer value and advance the write pointer. | |
bool | putInt64 (int64_t i) |
Write a 64-bit signed integer value and advance the write pointer. | |
bool | putInt8 (int8_t i) |
Write an 8-bit signed integer value and advance the write pointer. | |
bool | putLanguageCode (const UString &str, bool allow_empty=false) |
Serialize a 3-byte language or country code and advance the write pointer. | |
template<class Rep , class Period > | |
bool | putMinutesBCD (const cn::duration< Rep, Period > &duration) |
Put (serialize) a duration in minutes as 4 BCD digits (HHMM), 2 bytes. | |
bool | putMJD (const Time &time, MJDFormat fmt) |
Put (serialize) a Modified Julian Date (MJD), 2 to 5 bytes. | |
bool | putMultipleString (const ATSCMultipleString &mss, size_t max_size=NPOS, bool ignore_empty=false) |
Put (serialize) an ATSC multiple_string_structure() as defined in ATSC A/65. | |
bool | putMultipleStringWithLength (const ATSCMultipleString &mss, size_t length_bytes=1) |
Put (serialize) an ATSC multiple_string_structure() as defined in ATSC A/65, with a leading byte length. | |
size_t | putPartialDescriptorList (const DescriptorList &descs, size_t start=0, size_t count=NPOS) |
Put (serialize) as many descriptors as possible from a descriptor list. | |
size_t | putPartialDescriptorListWithLength (const DescriptorList &descs, size_t start=0, size_t count=NPOS, size_t length_bits=12) |
Put (serialize) as many descriptors as possible from a descriptor list with a 2-byte length field before the descriptor list. | |
size_t | putPartialString (const UString &str, size_t start=0, size_t count=NPOS, const Charset *charset=nullptr) |
Put a partial string using the preferred output character set. | |
size_t | putPartialStringWithByteLength (const UString &str, size_t start=0, size_t count=NPOS, const Charset *charset=nullptr) |
Put a partial string (preceded by its one-byte length) using the preferred output character set. | |
size_t | putPartialUTF16 (const UString &str, size_t start=0, size_t count=NPOS) |
Put a partial string using UTF-8 format. | |
size_t | putPartialUTF16WithLength (const UString &str, size_t start=0, size_t count=NPOS, size_t length_bits=8) |
Put a partial string (preceded by its length) using UTF-16 format. | |
size_t | putPartialUTF8 (const UString &str, size_t start=0, size_t count=NPOS) |
Put a partial string using UTF-8 format. | |
size_t | putPartialUTF8WithLength (const UString &str, size_t start=0, size_t count=NPOS, size_t length_bits=8) |
Put a partial string (preceded by its length) using UTF-8 format. | |
bool | putPID (PID pid) |
Serialize a 13-bit PID value. | |
bool | putReserved (size_t bits) |
Serialize the number of reserved '1' bits. | |
bool | putReservedZero (size_t bits) |
Serialize the number of reserved '0' bits. | |
template<class Rep , class Period > | |
bool | putSecondsBCD (const cn::duration< Rep, Period > &duration) |
Put (serialize) a duration in seconds as 6 BCD digits (HHMMSS), 3 bytes. | |
bool | putString (const UString &str, size_t start=0, size_t count=NPOS, const Charset *charset=nullptr) |
Put a string using the preferred output character set. | |
bool | putStringWithByteLength (const UString &str, size_t start=0, size_t count=NPOS, const Charset *charset=nullptr) |
Put a string (preceded by its one-byte length) using the preferred output character set. | |
bool | putUInt16 (uint16_t i) |
Write a 16-bit unsigned integer value and advance the write pointer. | |
bool | putUInt24 (uint32_t i) |
Write a 24-bit unsigned integer value and advance the write pointer. | |
bool | putUInt32 (uint32_t i) |
Write a 32-bit unsigned integer value and advance the write pointer. | |
bool | putUInt40 (uint64_t i) |
Write a 40-bit unsigned integer value and advance the write pointer. | |
bool | putUInt48 (uint64_t i) |
Write a 48-bit unsigned integer value and advance the write pointer. | |
bool | putUInt64 (uint64_t i) |
Write a 64-bit unsigned integer value and advance the write pointer. | |
bool | putUInt8 (uint8_t i) |
Write an 8-bit unsigned integer value and advance the write pointer. | |
bool | putUTF16 (const UString &str, size_t start=0, size_t count=NPOS) |
Put a string using UTF-16 format. | |
bool | putUTF16WithLength (const UString &str, size_t start=0, size_t count=NPOS, size_t length_bits=8) |
Put a string (preceded by its length) using UTF-16 format. | |
bool | putUTF8 (const UString &str, size_t start=0, size_t count=NPOS) |
Put a string using UTF-8 format. | |
bool | putUTF8WithLength (const UString &str, size_t start=0, size_t count=NPOS, size_t length_bits=8) |
Put a string (preceded by its length) using UTF-8 format. | |
bool | putVluimsbf5 (uint64_t value) |
Put (serialize) an integer value in "vluimsbf5" format. | |
bool | readError () const |
Check if there was a read error. | |
bool | readIsByteAligned () const |
Check if the current read bit pointer is on a byte boundary. | |
bool | readOnly () const |
Check if the buffer is read-only. | |
bool | readRealignByte () |
Align the read pointer to the next byte boundary if not already aligned. | |
bool | readSeek (size_t byte, size_t bit=0) |
Reset reading at the specified offset in the buffer. | |
size_t | remainingReadBits () const |
Get number of remaining bits to read. | |
size_t | remainingReadBytes () const |
Get number of remaining bytes to read (ignoring bit offset inside bytes). | |
size_t | remainingWriteBits () const |
Get number of remaining bits to write. | |
size_t | remainingWriteBytes () const |
Get number of remaining bytes to write (ignoring bit offset inside bytes). | |
bool | reservedBitsError () const |
Check if there were "reserved bits errors". | |
UString | reservedBitsErrorString (size_t base_offset=0, const UString &margin=UString()) |
Return a string describing the "reserved bits errors". | |
void | reset (const void *data, size_t size) |
Reset the buffer using a read-only external memory area which must remain valid as long as the Buffer object is used and not reset. | |
void | reset (size_t size) |
Reset the buffer, remove link to any external memory, reallocate an internal buffer if necessary. | |
void | reset (void *data, size_t size, bool read_only=false) |
Reset the buffer using an external memory area which must remain valid as long as the Buffer object is used and not reset. | |
bool | resize (size_t size, bool reallocate) |
Change the usable size of the buffer. | |
void | setBigEndian () |
Specify that read/write operations of integers should use big endian representation. | |
void | setLittleEndian () |
Specify that read/write operations of integers should use little endian representation. | |
void | setNativeEndian () |
Specify that read/write operations of integers should use the native endian representation. | |
void | setUserError () |
Set the user-generated error state. | |
size_t | size () const |
Get the current buffer size in bytes. | |
bool | skipBits (size_t bits) |
Skip read bits forward. | |
bool | skipBytes (size_t bytes) |
Skip read bytes forward (ignoring bit offset inside bytes). | |
bool | skipReservedBits (size_t bits, int expected=1) |
Skip read reserved bits forward. | |
size_t | swapState () |
Swap the current state of the read/write streams with the one on top of the stack of saved states. | |
void | switchEndian () |
Switch the endianness of read/write operations of integers. | |
UString | tryGetASCII (size_t bytes=NPOS) |
Try to get an ASCII string. | |
bool | tryGetASCII (UString &result, size_t bytes=NPOS) |
Try to get an ASCII string. | |
bool | userError () const |
Check if there was a user-generated error. | |
bool | writeError () const |
Check if there was a write error. | |
bool | writeIsByteAligned () const |
Check if the current write bit pointer is on a byte boundary. | |
bool | writeRealignByte (int stuffing=0) |
Align the write pointer to the next byte boundary if not already aligned. | |
bool | writeSeek (size_t byte, size_t bit, uint8_t stuffing) |
Reset writing at the specified offset in the buffer and trash forward memory. | |
bool | writeSeek (size_t byte, size_t bit=0) |
Reset writing at the specified offset in the buffer. | |
Static Public Member Functions | |
static UString | ReservedBitsErrorString (std::vector< size_t > &errors, size_t base_offset=0, const UString &margin=UString()) |
This static method returns a string describing "reserved bits errors". | |
Protected Member Functions | |
uint8_t * | currentWriteAddress () const |
Get starting address of current write area (ignoring bit offset inside first byte to read). | |
void | setReadError () |
Set the read error state (reserved to subclasses). | |
void | setWriteError () |
Set the write error state (reserved to subclasses). | |
A specialized subclass of ts::Buffer for PSI serialization.
|
explicit |
Default constructor.
The read and write index are at the beginning of the buffer. So, initially, there is nothing to read and the entire buffer to write.
[in,out] | duck | Reference to TSDuck execution context. |
[in] | size | Initial internal size in bytes of the buffer. |
ts::PSIBuffer::PSIBuffer | ( | DuckContext & | duck, |
void * | data, | ||
size_t | size, | ||
bool | read_only = false |
||
) |
Constructor using an external memory area which must remain valid as long as the PSIBuffer object is used and not reset.
When read_only is true, the read index is at the beginning of the buffer and the write index is at the end of the buffer. When read_only is false, the read and write index are both at the beginning of the buffer.
[in,out] | duck | Reference to TSDuck execution context. |
[in] | data | Address of data area to use as memory buffer. |
[in] | size | Size in bytes of the data area. |
[in] | read_only | The buffer is read-only. |
ts::PSIBuffer::PSIBuffer | ( | DuckContext & | duck, |
const void * | data, | ||
size_t | size | ||
) |
Constructor using a read-only external memory area which must remain valid as long as the PSIBuffer object is used and not reset.
The read index is at the beginning of the buffer and the write index is at the end of the buffer.
[in,out] | duck | Reference to TSDuck execution context. |
[in] | data | Address of data area to use as memory buffer. |
[in] | size | Size in bytes of the data area. |
ts::PSIBuffer::PSIBuffer | ( | DuckContext & | duck, |
const Section & | section | ||
) |
Constructor over the payload of a read-only section which must remain unmodified as long as the PSIBuffer object is used and not reset.
The read index is at the beginning of the section payload and the write index is at the end of the section payload.
|
inline |
Get a reference to the associated TSDuck execution context.
PID ts::PSIBuffer::getPID | ( | ) |
Deserialize a 13-bit PID value.
If the current read pointer is byte-aligned, 3 bits are skipped first. If the current read bit pointer is 3, the PID value is directly read. For all other read pointers, a read error is generated.
bool ts::PSIBuffer::putPID | ( | PID | pid | ) |
Serialize a 13-bit PID value.
If the current write pointer is byte-aligned, 3 '1' bits are written first. If the current write bit pointer is 3, the PID value is directly written. For all other write pointers, a write error is generated.
[in] | pid | 13-bit PID value to write. |
bool ts::PSIBuffer::putLanguageCode | ( | const UString & | str, |
bool | allow_empty = false |
||
) |
Serialize a 3-byte language or country code and advance the write pointer.
[in] | str | String to serialize. Generate a buffer error if not 3 characters long. |
[in] | allow_empty | If true, an empty string is allowed and serialized as zeroes. |
bool ts::PSIBuffer::getLanguageCode | ( | UString & | str | ) |
Read the next 24 bits as a 3-character language or country code and advance the read pointer.
Set the read error flag if there are not enough bits to read or if the current read pointer is not at a byte boundary. Non-ASCII characters are ignored.
[out] | str | Returned decoded string. |
UString ts::PSIBuffer::getLanguageCode | ( | ) |
Read the next 24 bits as a 3-character language or country code and advance the read pointer.
Set the read error flag if there are not enough bits to read or if the current read pointer is not at a byte boundary. Non-ASCII characters are ignored.
|
inline |
Put a string using the preferred output character set.
Generate a write error when the buffer is full before writing the complete string.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
[in] | charset | An optional specific character set to use instead of the default one. |
|
inline |
Put a partial string using the preferred output character set.
Stop either when this string is serialized or when the buffer is full, whichever comes first. Do not generate a write error when the buffer is full.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
[in] | charset | An optional specific character set to use instead of the default one. |
|
inline |
Put a string (preceded by its one-byte length) using the preferred output character set.
Generate a write error when the buffer is full before writing the complete string.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
[in] | charset | An optional specific character set to use instead of the default one. |
|
inline |
Put a partial string (preceded by its one-byte length) using the preferred output character set.
Stop either when this string is serialized or when the buffer is full, whichever comes first. Do not generate a write error when the buffer is full.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
[in] | charset | An optional specific character set to use instead of the default one. |
bool ts::PSIBuffer::getString | ( | UString & | str, |
size_t | size = NPOS , |
||
const Charset * | charset = nullptr |
||
) |
Get a string using the default input character set.
[out] | str | Returned decoded string. |
[in] | size | Size in bytes of the encoded string. If specified as NPOS (the default), read up to the end of the buffer. If different from NPOS, the exact number of bytes must be available or a read error is generated. |
[in] | charset | An optional specific character set to use instead of the default one. |
Get a string using the default input character set.
[in] | size | Size in bytes of the encoded string. If specified as NPOS (the default), read up to the end of the buffer. If different from NPOS, the exact number of bytes must be available or a read error is generated. |
[in] | charset | An optional specific character set to use instead of the default one. |
Get a string (preceded by its one-byte length) using the default input character set.
The specified number of bytes must be available or a read error is generated.
[out] | str | Returned decoded string. |
[in] | charset | An optional specific character set to use instead of the default one. |
Get a string (preceded by its one-byte length) using the default input character set.
The specified number of bytes must be available or a read error is generated.
[in] | charset | An optional specific character set to use instead of the default one. |
|
inline |
Put (serialize) a full Modified Julian Date (MJD), date and time, 5 bytes.
Generate a write error when the buffer is not large enough or when the write pointer is not byte-aligned.
[in] | time | The date and time to serialize. |
|
inline |
Put (serialize) the date part of a Modified Julian Date (MJD), the time part is ignored, 2 bytes.
Generate a write error when the buffer is not large enough or when the write pointer is not byte-aligned.
[in] | time | The date to serialize. |
Put (serialize) a Modified Julian Date (MJD), 2 to 5 bytes.
Generate a write error when the buffer is not large enough or when the write pointer is not byte-aligned.
[in] | time | The date and time to serialize. |
[in] | fmt | Format of the MJD in the buffer. |
|
inline |
Get a full Modified Julian Date (MJD), date and time, 5 bytes.
Generate a read error when there is not enough bytes or when the write pointer is not byte-aligned.
|
inline |
Get the date part of a Modified Julian Date (MJD), the time part is ignored, 2 bytes.
Generate a read error when there is not enough bytes or when the write pointer is not byte-aligned.
Get a Modified Julian Date (MJD), 2 to 5 bytes.
Generate a read error when there is not enough bytes or when the write pointer is not byte-aligned.
[in] | fmt | Format of the MJD in the buffer. |
bool ts::PSIBuffer::putMinutesBCD | ( | const cn::duration< Rep, Period > & | duration | ) |
Put (serialize) a duration in minutes as 4 BCD digits (HHMM), 2 bytes.
Generate a write error when the buffer is not large enough.
[in] | duration | A duration in any std::chrono::duration type. |
bool ts::PSIBuffer::putSecondsBCD | ( | const cn::duration< Rep, Period > & | duration | ) |
Put (serialize) a duration in seconds as 6 BCD digits (HHMMSS), 3 bytes.
Generate a write error when the buffer is not large enough.
[in] | duration | A duration in any std::chrono::duration type. |
void ts::PSIBuffer::getMinutesBCD | ( | cn::duration< Rep, Period > & | duration | ) |
Get (deserialize) a duration in minutes as 4 BCD digits (HHMM), 2 bytes.
Generate a read error when there is not enough bytes.
[out] | duration | Returned duration, converted in any std::chrono::duration type. |
void ts::PSIBuffer::getSecondsBCD | ( | cn::duration< Rep, Period > & | duration | ) |
Get (deserialize) a duration in seconds as 6 BCD digits (HHMMSS), 3 bytes.
Generate a read error when there is not enough bytes.
[out] | duration | Returned duration, converted in any std::chrono::duration type. |
uint64_t ts::PSIBuffer::getVluimsbf5 | ( | ) |
Get (deserialize) an integer value in "vluimsbf5" format.
This weird format is defined in ISO/IEC 23005-6 as follow:
"vluimsbf5: Variable length unsigned integer most significant bit first representation consisting of two parts. The first part defines the number n of 4-bit fields used for the value representation, encoded by a sequence of n-1 "1" bits, followed by a "0" bit signaling its end. The second part contains the value of the integer encoded using the number of bit fields specified in the first part."
Very similar to the following (for connoisseurs only):
"And Saint Attila raised the hand grenade up on high, saying, 'O Lord, bless this thy hand grenade, that with it thou mayst blow thine enemies to tiny bits, in thy mercy.' And the Lord did grin. And the people did feast upon the lambs, and sloths, and carp, and anchovies, and orangutans, and breakfast cereals, and fruit bats, and large chulapas. And the Lord spake, saying, 'First shalt thou take out the Holy Pin. Then shalt thou count to three, no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in My sight, shall snuff it.'"
Generate a read error when there is not enough bytes.
bool ts::PSIBuffer::putVluimsbf5 | ( | uint64_t | value | ) |
Put (serialize) an integer value in "vluimsbf5" format.
Generate a write error when the buffer is not large enough.
[in] | value | An integer to serialize. |
bool ts::PSIBuffer::putDescriptorList | ( | const DescriptorList & | descs, |
size_t | start = 0 , |
||
size_t | count = NPOS |
||
) |
Put (serialize) a complete descriptor list.
Generate a write error when the buffer is not large enough to write all descriptors or when the write pointer is not byte-aligned.
[in] | descs | The descriptor list to serialize into the buffer. |
[in] | start | Starting index in the descriptor list. |
[in] | count | Maximum number of descriptors to serialize. |
size_t ts::PSIBuffer::putPartialDescriptorList | ( | const DescriptorList & | descs, |
size_t | start = 0 , |
||
size_t | count = NPOS |
||
) |
Put (serialize) as many descriptors as possible from a descriptor list.
Generate a write error when the write pointer is not byte-aligned.
[in] | descs | The descriptor list to serialize into the buffer. |
[in] | start | Starting index in the descriptor list. |
[in] | count | Maximum number of descriptors to serialize. |
bool ts::PSIBuffer::putDescriptorListWithLength | ( | const DescriptorList & | descs, |
size_t | start = 0 , |
||
size_t | count = NPOS , |
||
size_t | length_bits = 12 |
||
) |
Put (serialize) a complete descriptor list with a 2-byte length field before the descriptor list.
Generate a write error when the buffer is not large enough to write all descriptors or when the write pointer is not byte-aligned.
The 2-byte length field uses only its N least significant bits (length_bits) for the length of the descriptor list. If the current write pointer is byte-aligned, 16-N '1' bits are written first. If the current write bit pointer is 16-N, the length is directly written after that bit. For all other write pointers, a write error is generated.
[in] | descs | The descriptor list to serialize into the buffer. |
[in] | start | Starting index in the descriptor list. |
[in] | count | Maximum number of descriptors to serialize. |
[in] | length_bits | Number of meaningful bits in the length field. |
size_t ts::PSIBuffer::putPartialDescriptorListWithLength | ( | const DescriptorList & | descs, |
size_t | start = 0 , |
||
size_t | count = NPOS , |
||
size_t | length_bits = 12 |
||
) |
Put (serialize) as many descriptors as possible from a descriptor list with a 2-byte length field before the descriptor list.
The 2-byte length field uses only its N least significant bits (length_bits) for the length of the descriptor list. If the current write pointer is byte-aligned, 16-N '1' bits are written first. If the current write bit pointer is 16-N, the length is directly written after that bit. For all other write pointers, a write error is generated.
[in] | descs | The descriptor list to serialize into the buffer. |
[in] | start | Starting index in the descriptor list. |
[in] | count | Maximum number of descriptors to serialize. |
[in] | length_bits | Number of meaningful bits in the length field. |
bool ts::PSIBuffer::getDescriptorList | ( | DescriptorList & | descs, |
size_t | length = NPOS |
||
) |
Get (deserialize) a descriptor list.
[in,out] | descs | The descriptor list into which the deserialized descriptors are appended. |
[in] | length | Number of bytes to read. If NPOS is specified (the default), read the rest of the buffer. |
bool ts::PSIBuffer::getDescriptorListWithLength | ( | DescriptorList & | descs, |
size_t | length_bits = 12 |
||
) |
Get (deserialize) a descriptor list with a 2-byte length field before the descriptor list.
The 2-byte length field uses only its N least significant bits (length_bits) for the length of the descriptor list. If the current read pointer is byte-aligned, 16-N bits are skipped first. If the current read bit pointer is 16-N, the length is directly read after that bit. For all other read pointers, a read error is generated.
[in,out] | descs | The descriptor list into which the deserialized descriptors are appended. |
[in] | length_bits | Number of meaningful bits in the length field. |
size_t ts::PSIBuffer::getUnalignedLength | ( | size_t | length_bits | ) |
Get a 2-byte integer length field, typically a length before a descriptor list.
The 2-byte integer field uses only its N least significant bits (length_bits). If the current read pointer is byte-aligned, 16-N bits are skipped first. If the current read bit pointer is 16-N, the length is directly read after that bit. For all other read pointers, a read error is generated.
[in] | length_bits | Number of meaningful bits in the integer field. |
bool ts::PSIBuffer::getMultipleString | ( | ATSCMultipleString & | mss, |
size_t | mss_size = NPOS , |
||
bool | ignore_empty = false |
||
) |
Get (deserialize) an ATSC multiple_string_structure() as defined in ATSC A/65.
[out] | mss | The deserialized multiple_string_structure. |
[in] | mss_size | Optional size of the multiple_string_structure to deserialize. If different from NPOS (the default), do not read more than mss_size bytes and move the read pointer after mss_size bytes, even if the multiple_string_structure is shorter. |
[in] | ignore_empty | If true and there is nothing left to read, then this is a valid empty multiple_string_structure. |
bool ts::PSIBuffer::getMultipleStringWithLength | ( | ATSCMultipleString & | mss, |
size_t | length_bytes = 1 |
||
) |
Get (deserialize) an ATSC multiple_string_structure() as defined in ATSC A/65, with a leading byte length.
[out] | mss | The deserialized multiple_string_structure. |
[in] | length_bytes | Size in bytes of the leading length field (1 byte by default). |
bool ts::PSIBuffer::putMultipleString | ( | const ATSCMultipleString & | mss, |
size_t | max_size = NPOS , |
||
bool | ignore_empty = false |
||
) |
Put (serialize) an ATSC multiple_string_structure() as defined in ATSC A/65.
[in] | mss | The multiple_string_structure to serialize. |
[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. |
bool ts::PSIBuffer::putMultipleStringWithLength | ( | const ATSCMultipleString & | mss, |
size_t | length_bytes = 1 |
||
) |
Put (serialize) an ATSC multiple_string_structure() as defined in ATSC A/65, with a leading byte length.
[in] | mss | The multiple_string_structure to serialize. |
[in] | length_bytes | Size in bytes of the leading length field (1 byte by default). |
|
inherited |
Check if the buffer is valid and contains some memory.
|
inlineinherited |
Check if the buffer is read-only.
|
inlineinherited |
Check if the buffer uses some internal private memory buffer.
|
inlineinherited |
Check if the buffer is linked to some external memory area.
|
inlineinherited |
Get the maximum buffer size in bytes.
|
inlineinherited |
Get the current buffer size in bytes.
|
inlineinherited |
Get the current base address of the buffer.
|
inlineinherited |
Specify that read/write operations of integers should use big endian representation.
The endianness of the buffer is not changed by the various reset() operations.
|
inlineinherited |
Specify that read/write operations of integers should use little endian representation.
The endianness of the buffer is not changed by the various reset() operations.
|
inlineinherited |
Specify that read/write operations of integers should use the native endian representation.
The endianness of the buffer is not changed by the various reset() operations.
|
inlineinherited |
Switch the endianness of read/write operations of integers.
The endianness of the buffer is not changed by the various reset() operations.
|
inlineinherited |
Check if read/write operations of integers use big endian representation.
|
inlineinherited |
Check if read/write operations of integers use little endian representation.
|
inlineinherited |
Check if read/write operations of integers use the native endian representation.
|
inherited |
Reset the buffer, remove link to any external memory, reallocate an internal buffer if necessary.
The read and write index are at the beginning of the buffer. So, initially, there is nothing to read and the entire buffer to write.
[in] | size | Internal size in bytes of the buffer. If an internal buffer already exists and is larger than the requested size, it is not shrunk. |
|
inherited |
Reset the buffer using an external memory area which must remain valid as long as the Buffer object is used and not reset.
When read_only is true, the read index is at the beginning of the buffer and the write index is at the end of the buffer. When read_only is false, the read and write index are both at the beginning of the buffer.
[in] | data | Address of data area to use as memory buffer. |
[in] | size | Size in bytes of the data area. |
[in] | read_only | The buffer is read-only. |
|
inherited |
Reset the buffer using a read-only external memory area which must remain valid as long as the Buffer object is used and not reset.
The read index is at the beginning of the buffer and the write index is at the end of the buffer.
[in] | data | Address of data area to use as memory buffer. |
[in] | size | Size in bytes of the data area. |
|
inlineinherited |
Check if there was a read error.
|
inlineinherited |
Check if there was a write error.
|
inlineinherited |
Check if there was a user-generated error.
|
inlineinherited |
Check if there was any kind of error.
|
inlineinherited |
Set the user-generated error state.
This can be used to indicate an application error such as invalid data format for instance.
|
inherited |
Reset reading at the specified offset in the buffer.
Seeking past the write pointer moves the read pointer to the write pointer and generates a read error.
[in] | byte | Index of next byte to read. |
[in] | bit | Offset of next bit to read in this byte. |
|
inherited |
Reset writing at the specified offset in the buffer.
Seeking backward beyond the read pointer moves the write pointer to the read pointer and generates a write error. Seeking forward past the end of buffer moves the write pointer to the end of the buffer and generates a write error.
[in] | byte | Index of next byte to write. |
[in] | bit | Offset of next bit to write in this byte. |
|
inherited |
Reset writing at the specified offset in the buffer and trash forward memory.
Seeking backward beyond the read pointer moves the write pointer to the read pointer and generates a write error. Seeking forward past the end of buffer moves the write pointer to the end of the buffer and generates a write error.
[in] | byte | Index of next byte to write. |
[in] | bit | Offset of next bit to write in this byte. |
[in] | stuffing | When seeking forward, byte value to write in skipped bytes. |
|
inlineinherited |
Check if the current read bit pointer is on a byte boundary.
|
inlineinherited |
Check if the current write bit pointer is on a byte boundary.
|
inherited |
Align the read pointer to the next byte boundary if not already aligned.
Skip any bit in a partially read byte.
|
inherited |
Align the write pointer to the next byte boundary if not already aligned.
Fill bits in a partially written byte with a know value.
[in] | stuffing | Bit value (must be 0 or 1) to write in skipped bits. |
|
inherited |
Skip read bytes forward (ignoring bit offset inside bytes).
[in] | bytes | Number of bytes to skip. |
|
inherited |
Skip read bits forward.
[in] | bits | Number of bits to skip. |
|
inherited |
Skip read reserved bits forward.
[in] | bits | Number of reserved bits to skip. |
[in] | expected | Expected value of each reserved bit. Must be 0 or 1, default is 1. For each reserved bit which does not have the expected value, a "reserved bit error" is logged. |
|
inlineinherited |
Check if there were "reserved bits errors".
|
inlineinherited |
Return a string describing the "reserved bits errors".
[in] | base_offset | Artificial base offset in bytes which is used to describe the placement of each bit error. When the Buffer instance describes the payload of a structure, specify the structure header size as base_offset in order to display each bit error relatively to the complete structure. |
[in] | margin | Prepend that string to each line. |
|
staticinherited |
This static method returns a string describing "reserved bits errors".
[in,out] | errors | A vector of error description. Each value is made of byte offset || bit offset (3 bits) || expected bit value (1 bit). The vector is sorted first. |
[in] | base_offset | Artificial base offset in bytes which is used to describe the placement of each bit error. When the Buffer instance describes the payload of a structure, specify the structure header size as base_offset in order to display each bit error relatively to the complete structure. |
[in] | margin | Prepend that string to each line. |
|
inherited |
Skip read bytes backward.
[in] | bytes | Number of bytes to skip back. |
|
inherited |
Skip read bits backward.
[in] | bits | Number of bits to skip back. |
|
inlineinherited |
Get starting address of current read data (ignoring bit offset inside first byte to read).
|
inlineinherited |
Get current read byte index (ignoring bit offset inside bytes).
|
inlineinherited |
Get current read bit offset from the beginning of the buffer.
|
inlineinherited |
Get current write byte index (ignoring bit offset inside bytes).
|
inlineinherited |
Get current write bit offset from the beginning of the buffer.
|
inherited |
Get number of remaining bytes to read (ignoring bit offset inside bytes).
|
inherited |
Get number of remaining bits to read.
|
inherited |
Get number of remaining bytes to write (ignoring bit offset inside bytes).
|
inherited |
Get number of remaining bits to write.
|
inlineinherited |
Check end of read stream.
|
inlineinherited |
Check end of write stream.
|
inlineinherited |
Check if we can still read from the buffer.
|
inlineinherited |
Check if we can read at least the specified number of bytes from the buffer.
[in] | bytes | Number of bytes. |
|
inlineinherited |
Check if we can read at least the specified number of bits from the buffer.
[in] | bits | Number of bits. |
|
inlineinherited |
Check if we can still write in the buffer.
|
inlineinherited |
Check if we can write at least the specified number of bytes in the buffer.
[in] | bytes | Number of bytes. |
|
inlineinherited |
Check if we can write at least the specified number of bits in the buffer.
[in] | bits | Number of bits. |
|
inherited |
Push the current state of the read/write streams on a stack of saved states.
There is an internal stack of read/write states. It is possible to save the current state of the buffer, try to do some operations and then either restore (pop) the previous state if the attempted operations failed or drop the saved state and continue with the new state.
|
inherited |
Temporary reduce the readable size of the buffer.
The previous state is pushed to the internal stack of state and can be restored later. Saving the readable size temporarily changes the write pointer and sets the buffer as read only. When the state is restored using popState(), the previous readable size (write pointer) and read-only indicator are restored. The read pointer is set to the end of previous readable size.
[in] | size | New readable size in bytes of the buffer. In some cases, the final granted size can be different. The final value is bounded by the current read and write pointers. |
|
inherited |
Temporary reduce the readable size of the buffer using a length field from the stream.
An integer value is read from the stream (given the value size in bits). The read pointer must then be byte-aligned. Finally, pushReadSize() is called so that the remaining number of bytes to read is the length value that was just read.
[in] | length_bits | Size in bits of the length field to read. |
|
inherited |
Temporary reduce the writable size of the buffer.
The previous state is pushed to the internal stack of state and can be restored later. Saving the writable size temporarily changes the end of buffer. When the state is restored using popState(), the previous end of buffer is restored. The read and write pointers are not restored (everything that was read or written in the meantime remain valid).
[in] | size | New writable size in bytes of the buffer. In some cases, the final granted size can be different. The final value is bounded by the current write pointer and end of buffer. |
|
inherited |
Start a write sequence with a leading length field.
The current state is pushed and the specified number of bits are skipped in the write field. The write stream must then be byte-aligned or an error is generated. Writing data can be continued by the application. When popState() is called, the size in bytes starting after the length field is then written in the length field.
[in] | length_bits | Size in bits of the length field to write. Must be in the range 1 to 64. |
|
inherited |
Swap the current state of the read/write streams with the one on top of the stack of saved states.
The previous state must have been fully saved using pushState() only, not any other push method such as pushReadSize() or pushWriteSize(). Otherwise, the buffer is set in read and write error state.
As a result, the previously saved state is restored and the current state (just before restoring the saved state) is pushed. If there was no saved state, the current state is unchanged but still saved. So it is always safe to assume that the current state was saved.
|
inherited |
Pop the current state of the read/write streams from the stack of saved states and perform appropriate actions.
The new state depends on which method was used to push the previous state.
[in] | level | Saved level to restore. The default is NPOS, meaning the last saved state. Another inner level can be specified, in which case all outer levels are also popped. |
|
inherited |
Drop the last saved state of the read/write streams from the stack of saved states.
[in] | level | Saved level to drop. The default is NPOS, meaning the last saved state. Another inner level can be specified, in which case the specified level and all outer levels are dropped. |
|
inlineinherited |
Get the current number of pushed states of the read/write streams.
|
inherited |
Change the usable size of the buffer.
[in] | size | New usable size in bytes of the buffer. In some cases, the final granted size can be different:
|
[in] | reallocate | If true and the buffer is internally allocated, then reallocate the internal buffer to the final accepted size. |
|
inherited |
Read the next bit and advance the read pointer.
|
inlineinherited |
Read the next bit as a boolean and advance the read pointer.
|
inherited |
Write the next bit and advance the write pointer.
[in] | bit | The bit value (0 or 1). |
|
inherited |
Read the next n bits as an integer value and advance the read pointer.
INT | An integer type for the result. |
[in] | bits | Number of bits to read. |
|
inlineinherited |
Read the next n bits as an integer value and advance the read pointer.
INT | An integer type for the result. |
[out] | value | The value of the next bits. |
[in] | bits | Number of bits to read. |
|
inherited |
Read the next n bits as an integer value and advance the read pointer.
INT | An integer type for the result. |
[out] | value | The value of the next bits as a std::optional instance. If no integer can be read, the std::optional is unset. |
[in] | bits | Number of bits to read. |
|
inherited |
Read the next n bits as a std::chrono::duration value and advance the read pointer.
[out] | value | The value of the next bits. |
[in] | bits | Number of bits to read. |
|
inherited |
|
inlineinherited |
Put the next n bits from an integer value and advance the write pointer.
INT | An integer type. |
[in] | value | Integer value to write as a std::optional instance. If value is unset, nothing is written. |
[in] | bits | Number of bits to write. |
|
inlineinherited |
Put the next n bits from a std::chrono::duration value and advance the write pointer.
[in] | value | Integer value to write. |
[in] | bits | Number of bits to write. |
|
inherited |
Serialize the number of reserved '1' bits.
[in] | bits | Number of reserved '1' bits to write. |
|
inlineinherited |
Serialize the number of reserved '0' bits.
[in] | bits | Number of reserved '0' bits to write. |
|
inherited |
Get bulk bytes from the buffer.
The bit aligment is ignored, reading starts at the current read byte pointer, even if a few bits were already read from that byte.
[out] | buffer | Address of the buffer receiving the read bytes. |
[in] | bytes | Number of bytes to read. |
Get bulk bytes from the buffer.
The bit aligment is ignored, reading starts at the current read byte pointer, even if a few bits were already read from that byte.
[in] | bytes | Number of bytes to read. If specified as NPOS, return all remaining bytes. |
Get bulk bytes from the buffer.
The bit aligment is ignored, reading starts at the current read byte pointer, even if a few bits were already read from that byte.
[out] | bb | Byte block receiving the read bytes. |
[in] | bytes | Number of bytes to read. If specified as NPOS, return all remaining bytes. |
Get bulk bytes from the buffer.
The bit aligment is ignored, reading starts at the current read byte pointer, even if a few bits were already read from that byte.
[in,out] | bb | Byte block receiving the read bytes. The read data are appended to bb. |
[in] | bytes | Number of bytes to read. If specified as NPOS, return all remaining bytes. |
|
inherited |
Put bytes in the buffer.
[in] | buffer | Address of the data to write. |
[in] | bytes | Number of bytes to write. |
|
inherited |
Put bulk bytes in the buffer.
The bit aligment is ignored, writing starts at the current write byte pointer, even if a few bits were already written in that byte.
[in] | bb | Byte block containing the data to write. |
[in] | start | Start in index in bb. |
[in] | count | Number of bytes to write. |
|
inlineinherited |
Read the next 8 bits as an unsigned integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 16 bits as an unsigned integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 24 bits as an unsigned integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 32 bits as an unsigned integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 40 bits as an unsigned integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 48 bits as an unsigned integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 64 bits as an unsigned integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 8 bits as a signed integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 16 bits as a signed integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 24 bits as a signed integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 32 bits as a signed integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 40 bits as a signed integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 48 bits as a signed integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 64 bits as a signed integer value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 32 bits as an IEEE float value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Read the next 64 bits as an IEEE float value and advance the read pointer.
Set the read error flag if there are not enough bits to read.
|
inlineinherited |
Write an 8-bit unsigned integer value and advance the write pointer.
[in] | i | 8-bit unsigned integer value to write. |
|
inlineinherited |
Write a 16-bit unsigned integer value and advance the write pointer.
[in] | i | 16-bit unsigned integer value to write. |
|
inlineinherited |
Write a 24-bit unsigned integer value and advance the write pointer.
[in] | i | 24-bit unsigned integer value to write. |
|
inlineinherited |
Write a 32-bit unsigned integer value and advance the write pointer.
[in] | i | 32-bit unsigned integer value to write. |
|
inlineinherited |
Write a 40-bit unsigned integer value and advance the write pointer.
[in] | i | 40-bit unsigned integer value to write. |
|
inlineinherited |
Write a 48-bit unsigned integer value and advance the write pointer.
[in] | i | 48-bit unsigned integer value to write. |
|
inlineinherited |
Write a 64-bit unsigned integer value and advance the write pointer.
[in] | i | 64-bit unsigned integer value to write. |
|
inlineinherited |
Write an 8-bit signed integer value and advance the write pointer.
[in] | i | 8-bit signed integer value to write. |
|
inlineinherited |
Write a 16-bit signed integer value and advance the write pointer.
[in] | i | 16-bit signed integer value to write. |
|
inlineinherited |
Write a 24-bit signed integer value and advance the write pointer.
[in] | i | 24-bit signed integer value to write. |
|
inlineinherited |
Write a 32-bit signed integer value and advance the write pointer.
[in] | i | 32-bit signed integer value to write. |
|
inlineinherited |
Write a 40-bit signed integer value and advance the write pointer.
[in] | i | 40-bit signed integer value to write. |
|
inlineinherited |
Write a 48-bit signed integer value and advance the write pointer.
[in] | i | 48-bit signed integer value to write. |
|
inlineinherited |
Write a 64-bit signed integer value and advance the write pointer.
[in] | i | 64-bit signed integer value to write. |
|
inlineinherited |
Write a 32-bit IEEE float value and advance the write pointer.
[in] | f | 32-bit IEEE float value to write. |
|
inlineinherited |
Write a 64-bit IEEE float value and advance the write pointer.
[in] | f | 32-bit IEEE float value to write. |
|
inherited |
Read the next 4*n bits as a Binary Coded Decimal (BCD) value and advance the read pointer.
If an invalid BCD digit is found, the read error state of the buffer is set after reading all BCD digits.
INT | An integer type. |
[in] | bcd_count | Number of BCD digits (bcd_count * 4 bits). |
|
inherited |
Read the next 4*n bits as a Binary Coded Decimal (BCD) value and advance the read pointer.
If an invalid BCD digit is found, the read error state of the buffer is set after reading all BCD digits.
INT | An integer type. |
[out] | value | The decoded BCD value or zero in case of error. |
[in] | bcd_count | Number of BCD digits (bcd_count * 4 bits). |
|
inherited |
Put the next 4*n bits as a Binary Coded Decimal (BCD) value and advance the write pointer.
INT | An integer type. |
[in] | value | Integer value to write. |
[in] | bcd_count | Number of BCD digits (bcd_count * 4 bits). |
Try to get an ASCII string.
The read-pointer must be byte-aligned. If all bytes are valid ASCII characters (optionally zero-padded), the corresponding string is returned and the read pointer is moved. If the corresponding area is not a valid ASCII string (optionally zero-padded), do not move the read pointer and return an empty string.
[out] | result | Returned ASCII string. If the binary area is zero-padded, the trailing zeroes are not included in the string. This means that result can be shorter than bytes. |
[in] | bytes | Size in bytes of the string. If specified as NPOS (the default), read up to the end of the buffer. If different from NPOS, the exact number of bytes must be available or a read error is generated. |
Try to get an ASCII string.
The read-pointer must be byte-aligned. If all bytes are valid ASCII characters (optionally zero-padded), the corresponding string is returned and the read pointer is moved. If the corresponding area is not a valid ASCII string (optionally zero-padded), do not move the read pointer and return an empty string.
[in] | bytes | Size in bytes of the string. If specified as NPOS (the default), read up to the end of the buffer. If different from NPOS, the exact number of bytes must be available or a read error is generated. |
Get a UTF-8 string.
The read-pointer must be byte-aligned.
[out] | result | Returned decoded string. |
[in] | bytes | Size in bytes of the encoded UTF-8 string. If specified as NPOS (the default), read up to the end of the buffer. If different from NPOS, the exact number of bytes must be available or a read error is generated. |
Get a UTF-8 string.
The read-pointer must be byte-aligned.
[in] | bytes | Size in bytes of the encoded UTF-8 string. If specified as NPOS (the default), read up to the end of the buffer. If different from NPOS, the exact number of bytes must be available or a read error is generated. |
|
inlineinherited |
Get a UTF-8 string (preceded by its length).
The read-pointer must be byte-aligned after reading the length-field. The specified number of bytes must be available or a read error is generated.
[out] | result | Returned decoded string. |
[in] | length_bits | Size in bits in the length field. |
|
inlineinherited |
Get a UTF-8 string (preceded by its length).
The read-pointer must be byte-aligned after reading the length-field. The specified number of bytes must be available or a read error is generated.
[in] | length_bits | Size in bits in the length field. |
Get a UTF-16 string.
The read-pointer must be byte-aligned.
[out] | result | Returned decoded string. |
[in] | bytes | Size in bytes of the encoded UTF-16 string. If specified as NPOS (the default), read up to the end of the buffer. If different from NPOS, the exact number of bytes must be available or a read error is generated. If bytes is an odd value, the last byte is skipped and ignored. |
Get a UTF-16 string.
The read-pointer must be byte-aligned.
[in] | bytes | Size in bytes of the encoded UTF-16 string. If specified as NPOS (the default), read up to the end of the buffer. If different from NPOS, the exact number of bytes must be available or a read error is generated. If bytes is an odd value, the last byte is skipped and ignored. |
|
inlineinherited |
Get a UTF-16 string (preceded by its length).
The read-pointer must be byte-aligned after reading the length-field. The specified number of bytes must be available or a read error is generated. If the extracted length is an odd value, the last byte is skipped and ignored.
[out] | result | Returned decoded string. |
[in] | length_bits | Size in bits in the length field. |
|
inlineinherited |
Get a UTF-16 string (preceded by its length).
The read-pointer must be byte-aligned after reading the length-field. The specified number of bytes must be available or a read error is generated. If the extracted length is an odd value, the last byte is skipped and ignored.
[in] | length_bits | Size in bits in the length field. |
|
inlineinherited |
Put a string using UTF-8 format.
The write-pointer must be byte-aligned. Generate a write error when the buffer is full before writing the complete string.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inlineinherited |
Put a string using UTF-8 format with a fixed binary size (truncate or pad).
The write-pointer must be byte-aligned. Generate a write error when the buffer is full before writing the complete string.
[in] | str | The UTF-16 string to encode. |
[in] | size | Fixed size in bytes to fill. If str cannot be fully serialized, it is truncated. |
[in] | pad | It str does not fill size bytes, pad the remaining bytes with this value. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inlineinherited |
Put a partial string using UTF-8 format.
The write-pointer must be byte-aligned. Stop either when this string is serialized or when the buffer is full, whichever comes first. Do not generate a write error when the buffer is full.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inlineinherited |
Put a string (preceded by its length) using UTF-8 format.
The write-pointer must be byte-aligned after writing the length-field. Generate a write error when the buffer is full before writing the complete string.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
[in] | length_bits | Size in bits in the length field. |
|
inlineinherited |
Put a partial string (preceded by its length) using UTF-8 format.
The write-pointer must be byte-aligned after writing the length-field. Do not generate a write error when the buffer is full.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
[in] | length_bits | Size in bits in the length field. |
|
inlineinherited |
Put a string using UTF-16 format.
The write-pointer must be byte-aligned. Generate a write error when the buffer is full before writing the complete string.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inlineinherited |
Put a string using UTF-16 format with a fixed binary size (truncate or pad).
The write-pointer must be byte-aligned. Generate a write error when the buffer is full before writing the complete string.
[in] | str | The UTF-16 string to encode. |
[in] | size | Fixed size in bytes to fill. If str cannot be fully serialized, it is truncated. |
[in] | pad | It str does not fill size bytes, serialize the remaining UTF-16 characters with this value. If size has an odd value, the last byte is padded with the least significant byte of pad. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inlineinherited |
Put a partial string using UTF-8 format.
The write-pointer must be byte-aligned. Stop either when this string is serialized or when the buffer is full, whichever comes first. Do not generate a write error when the buffer is full.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
|
inlineinherited |
Put a string (preceded by its length) using UTF-16 format.
The write-pointer must be byte-aligned after writing the length-field. Generate a write error when the buffer is full before writing the complete string.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
[in] | length_bits | Size in bits in the length field. |
|
inlineinherited |
Put a partial string (preceded by its length) using UTF-16 format.
The write-pointer must be byte-aligned after writing the length-field. Do not generate a write error when the buffer is full.
[in] | str | The UTF-16 string to encode. |
[in] | start | Starting offset to convert in this UTF-16 string. |
[in] | count | Maximum number of characters to convert. |
[in] | length_bits | Size in bits in the length field. |
|
inlineprotectedinherited |
Get starting address of current write area (ignoring bit offset inside first byte to read).
This operation is reserved to subclasses. Applications can only get a read-only pointer to the current read area (see currentReadAddress()).