|
|
| PIByteArray () |
| | Constructs an empty byte array.
|
| |
|
| PIByteArray (const PIByteArray &o) |
| | Constructs copy of byte array "o".
|
| |
|
| PIByteArray (const PIDeque< uchar > &o) |
| | Constructs copy of byte array "o".
|
| |
|
| PIByteArray (const uint size) |
| | Constructs 0-filled byte array with size "size".
|
| |
|
| PIByteArray (const void *data, const uint size) |
| | Constructs byte array from data "data" and size "size".
|
| |
|
| PIByteArray (const uint size, uchar t) |
| | Constructs byte array with size "size" filled by "t".
|
| |
| | PIByteArray (std::initializer_list< uchar > init_list) |
| | Contructs array from C++11 initializer list. More...
|
| |
| void | swap (PIByteArray &other) |
| | Swaps array v other with this array. More...
|
| |
| PIDeque< uchar >::iterator | begin () |
| | Iterator to the first element. More...
|
| |
| PIDeque< uchar >::iterator | end () |
| | Iterator to the element following the last element. More...
|
| |
| PIDeque< uchar >::reverse_iterator | rbegin () |
| | Returns a reverse iterator to the first element of the reversed array. More...
|
| |
| PIDeque< uchar >::reverse_iterator | rend () |
| | Returns a reverse iterator to the element. following the last element of the reversed array. More...
|
| |
| size_t | size () const |
| | Number of elements in the container. More...
|
| |
| ssize_t | size_s () const |
| | Number of elements in the container as signed value. More...
|
| |
| size_t | length () const |
| | Same as size(). More...
|
| |
| size_t | capacity () const |
| | Number of elements that the container has currently allocated space for. More...
|
| |
| bool | isEmpty () const |
| | Checks if the container has no elements. More...
|
| |
| bool | isNotEmpty () const |
| | Checks if the container has elements. More...
|
| |
| bool | any (std::function< bool(uchar e)> test) const |
| | Tests whether at least one element in the array passes the test implemented by the provided function test. More...
|
| |
| bool | every (std::function< bool(uchar e)> test) const |
| | Tests whether all elements in the array passes the test implemented by the provided function test. More...
|
| |
| uchar & | operator[] (size_t index) |
| | Full access to element by index. More...
|
| |
| uchar | at (size_t index) const |
| | Read only access to element by index. More...
|
| |
| uchar & | back () |
| | Last element. More...
|
| |
| uchar & | front () |
| | Last element. More...
|
| |
| bool | contains (uchar e, ssize_t start=0) const |
| | Tests if element e exists in the array. More...
|
| |
| int | entries (uchar e, ssize_t start=0) const |
| | Count elements equal e in the array. More...
|
| |
| int | entries (std::function< bool(uchar e)> test, ssize_t start=0) const |
| | Count elements in the array passes the test implemented by the provided function test. More...
|
| |
| ssize_t | indexOf (const uchar &e, ssize_t start=0) const |
| | Returns the first index at which a given element e can be found in the array, or -1 if it is not present. More...
|
| |
| ssize_t | indexWhere (std::function< bool(const uchar &e)> test, ssize_t start=0) const |
| | Returns the first index passes the test implemented by the provided function test, or -1 if it is not present. can be found in the array, or -1 if it is not present. More...
|
| |
| ssize_t | lastIndexOf (const uchar &e, ssize_t start=-1) const |
| | Returns the last index at which a given element e can be found in the array, or -1 if it is not present. More...
|
| |
| ssize_t | lastIndexWhere (std::function< bool(const uchar &e)> test, ssize_t start=-1) const |
| | Returns the last index passes the test implemented by the provided function test, or -1 if it is not present. More...
|
| |
| uchar * | data (size_t index=0) |
| | Pointer to array. More...
|
| |
| const uchar * | data (size_t index=0) const |
| | Read only pointer to array. More...
|
| |
| PIByteArray & | clear () |
| | Clear array, remove all elements. More...
|
| |
| PIByteArray & | fill (uchar e=0) |
| | Assigns element 'e' to all items in the array. More...
|
| |
| PIByteArray & | fill (std::function< uchar(size_t i)> f) |
| | Assigns result of function 'f(size_t i)' to all items in the array. More...
|
| |
| PIByteArray & | assign (uchar e=0) |
| | Same as fill(). More...
|
| |
| PIByteArray & | assign (size_t new_size, uchar e) |
| | First does resize(new_size) then fill(e). More...
|
| |
| PIByteArray & | resize (size_t new_size, uchar e=0) |
| | Sets size of the array, new elements are copied from e. More...
|
| |
| PIByteArray & | resize (size_t new_size, std::function< uchar(size_t i)> f) |
| | Sets size of the array, new elements created by function f(size_t i). More...
|
| |
|
PIByteArray | resized (uint new_size) const |
| | Return resized byte array.
|
| |
| PIByteArray & | reserve (size_t new_size) |
| | Attempts to allocate memory for at least new_size elements. More...
|
| |
| PIByteArray & | insert (size_t index, uchar e=0) |
| | Inserts value e at index position in the array. More...
|
| |
| PIByteArray & | insert (size_t index, const PIByteArray &v) |
| | Inserts array v at index position in the array. More...
|
| |
| PIByteArray & | insert (size_t index, std::initializer_list< uchar > init_list) |
| | Inserts the given elements at index position in the array. More...
|
| |
| PIByteArray & | remove (size_t index, size_t count=1) |
| | Removes count elements from the middle of the array, starting at index position. More...
|
| |
|
PIByteArray | getRange (size_t index, size_t count) const |
| | Return sub-array starts from "index" and has "count" or less bytes.
|
| |
| PIByteArray | takeRange (size_t index, size_t count) |
| | Cut sub-array of this array. More...
|
| |
| PIByteArray & | reverse () |
| | Reverses this array. More...
|
| |
| PIByteArray | reversed () const |
| | Returns reversed array. More...
|
| |
| PIByteArray & | enlarge (ssize_t add_size, uchar e=0) |
| | Increases or decreases the size of the array by add_size elements. More...
|
| |
| PIByteArray & | removeOne (uchar e) |
| | Remove no more than one element equal e. More...
|
| |
| PIByteArray & | removeAll (uchar e) |
| | Remove all elements equal e. More...
|
| |
| PIByteArray & | removeWhere (std::function< bool(uchar e)> test) |
| | Remove all elements in the array passes the test implemented by the provided function test. More...
|
| |
| PIByteArray & | push_back (uchar e) |
| | Appends the given element e to the end of the array. More...
|
| |
| PIByteArray & | push_back (std::initializer_list< uchar > init_list) |
| | Appends the given elements to the end of the array. More...
|
| |
| PIByteArray & | push_back (const PIByteArray &v) |
| | Appends the given array v to the end of the array. More...
|
| |
|
PIByteArray & | push_back (const void *data_, int size_) |
| | Add to the end data "data" with size "size".
|
| |
| PIByteArray & | push_front (uchar e) |
| | Appends the given element e to the begin of the array. More...
|
| |
| PIByteArray & | push_front (const PIByteArray &v) |
| | Appends the given array v to the begin of the array. More...
|
| |
| PIByteArray & | push_front (std::initializer_list< uchar > init_list) |
| | Appends the given elements to the begin of the array. More...
|
| |
| PIByteArray & | prepend (uchar e) |
| | Appends the given element e to the begin of the array. More...
|
| |
| PIByteArray & | prepend (const PIByteArray &v) |
| | Appends the given array v to the begin of the array. More...
|
| |
| PIByteArray & | prepend (std::initializer_list< uchar > init_list) |
| | Appends the given elements to the begin of the array. More...
|
| |
| PIByteArray & | pop_back () |
| | Remove one element from the end of the array. More...
|
| |
| PIByteArray & | pop_front () |
| | Remove one element from the begining of the array. More...
|
| |
| uchar | take_back () |
| | Remove one element from the end of the array and return it. More...
|
| |
| uchar | take_front () |
| | Remove one element from the begining of the array and return it. More...
|
| |
| PIByteArray | filter (std::function< bool(const uchar &e)> test) const |
| | Returns a new array with all elements that pass the test implemented by the provided function test. More...
|
| |
| void | forEach (std::function< void(const uchar &e)> f) const |
| | Execute function void f(const uchar & e) for every element in array. More...
|
| |
| PIByteArray & | forEach (std::function< void(uchar &e)> f) |
| | Execute function void f(uchar & e) for every element in array. More...
|
| |
| template<typename ST > |
| PIDeque< ST > | map (std::function< ST(const uchar &e)> f) const |
| | Сreates a new array populated with the results of calling a provided function ST f(const uchar & e) on every element in the calling array. More...
|
| |
| template<typename ST > |
| ST | reduce (std::function< ST(const uchar &e, const ST &acc)> f, const ST &initial=ST()) const |
| | Applies the function ST f(const uchar & e, const ST & acc) to each element of the array (from left to right), returns one value. More...
|
| |
|
PIByteArray & | convertToBase64 () |
| | Convert data to Base 64 and return this byte array.
|
| |
|
PIByteArray & | convertFromBase64 () |
| | Convert data from Base 64 and return this byte array.
|
| |
|
PIByteArray | toBase64 () const |
| | Return converted to Base 64 data.
|
| |
|
PIString | toString (int base=16) const |
| | Return string representation of data, each byte in "base" base, separated by spaces.
|
| |
|
PIString | toHex () const |
| | Returns a hex encoded copy of the byte array, without spaces. The hex encoding uses the numbers 0-9 and the letters a-f.
|
| |
|
PIByteArray & | append (const void *data_, int size_) |
| | Add to the end data "data" with size "size".
|
| |
|
PIByteArray & | append (const PIByteArray &data_) |
| | Add to the end byte array "data".
|
| |
|
PIByteArray & | append (uchar t) |
| | Add to the end "t".
|
| |
| PIByteArray & | append (std::initializer_list< uchar > init_list) |
| | Appends the given elements to the end of the array. More...
|
| |
| uchar | checksumPlain8 (bool inverse=true) const |
| | Returns 8-bit checksum. More...
|
| |
| uint | checksumPlain32 (bool inverse=true) const |
| | Returns 32-bit checksum. More...
|
| |
|
uchar | checksumCRC8 () const |
| | Returns 8-bit checksum CRC-8.
|
| |
|
ushort | checksumCRC16 () const |
| | Returns 16-bit checksum CRC-16.
|
| |
|
uint | checksumCRC32 () const |
| | Returns 32-bit checksum CRC-32.
|
| |
|
uint | hash () const |
| | Returns hash of content.
|
| |
|
bool | binaryStreamAppend (const void *d, size_t s) |
| | Write data.
|
| |
|
void | binaryStreamAppend (T v) |
| | Write data.
|
| |
|
bool | binaryStreamTake (void *d, size_t s) |
| | Read data.
|
| |
| ssize_t | binaryStreamSize () const |
| | Returns remain size. More...
|
| |
|
int | binaryStreamTakeInt () |
| | Read int.
|
| |
|
bool | wasReadError () const |
| | Returns whether there has been an incomplete read since last resetReadError() or after the stream was created.
|
| |
|
void | resetReadError () |
| | Reset incomplete read flag.
|
| |
|
(Note that these are not member functions.)
|
|
PICout | operator<< (PICout s, const PIBitArray &ba) |
| | Output operator to PICout.
|
| |
|
bool | operator< (const PIByteArray &v0, const PIByteArray &v1) |
| | Byte arrays compare operator.
|
| |
|
bool | operator> (const PIByteArray &v0, const PIByteArray &v1) |
| | Byte arrays compare operator.
|
| |
|
bool | operator== (const PIByteArray &v0, const PIByteArray &v1) |
| | Byte arrays compare operator.
|
| |
|
bool | operator!= (const PIByteArray &v0, const PIByteArray &v1) |
| | Byte arrays compare operator.
|
| |
|
PIByteArray | operator& (const PIByteArray &v0, const PIByteArray &v1) |
| | Returns bit-wise "and". If non-equal size, then returns empty PIByteArray.
|
| |
|
PIByteArray | operator| (const PIByteArray &v0, const PIByteArray &v1) |
| | Returns bit-wise "or". If non-equal size, then returns empty PIByteArray.
|
| |
|
PIByteArray | operator^ (const PIByteArray &v0, const PIByteArray &v1) |
| | Returns bit-wise "xor". If non-equal size, then returns empty PIByteArray.
|
| |
|
PICout | operator<< (PICout s, const PIByteArray &ba) |
| | Output operator to PICout.
|
| |
|
template<> |
| uint | piHash (const PIByteArray &ba) |
| | Returns PIByteArray::hash() of "ba".
|
| |
|
template<> |
| void | piSwap (PIByteArray &f, PIByteArray &s) |
| | Swap contents betwee "f" and "s".
|
| |
|
template<typename T > |
| PIByteArray | piSerialize (const T &value) |
| | Store "value" to bytearray and returns it.
|
| |
|
template<typename T > |
| T | piDeserialize (const PIByteArray &data) |
| | Restore type "T" from bytearray "data" and returns it.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PISystemMonitor::ProcessStats &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PISystemMonitor::ThreadStats &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIKbdListener::MouseEvent &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIKbdListener::WheelEvent &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIScreenTypes::Cell &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIScreenTypes::TileEvent &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIFile::FileInfo &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIPeer::PeerInfo::PeerAddress &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIPeer::PeerInfo &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PISerial::DeviceInfo &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIString &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIStringList &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIByteArray &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIPropertyStorage::Property &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIPropertyStorage &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIValueTree &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIVariant &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIVariantTypes::Enumerator &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIVariantTypes::Enum &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIVariantTypes::File &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIVariantTypes::Dir &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIVariantTypes::Color &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator<< (PIBinaryStream< PIByteArray > &s, const PIVariantTypes::IODevice &v) |
| | Store operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PISystemMonitor::ProcessStats &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PISystemMonitor::ThreadStats &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIKbdListener::MouseEvent &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIKbdListener::WheelEvent &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIScreenTypes::Cell &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIScreenTypes::TileEvent &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIFile::FileInfo &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIPeer::PeerInfo::PeerAddress &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIPeer::PeerInfo &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PISerial::DeviceInfo &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIString &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIStringList &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIByteArray &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIPropertyStorage::Property &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIPropertyStorage &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIValueTree &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIVariant &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIVariantTypes::Enumerator &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIVariantTypes::Enum &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIVariantTypes::File &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIVariantTypes::Dir &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIVariantTypes::Color &v) |
| | Restore operator.
|
| |
|
PIBinaryStream< PIByteArray > & | operator>> (PIBinaryStream< PIByteArray > &s, PIVariantTypes::IODevice &v) |
| | Restore operator.
|
| |
The PIByteArray class provides an array of bytes.
PIByteArray used to store raw bytes. It can be constructed from any data and size. You can use PIByteArray as binary stream to serialize/deserialize any objects and data. See details Input/Output stream. This class use PIDeque<uchar> and provide some handle function to manipulate it.
Usage
PIByteArray subclass PIBinaryStream and can be used to store custom data and manipulate it. Store operators places data at the end of array, restore operators takes data from the beginning of array. In addition there are Hex and Base64 convertions.
Attention
Stream operator of PIByteArray store byte array as vector, not simply append content of byte array. This operators useful to transmit custom data as PIByteArray packed into parent byte array, e.g. to form packet from PIByteArray. To append one byte array to another use funtion append().
uchar uc(127);
sba << uc;
ba << sba;
The PIByteArray class provides an array of bytes.
Definition: pibytearray.h:42
PIByteArray & clear()
Clear array, remove all elements.
Definition: pibytearray.h:507
PIByteArray & append(const void *data_, int size_)
Add to the end data "data" with size "size".
Definition: pibytearray.h:1094
#define piCout
Macro used for conditional (piDebug) output to PICout(StdOut)
Definition: picout.h:35