The QKnxByteArray class provides an array of unsigned bytes. 更多...
头: | #include <QKnxByteArray> |
qmake: | QT += knx |
typedef | const_iterator |
typedef | const_reverse_iterator |
typedef | iterator |
typedef | reverse_iterator |
QKnxByteArray (QKnxByteArray && other ) | |
QKnxByteArray (const QKnxByteArray & other ) | |
QKnxByteArray (std::initializer_list<quint8> args ) | |
QKnxByteArray (const quint8 * data , int size ) | |
QKnxByteArray (const char * data , int size ) | |
QKnxByteArray (int size , quint8 ch ) | |
QKnxByteArray () | |
QKnxByteArray & | operator= (QKnxByteArray && other ) |
QKnxByteArray & | operator= (const QKnxByteArray & other ) |
~QKnxByteArray () | |
QKnxByteArray & | append (const QKnxByteArray & ba ) |
QKnxByteArray & | append (quint8 ch ) |
QKnxByteArray & | append (int count , quint8 ch ) |
quint8 | at (int i ) const |
QKnxByteArray::iterator | begin () |
QKnxByteArray::const_iterator | begin () const |
QKnxByteArray::const_iterator | cbegin () const |
QKnxByteArray::const_iterator | cend () const |
QKnxByteArray | chop (int len ) const |
void | clear () |
QKnxByteArray::const_iterator | constBegin () const |
const quint8 * | constData () const |
QKnxByteArray::const_iterator | constEnd () const |
bool | contains (const QKnxByteArray & ba ) const |
bool | contains (quint8 ch ) const |
QKnxByteArray::const_reverse_iterator | crbegin () const |
QKnxByteArray::const_reverse_iterator | crend () const |
quint8 * | data () |
const quint8 * | data () const |
QKnxByteArray::iterator | end () |
QKnxByteArray::const_iterator | end () const |
bool | endsWith (const QKnxByteArray & ba ) const |
bool | endsWith (quint8 ch ) const |
QKnxByteArray & | fill (quint8 ch , int size = -1) |
int | indexOf (const QKnxByteArray & ba , int from = 0) const |
int | indexOf (quint8 ch , int from = 0) const |
QKnxByteArray & | insert (int i , const QKnxByteArray & ba ) |
QKnxByteArray & | insert (int i , quint8 ch ) |
QKnxByteArray & | insert (int i , int count , quint8 ch ) |
bool | isEmpty () const |
bool | isNull () const |
int | lastIndexOf (const QKnxByteArray & ba , int from = -1) const |
int | lastIndexOf (quint8 ch , int from = -1) const |
QKnxByteArray | left (int len ) const |
QKnxByteArray | mid (int pos , int len = -1) const |
QKnxByteArray & | prepend (const QKnxByteArray & ba ) |
QKnxByteArray & | prepend (quint8 ch ) |
QKnxByteArray & | prepend (int count , quint8 ch ) |
QKnxByteArray::reverse_iterator | rbegin () |
QKnxByteArray::const_reverse_iterator | rbegin () const |
QKnxByteArray & | remove (int pos , int len ) |
QKnxByteArray::reverse_iterator | rend () |
QKnxByteArray::const_reverse_iterator | rend () const |
QKnxByteArray | repeated (int times ) const |
QKnxByteArray & | replace (int index , int len , const QKnxByteArray & after ) |
QKnxByteArray & | replace (quint8 before , const QKnxByteArray & after ) |
QKnxByteArray & | replace (const QKnxByteArray & before , const QKnxByteArray & after ) |
QKnxByteArray & | replace (quint8 before , quint8 after ) |
void | resize (int size ) |
QKnxByteArray | right (int len ) const |
void | set (int i , quint8 val ) |
void | setValue (int i , quint8 val ) |
int | size () const |
bool | startsWith (const QKnxByteArray & ba ) const |
bool | startsWith (quint8 ch ) const |
void | swap (QKnxByteArray & other ) |
const QByteArray & | toByteArray () const |
QKnxByteArray | toHex (quint8 separator = '\0') const |
quint8 | value (int i , quint8 defaultValue = {}) const |
QKnxByteArray & | operator+= (const QKnxByteArray & ba ) |
QKnxByteArray & | operator+= (quint8 ch ) |
QKnxByteArray | fromByteArray (const QByteArray & byteArray ) |
QKnxByteArray | fromHex (const QKnxByteArray & hexEncoded ) |
QKnxByteArray | fromHex (const QByteArray & hexEncoded ) |
uint | qHash (const QKnxByteArray & key , uint seed = 0) |
bool | operator!= (const QKnxByteArray & a1 , const QKnxByteArray & a2 ) |
const QKnxByteArray | operator+ (const QKnxByteArray & a1 , const QKnxByteArray & a2 ) |
const QKnxByteArray | operator+ (const QKnxByteArray & ba , quint8 ch ) |
const QKnxByteArray | operator+ (quint8 ch , const QKnxByteArray & ba ) |
QDebug | operator<< (QDebug debug , const QKnxByteArray & byteArray ) |
bool | operator== (const QKnxByteArray & a1 , const QKnxByteArray & a2 ) |
A KNX byte array can be used to store both raw bytes (including the string
\0
and any characters that might come after it) and traditional 8-bit
\0
-terminated strings. Using QKnxByteArray is much more convenient than using
const quint8 *
. Behind the scenes, it always ensures that the data is followed by a null-terminator (
\0
).
QKnxByteArray makes a deep copy of the data given, so you can modify it later without experiencing side effects.
Another approach is to set the size of the array using resize () and to initialize the data byte per byte. QKnxByteArray uses 0-based indexes, just like C++ arrays. To access the byte at a particular index position, you can use at (), set (), value () 和 setValue ().
To extract several bytes at a time, use left (), right (),或 mid ().
A KNX byte array can embed
\0
bytes. The
size
() function always returns the size of the whole array, including the embedded
\0
bytes, but excluding the null-terminator added by QKnxByteArray.
After a call to resize (), newly allocated bytes have undefined values. To set all the bytes to a particular value, call fill ().
要获得实际字符数据指针,调用 data () 或 constData (). These functions return a pointer to the beginning of the data. The pointer is guaranteed to remain valid until a non-const function is called on the byte array.
此 typedef 提供 STL 样式 const 迭代器为 QKnxByteArray .
This typedef provides an STL-style const reverse iterator for QKnxByteArray .
This typedef provides an STL-style non-const iterator for QKnxByteArray .
This typedef provides an STL-style non-const reverse iterator for QKnxByteArray .
Move-constructs a QKnxByteArray instance, making it point to the same object that other 所指向的。
构造副本为 other .
Constructs a byte array from the
std::initializer_list
指定通过
args
.
This function overloads QKnxByteArray().
Constructs a byte array from data containing the number of bytes specified by size starting from the beginning of the data.
若 data 为 0,构造 null 字节数组。
若 size 为负, data is assumed to point to a null-terminated string and its length is determined dynamically. The terminating null-character is not considered part of the byte array.
QKnxByteArray makes a deep copy of the string data.
Constructs a byte array of the size size with every byte set to the character ch .
构造空字节数组。
移动赋值 other 到此 QKnxByteArray 实例。
赋值 other to this KNX byte array and returns a reference.
销毁字节数组。
追加字节数组 ba to the end of this byte array.
此函数重载 append()。
追加字符 ch 到此字节数组。
此函数重载 append()。
Appends the number of copies of the character ch 指定通过 count 到此字节数组,并返回此字节数组的引用。
若 count is negative or zero, nothing is appended to the byte array.
Returns the character at the index position i 在字节数组中。
i must be a valid index position in the byte array (that is, between 0 and the value returned by size ()).
返回 STL 样式迭代器 pointing to the first character in the byte array.
此函数重载 begin()。
返回常量 STL 样式迭代器 pointing to the first character in the byte array.
返回常量 STL 样式迭代器 pointing to the imaginary character after the last character in the list.
Returns a byte array that contains the number of leftmost bytes in this byte array calculated by subtracting the amount of bytes specified by len from the amount of bytes of returned by size ().
注意: 行为未定义若 len 为负。
Clears the contents of the byte array and makes it null.
返回常量 STL 样式迭代器 pointing to the first character in the byte array.
Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is null-terminated.
The pointer remains valid until the byte array is reallocated or destroyed.
返回常量 STL 样式迭代器 pointing to the imaginary character after the last character in the list.
返回
true
if the byte array contains an occurrence of the byte array
ba
;否则返回
false
.
此函数重载 contains()。
返回
true
if the byte array contains the character
ch
;否则返回
false
.
返回常量 STL-style reverse iterator pointing to the first character in the byte array, in reverse order.
返回常量 STL-style reverse iterator pointing to one past the last character in the byte array, in reverse order.
Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is null-terminated, which means that the number of bytes in the returned character string is the value returned by size () plus 1 for the null-terminator.
The pointer remains valid until the byte array is reallocated or destroyed.
此函数重载 data()。
返回 STL 样式迭代器 pointing to the imaginary character after the last character in the byte array.
此函数重载 end()。
返回
true
if this byte array ends with the byte array
ba
;否则返回
false
.
此函数重载 endsWith()。
返回
true
if this byte array ends with the character
ch
;否则返回
false
.
Sets every byte in the byte array to the character ch and returns a reference to this byte array. If size is different from -1, the byte array is resized to size 事先。
[static]
QKnxByteArray
QKnxByteArray::
fromByteArray
(const
QByteArray
&
byteArray
)
Returns a byte array constructed from byteArray .
[static]
QKnxByteArray
QKnxByteArray::
fromHex
(const
QKnxByteArray
&
hexEncoded
)
Returns a decoded copy of the hex encoded array hexEncoded . Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.
[static]
QKnxByteArray
QKnxByteArray::
fromHex
(const
QByteArray
&
hexEncoded
)
This function overloads fromHex().
Returns the index position of the first occurrence of the byte array ba in this byte array, searching forward from the index position from . Returns -1 if ba could not be found.
此函数重载 indexOf()。
Returns the index position of the first occurrence of the character ch in the byte array, searching forward from the index position from . Returns -1 if ch could not be found.
Inserts the byte array ba at the index position i and returns a reference to this byte array.
This function overloads insert().
Inserts the character ch at the index position i in the byte array. If i is greater than the number of bytes returned by size (), the array is first extended using resize ().
This function overloads insert().
Inserts the number of copies of the character ch 指定通过 count at the index position i 在字节数组中。
若 i is greater than the value returned by size (), the array is first extended using resize ().
返回
true
if the byte array has the size 0; otherwise returns
false
.
返回
true
if this byte array is null; otherwise returns
false
.
Returns the index position of the last occurrence of the byte array ba in this byte array, searching backward from the index position from 。若 from is -1 (the default), the search starts at the last byte. Returns -1 if ba could not be found.
This function overloads lastIndexOf().
Returns the index position of the last occurrence of the character ch in the byte array, searching backward from the index position from 。若 from is -1 (the default), the search starts at the last byte (that is, the value returned by size () minus 1). Returns -1 if ch cannot be found.
Returns a byte array that contains the number of leftmost bytes in the byte array specified by len .
返回整个字节数组若 len is greater than the value returned by size ().
Returns a byte array containing the number of bytes in the byte array specified by len , starting at the position pos .
若 len 为 -1 (默认),或 pos added to len is equal to or larger than the value returned by size (), returns a byte array containing all bytes starting from the position pos to the end of the byte array.
前置字节数组 ba 到此字节数组,并返回此字节数组的引用。
This function overloads prepend().
前置字符 ch 到此字节数组。
This function overloads prepend().
Prepends the number of copies of the character ch 指定通过 count 到此字节数组。
返回 STL-style reverse iterator pointing to the first character in the byte array, in reverse order.
This function overloads rbegin().
Removes the number of bytes specified by len from the array, starting at the index position pos , and returns a reference to the array.
若 pos is out of range, nothing happens. If pos is valid, but pos added to len is larger than the size of the array, the array is truncated at the position pos .
返回 STL-style reverse iterator pointing to one past the last character in the byte array, in reverse order.
This function overloads rend().
Returns a copy of this byte array repeated the specified number of times .
若 times is less than 1, an empty byte array is returned.
Replaces the number of bytes specified by len beginning at the index position index with the byte array after , and returns a reference to this byte array.
此函数重载 replace()。
Replaces every occurrence of the character before with the byte array after .
此函数重载 replace()。
Replaces every occurrence of the byte array before with the byte array after .
此函数重载 replace()。
Replaces every occurrence of the character before with the character after .
Sets the size of the byte array to the number of bytes specified by size .
若 size is greater than the current size, the byte array is extended to size bytes by adding default-constructed values to the end of the array.
若 size is less than the current size, bytes are removed from the end of the array.
Returns a byte array that contains the number of rightmost bytes in the byte array specified by len .
返回整个字节数组若 len is greater than the value returned by size ().
Sets the character at the index position i in the byte array to val .
i must be a valid index position in the byte array (that is, between 0 and the value returned by size ()).
Sets the value at the index position i in the byte array to val .
If the index i is out of bounds, the function does nothing. If you are certain that i is within bounds, you can use set () instead, which is slightly faster.
另请参阅 value ().
Returns the number of bytes in this byte array. The last byte in the byte array is at the position returned by this function minus 1.
返回
true
if this byte array starts with the byte array
ba
;否则返回
false
.
This function overloads startsWith().
返回
true
if this byte array starts with the character
ch
;否则返回
false
.
Swaps the byte array other with this byte array. This operation is very fast and never fails.
Returns a copy of this byte array as QByteArray .
Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and the letters a-f.
若
separator
不是
\0
, the separator character is inserted between the hex bytes.
范例:
auto macAddress = QKnxByteArray::fromHex("123456abcdef"); macAddress.toHex(':'); // returns "12:34:56:ab:cd:ef" macAddress.toHex(0); // returns "123456abcdef"
Returns the value at the index position i 在字节数组中。
If the index i is out of bounds, the function returns defaultValue , which may be a 默认构造值 . If you are certain that i is within bounds, you can use at () instead, which is slightly faster.
另请参阅 setValue ().
追加字节数组 ba onto the end of this byte array and returns a reference to this byte array.
This function overloads operator+=().
追加字符 ch onto the end of this byte array and returns a reference to this byte array.
返回哈希值为 key ,使用 seed 做计算种子。
返回
true
if the byte array
a1
is not equal to the byte array
a2
;否则返回
false
.
Returns a byte array that is the result of concatenating the byte array a1 和字节数组 a2 .
This function overloads operator+().
Returns a byte array that is the result of concatenating the byte array ba 和字符 ch .
This function overloads operator+().
Returns a byte array that is the result of concatenating the character ch 和字节数组 ba .
Writes the byte array byteArray 到 debug stream.
返回
true
if the byte array
a1
is equal to the byte array
a2
;否则返回
false
.