PIP
0.4.0_beta2
Platform-Independent Primitives
|
Byte array. More...
Inherits PIDeque< T >.
Classes | |
struct | RawData |
Help struct to store/restore custom blocks of data to/from PIByteArray. More... | |
Public Member Functions | |
PIByteArray () | |
Constructs an empty byte array. | |
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 | resized (int new_size) const |
Return resized byte array. | |
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. | |
PIByteArray | fromBase64 () const |
Return converted from Base 64 data. | |
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". | |
uchar | checksumPlain8 () const |
Returns plain 8-bit checksum. | |
uint | checksumPlain32 () const |
Returns plain 32-bit checksum. | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const PIByteArray &ba) |
Output to std::ostream operator. | |
PICout | operator<< (PICout s, const PIByteArray &ba) |
Output to PICout operator. | |
PIByteArray & | operator<< (PIByteArray &s, uchar v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const short v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const int v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const long &v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const llong &v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const ushort v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const uint v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const ulong &v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const ullong &v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const float v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const double &v) |
Store operator. | |
PIByteArray & | operator<< (PIByteArray &s, const PIByteArray &v) |
Store operator, see Attention for details. | |
PIByteArray & | operator<< (PIByteArray &s, const PIByteArray::RawData &v) |
Store operator, see Attention for details. | |
template<typename Type0 , typename Type1 > | |
PIByteArray & | operator<< (PIByteArray &s, const PIPair< Type0, Type1 > &v) |
Store operator. | |
template<typename T > | |
PIByteArray & | operator<< (PIByteArray &s, const PIVector< T > &v) |
Store operator. | |
template<typename T > | |
PIByteArray & | operator<< (PIByteArray &s, const PIList< T > &v) |
Store operator. | |
template<typename T > | |
PIByteArray & | operator<< (PIByteArray &s, const PIDeque< T > &v) |
Store operator. | |
PIByteArray & | operator>> (PIByteArray &s, uchar &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, short &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, int &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, long &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, llong &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, ushort &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, uint &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, ulong &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, ullong &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, float &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, double &v) |
Restore operator. | |
PIByteArray & | operator>> (PIByteArray &s, PIByteArray &v) |
Restore operator, see Attention for details. | |
PIByteArray & | operator>> (PIByteArray &s, PIByteArray::RawData v) |
Restore operator, see Attention for details. | |
template<typename Type0 , typename Type1 > | |
PIByteArray & | operator>> (PIByteArray &s, PIPair< Type0, Type1 > &v) |
Restore operator. | |
template<typename T > | |
PIByteArray & | operator>> (PIByteArray &s, PIVector< T > &v) |
Restore operator. | |
template<typename T > | |
PIByteArray & | operator>> (PIByteArray &s, PIList< T > &v) |
Restore operator. | |
template<typename T > | |
PIByteArray & | operator>> (PIByteArray &s, PIDeque< T > &v) |
Restore operator. | |
bool | operator== (PIByteArray &f, PIByteArray &s) |
Byte arrays compare operator. | |
bool | operator!= (PIByteArray &f, PIByteArray &s) |
Byte arrays compare operator. | |
PIByteArray & | operator<< (PIByteArray &s, const PIString &v) |
Output operator to PIByteArray. | |
PIByteArray & | operator>> (PIByteArray &s, PIString &v) |
Input operator from PIByteArray. | |
PIByteArray & | operator<< (PIByteArray &s, const PIStringList &v) |
Output operator to PIByteArray. | |
PIByteArray & | operator>> (PIByteArray &s, PIStringList &v) |
Input operator from PIByteArray. | |
PICout | operator<< (PICout s, const PISystemTime &v) |
Output operator to PICout. | |
PIByteArray & | operator<< (PIByteArray &s, const PISystemTime &v) |
Output operator to PIByteArray. | |
PIByteArray & | operator>> (PIByteArray &s, PISystemTime &v) |
Input operator from PIByteArray. | |
Byte array.
This class based on PIDeque<uchar> and provide some handle function to manipulate it.
PIByteArray can be used to store custom data and manipulate it. There are many stream operators to store/restore common types to byte array. Store operators places data at the end of array, restore operators takes data from the beginning of array. In addition there are Base 64 convertions and checksums:
One of the major usage of PIByteArray is stream functions. You can form binary packet from many types (also dynamic types, e.g. PIVector) with one line:
Or you can descibe stream operator of your own type and store/restore vectors of your type:
For store/restore custom data blocks there is PIByteArray::RawData class. Stream operators of this class simply store/restore data block to/from byte array.
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().