PIP 5.6.1
Platform-Independent Primitives
Files | Namespaces | Classes | Functions | Variables
Types

Basic types, value containers and time utilities. More...

Files

file  pibitarray.h
 Packed bit array.
 
file  pibytearray.h
 Byte array.
 
file  pidatetime.h
 Time and date structs.
 
file  piflags.h
 General flags class.
 
file  pinetworkaddress.h
 Network address.
 
file  pipropertystorage.h
 Properties array.
 
file  pisystemtime.h
 System time structs and methods.
 
file  pitime.h
 System time, time and date.
 
file  pitime_win.h
 PITime conversions for Windows This file provides conversion functions between Windows time structures (FILETIME, SYSTEMTIME) and PIP time structures (PISystemTime, PIDateTime).
 
file  pitypesmodule.h
 Convenience includes for the Types module.
 
file  pivaluetree.h
 Attributed values tree.
 
file  pivariant.h
 Variant type.
 
file  pivariantsimple.h
 Simple variant type.
 
file  pivarianttypes.h
 Types for PIVariant.
 

Namespaces

namespace  PIVariantTypes
 Namespace contains several types for PIVariant.
 

Classes

class  PIBitArray
 The PIBitArray class provides a space-efficient array of bits. More...
 
class  PIByteArray
 The PIByteArray class provides an array of bytes with efficient memory management and various manipulation operations. More...
 
class  PITime
 Calendar time. More...
 
class  PIDate
 Calendar date. More...
 
class  PIDateTime
 Calendar date and time. More...
 
class  PIFlags< Enum >
 The PIFlags class is a template container for bit flags with various bitwise operations and comparison operators. More...
 
class  PINetworkAddress
 Network address, IP and port. More...
 
class  PIPropertyStorage
 This class provides key-value properties storage. More...
 
class  PIPropertyStorage::Property
 PIPropertyStorage element. More...
 
class  PISystemTime
 System time with nanosecond precision. More...
 
class  PISystemTime::Frequency
 Frequency type. More...
 
class  PITimeMeasurer
 Time measurements. More...
 
class  PIValueTree
 The PIValueTree class represents a tree structure of PIVariant values with attributes. More...
 
class  PIVariant
 Variant type. More...
 
class  PIVariantSimple
 Lightweight strongly-typed variant for a single value. More...
 
struct  PIVariantTypes::Enumerator
 Name-value pair. More...
 
struct  PIVariantTypes::Enum
 Collection of PIVariantTypes::Enumerator. More...
 
struct  PIVariantTypes::File
 File location description. More...
 
struct  PIVariantTypes::Dir
 Directory description. More...
 
struct  PIVariantTypes::Color
 32-bits color. More...
 
struct  PIVariantTypes::IODevice
 Variant description used to create or configure PIIODevice. More...
 

Functions

 PIByteArray::PIByteArray ()
 Constructs an empty byte array.
 
 PIByteArray::PIByteArray (const PIByteArray &o)
 Constructs copy of byte array "o".
 
 PIByteArray::PIByteArray (const PIDeque< uchar > &o)
 Constructs copy of byte array "o".
 
 PIByteArray::PIByteArray (PIByteArray &&o)
 Move constructor.
 
 PIByteArray::PIByteArray (const uint size)
 Constructs 0-filled byte array with size "size".
 
 PIByteArray::PIByteArray (const void *data, const uint size)
 Constructs byte array from data "data" and size "size".
 
 PIByteArray::PIByteArray (const uint size, uchar t)
 Constructs byte array with size "size" filled by "t".
 
 PIByteArray::PIByteArray (std::initializer_list< uchar > init_list)
 Constructs array from C++11 initializer list. More...
 
void PIByteArray::swap (PIByteArray &other)
 Swaps array v other with this array. More...
 
PIDeque< uchar >::iterator PIByteArray::begin ()
 Iterator to the first element. More...
 
PIDeque< uchar >::iterator PIByteArray::end ()
 Iterator to the element following the last element. More...
 
PIDeque< uchar >::reverse_iterator PIByteArray::rbegin ()
 Returns a reverse iterator to the first element of the reversed array. More...
 
PIDeque< uchar >::reverse_iterator PIByteArray::rend ()
 Returns a reverse iterator to the element. following the last element of the reversed array. More...
 
size_t PIByteArray::size () const
 Number of elements in the container. More...
 
ssize_t PIByteArray::size_s () const
 Number of elements in the container as signed value. More...
 
size_t PIByteArray::length () const
 Same as size(). More...
 
size_t PIByteArray::capacity () const
 Number of elements that the container has currently allocated space for. More...
 
bool PIByteArray::isEmpty () const
 Checks if the container has no elements. More...
 
bool PIByteArray::isNotEmpty () const
 Checks if the container has elements. More...
 
bool PIByteArray::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 PIByteArray::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 & PIByteArray::operator[] (size_t index)
 Full access to element by index. More...
 
uchar PIByteArray::at (size_t index) const
 Read only access to element by index. More...
 
uchar & PIByteArray::back ()
 Last element. More...
 
uchar & PIByteArray::front ()
 Last element. More...
 
bool PIByteArray::contains (uchar e, ssize_t start=0) const
 Tests if element e exists in the array. More...
 
int PIByteArray::entries (uchar e, ssize_t start=0) const
 Count elements equal e in the array. More...
 
int PIByteArray::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 PIByteArray::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 PIByteArray::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 PIByteArray::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 PIByteArray::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 * PIByteArray::data (size_t index=0)
 Pointer to array. More...
 
const uchar * PIByteArray::data (size_t index=0) const
 Read only pointer to array. More...
 
PIByteArrayPIByteArray::clear ()
 Clear array, remove all elements. More...
 
PIByteArrayPIByteArray::fill (uchar e=0)
 Assigns element 'e' to all items in the array. More...
 
PIByteArrayPIByteArray::fill (std::function< uchar(size_t i)> f)
 Assigns result of function 'f(size_t i)' to all items in the array. More...
 
PIByteArrayPIByteArray::assign (uchar e=0)
 Same as fill(). More...
 
PIByteArrayPIByteArray::assign (size_t new_size, uchar e)
 First does resize(new_size) then fill(e). More...
 
PIByteArrayPIByteArray::resize (size_t new_size, uchar e=0)
 Sets size of the array, new elements are copied from e. More...
 
PIByteArrayPIByteArray::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 PIByteArray::resized (uint new_size) const
 Return resized byte array.
 
PIByteArrayPIByteArray::reserve (size_t new_size)
 Attempts to allocate memory for at least new_size elements. More...
 
PIByteArrayPIByteArray::insert (size_t index, uchar e=0)
 Inserts value e at index position in the array. More...
 
PIByteArrayPIByteArray::insert (size_t index, const PIByteArray &v)
 Inserts array v at index position in the array. More...
 
PIByteArrayPIByteArray::insert (size_t index, std::initializer_list< uchar > init_list)
 Inserts the given elements at index position in the array. More...
 
PIByteArrayPIByteArray::remove (size_t index, size_t count=1)
 Removes count elements from the middle of the array, starting at index position. More...
 
PIByteArray PIByteArray::getRange (size_t index, size_t count) const
 Return sub-array starts from "index" and has "count" or less bytes.
 
PIByteArray PIByteArray::takeRange (size_t index, size_t count)
 Cut sub-array of this array. More...
 
PIByteArrayPIByteArray::reverse ()
 Reverses this array. More...
 
PIByteArray PIByteArray::reversed () const
 Returns reversed array. More...
 
PIByteArrayPIByteArray::enlarge (ssize_t add_size, uchar e=0)
 Increases or decreases the size of the array by add_size elements. More...
 
PIByteArrayPIByteArray::removeOne (uchar e)
 Remove no more than one element equal e. More...
 
PIByteArrayPIByteArray::removeAll (uchar e)
 Remove all elements equal e. More...
 
PIByteArrayPIByteArray::removeWhere (std::function< bool(uchar e)> test)
 Remove all elements in the array passes the test implemented by the provided function test. More...
 
PIByteArrayPIByteArray::push_back (uchar e)
 Appends the given element e to the end of the array. More...
 
PIByteArrayPIByteArray::push_back (std::initializer_list< uchar > init_list)
 Appends the given elements to the end of the array. More...
 
PIByteArrayPIByteArray::push_back (const PIByteArray &v)
 Appends the given array v to the end of the array. More...
 
PIByteArrayPIByteArray::push_back (const void *data_, int size_)
 Add to the end data "data" with size "size".
 
PIByteArrayPIByteArray::push_front (uchar e)
 Appends the given element e to the begin of the array. More...
 
PIByteArrayPIByteArray::push_front (const PIByteArray &v)
 Appends the given array v to the begin of the array. More...
 
PIByteArrayPIByteArray::push_front (std::initializer_list< uchar > init_list)
 Appends the given elements to the begin of the array. More...
 
PIByteArrayPIByteArray::prepend (uchar e)
 Appends the given element e to the begin of the array. More...
 
PIByteArrayPIByteArray::prepend (const PIByteArray &v)
 Appends the given array v to the begin of the array. More...
 
PIByteArrayPIByteArray::prepend (std::initializer_list< uchar > init_list)
 Appends the given elements to the begin of the array. More...
 
PIByteArrayPIByteArray::pop_back ()
 Remove one element from the end of the array. More...
 
PIByteArrayPIByteArray::pop_front ()
 Remove one element from the begining of the array. More...
 
uchar PIByteArray::take_back ()
 Remove one element from the end of the array and return it. More...
 
uchar PIByteArray::take_front ()
 Remove one element from the begining of the array and return it. More...
 
PIByteArray 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 PIByteArray::forEach (std::function< void(const uchar &e)> f) const
 Execute function void f(const uchar & e) for every element in array. More...
 
PIByteArrayPIByteArray::forEach (std::function< void(uchar &e)> f)
 Execute function void f(uchar & e) for every element in array. More...
 
template<typename ST >
PIDeque< ST > PIByteArray::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 PIByteArray::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...
 
PIByteArrayPIByteArray::convertToBase64 ()
 Convert data to Base 64 and return this byte array.
 
PIByteArrayPIByteArray::convertFromBase64 ()
 Convert data from Base 64 and return this byte array.
 
PIByteArray PIByteArray::toBase64 () const
 Return converted to Base 64 data.
 
PIString PIByteArray::toString (int base=16) const
 Return string representation of data, each byte in "base" base, separated by spaces.
 
PIString PIByteArray::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.
 
PIByteArrayPIByteArray::append (const void *data_, int size_)
 Add to the end data "data" with size "size".
 
PIByteArrayPIByteArray::append (const PIByteArray &data_)
 Add to the end byte array "data".
 
PIByteArrayPIByteArray::append (uchar t)
 Add to the end "t".
 
PIByteArrayPIByteArray::append (std::initializer_list< uchar > init_list)
 Appends the given elements to the end of the array. More...
 
uchar PIByteArray::checksumPlain8 (bool inverse=true) const
 Returns 8-bit checksum. More...
 
uint PIByteArray::checksumPlain32 (bool inverse=true) const
 Returns 32-bit checksum. More...
 
uchar PIByteArray::checksumCRC8 () const
 Returns 8-bit checksum CRC-8.
 
ushort PIByteArray::checksumCRC16 () const
 Returns 16-bit checksum CRC-16.
 
uint PIByteArray::checksumCRC32 () const
 Returns 32-bit checksum CRC-32.
 
uint PIByteArray::hash () const
 Returns hash of content.
 
static PIByteArray PIByteArray::fromBase64 (const PIByteArray &base64)
 Return converted from Base 64 data.
 
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.
 
s binaryStreamAppend (v.data(), v.size())
 Store operator.
 
s binaryStreamTake (v.data(), v.size())
 Restore operator.
 
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 >
piDeserialize (const PIByteArray &data)
 Restore type "T" from bytearray "data" and returns it.
 
 PIFlags< Enum >::PIFlags ()
 Constructor with flags = 0.
 
 PIFlags< Enum >::PIFlags (Enum e)
 Constructor with flags = Enum "e".
 
 PIFlags< Enum >::PIFlags (const int i)
 Constructor with flags = int "i".
 
PIFlagsPIFlags< Enum >::setFlag (const PIFlags &f, bool on=true)
 Set flags on positions "f" to value "on".
 
PIFlagsPIFlags< Enum >::setFlag (const Enum &e, bool on=true)
 Set flag "e" to value "on".
 
PIFlagsPIFlags< Enum >::setFlag (const int &i, bool on=true)
 Set flag "i" to value "on".
 
void PIFlags< Enum >::operator= (const Enum &e)
 Assign operator.
 
void PIFlags< Enum >::operator= (const int &i)
 Assign operator.
 
bool PIFlags< Enum >::operator== (const PIFlags &f)
 Compare operator.
 
bool PIFlags< Enum >::operator== (const Enum &e)
 Compare operator.
 
bool PIFlags< Enum >::operator== (const int i)
 Compare operator.
 
bool PIFlags< Enum >::operator!= (const PIFlags &f)
 Compare operator.
 
bool PIFlags< Enum >::operator!= (const Enum &e)
 Compare operator.
 
bool PIFlags< Enum >::operator!= (const int i)
 Compare operator.
 
bool PIFlags< Enum >::operator> (const PIFlags &f)
 Compare operator.
 
bool PIFlags< Enum >::operator> (const Enum &e)
 Compare operator.
 
bool PIFlags< Enum >::operator> (const int i)
 Compare operator.
 
bool PIFlags< Enum >::operator< (const PIFlags &f)
 Compare operator.
 
bool PIFlags< Enum >::operator< (const Enum &e)
 Compare operator.
 
bool PIFlags< Enum >::operator< (const int i)
 Compare operator.
 
bool PIFlags< Enum >::operator>= (const PIFlags &f)
 Compare operator.
 
bool PIFlags< Enum >::operator>= (const Enum &e)
 Compare operator.
 
bool PIFlags< Enum >::operator>= (const int i)
 Compare operator.
 
bool PIFlags< Enum >::operator<= (const PIFlags &f)
 Compare operator.
 
bool PIFlags< Enum >::operator<= (const Enum &e)
 Compare operator.
 
bool PIFlags< Enum >::operator<= (const int i)
 Compare operator.
 
void PIFlags< Enum >::operator&= (const PIFlags &f)
 Bit-wise AND operator.
 
void PIFlags< Enum >::operator&= (const Enum &e)
 Bit-wise AND operator.
 
void PIFlags< Enum >::operator&= (const int i)
 Bit-wise AND operator.
 
void PIFlags< Enum >::operator|= (const PIFlags &f)
 Bit-wise OR operator.
 
void PIFlags< Enum >::operator|= (const Enum &e)
 Bit-wise OR operator.
 
void PIFlags< Enum >::operator|= (const int i)
 Bit-wise OR operator.
 
void PIFlags< Enum >::operator^= (const PIFlags &f)
 Bit-wise XOR operator.
 
void PIFlags< Enum >::operator^= (const Enum &e)
 Bit-wise XOR operator.
 
void PIFlags< Enum >::operator^= (const int i)
 Bit-wise XOR operator.
 
PIFlags PIFlags< Enum >::operator& (PIFlags f) const
 Bit-wise AND operator.
 
PIFlags PIFlags< Enum >::operator& (Enum e) const
 Bit-wise AND operator.
 
PIFlags PIFlags< Enum >::operator& (int i) const
 Bit-wise AND operator.
 
PIFlags PIFlags< Enum >::operator| (PIFlags f) const
 Bit-wise OR operator.
 
PIFlags PIFlags< Enum >::operator| (Enum e) const
 Bit-wise OR operator.
 
PIFlags PIFlags< Enum >::operator| (int i) const
 Bit-wise OR operator.
 
PIFlags PIFlags< Enum >::operator^ (PIFlags f) const
 Bit-wise XOR operator.
 
PIFlags PIFlags< Enum >::operator^ (Enum e) const
 Bit-wise XOR operator.
 
PIFlags PIFlags< Enum >::operator^ (int i) const
 Bit-wise XOR operator.
 
bool PIFlags< Enum >::operator[] (Enum e) const
 Test flag operator.
 
 PIFlags< Enum >::operator int () const
 Implicity conversion to int.
 
void piUSleep (int usecs)
 Precise sleep for "usecs" microseconds. More...
 
void piMSleep (double msecs)
 Precise sleep for "msecs" milliseconds. More...
 
void piSleep (double secs)
 Precise sleep for "secs" seconds. More...
 
void piSleep (PISystemTime t)
 Precise sleep for "t" time.
 
void piMinSleep ()
 Shortest available on current system sleep.
 
PISystemTime FILETIME2PISystemTime (const FILETIME &t)
 Converts FILETIME to PISystemTime. Converts Windows FILETIME structure to PISystemTime. FILETIME is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
 
PIDateTime SYSTEMTIME2PIDateTime (const SYSTEMTIME &t)
 Converts SYSTEMTIME to PIDateTime. Converts Windows SYSTEMTIME structure to PIDateTime. SYSTEMTIME represents a date and time using individual members for month, day, year, etc.
 
PIDateTime FILETIME2PIDateTime (const FILETIME &t)
 Converts FILETIME to PIDateTime. Converts Windows FILETIME to PIDateTime. The FILETIME is first converted to local time, then to SYSTEMTIME, and finally to PIDateTime.
 
SYSTEMTIME PIDateTime2SYSTEMTIME (const PIDateTime &dt)
 Converts PIDateTime to SYSTEMTIME. Converts PIDateTime to Windows SYSTEMTIME structure.
 
FILETIME PIDateTime2FILETIME (const PIDateTime &dt)
 Converts PIDateTime to FILETIME. Converts PIDateTime to Windows FILETIME. The PIDateTime is first converted to SYSTEMTIME, then to local FILETIME, and finally to UTC FILETIME.
 
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 >
piDeserialize (const PIByteArray &data)
 Restore type "T" from bytearray "data" and returns it.
 

Variables

return s
 Store operator. More...
 

Detailed Description

Basic types, value containers and time utilities.

This module collects public headers for commonly used value types, variant containers, property helpers, network-address types and time/date utilities.

Function Documentation

◆ PIByteArray()

PIByteArray::PIByteArray ( std::initializer_list< uchar >  init_list)
inline

#include <pibytearray.h>

Constructs array from C++11 initializer list.

PIByteArray v{1,2,3};
piCout << v; // {1, 2, 3}
The PIByteArray class provides an array of bytes with efficient memory management and various manipul...
Definition: pibytearray.h:42
#define piCout
Definition: picout.h:36

◆ swap()

void PIByteArray::swap ( PIByteArray other)
inline

#include <pibytearray.h>

Swaps array v other with this array.

This operation is very fast and never fails.

◆ begin()

PIDeque< uchar >::iterator PIByteArray::begin ( )
inline

#include <pibytearray.h>

Iterator to the first element.

If the array is empty, the returned iterator is equal to end().

Returns
STL-Style Iterators
See also
end(), rbegin(), rend()

◆ end()

PIDeque< uchar >::iterator PIByteArray::end ( )
inline

#include <pibytearray.h>

Iterator to the element following the last element.

This element acts as a placeholder; attempting to access it results in undefined behavior.

Returns
STL-Style Iterators
See also
begin(), rbegin(), rend()

◆ rbegin()

PIDeque< uchar >::reverse_iterator PIByteArray::rbegin ( )
inline

#include <pibytearray.h>

Returns a reverse iterator to the first element of the reversed array.

It corresponds to the last element of the non-reversed array. If the array is empty, the returned iterator is equal to rend().

Returns
STL-Style Iterators
See also
rend(), begin(), end()

◆ rend()

PIDeque< uchar >::reverse_iterator PIByteArray::rend ( )
inline

#include <pibytearray.h>

Returns a reverse iterator to the element. following the last element of the reversed array.

It corresponds to the element preceding the first element of the non-reversed array. This element acts as a placeholder, attempting to access it results in undefined behavior.

Returns
STL-Style Iterators
See also
rbegin(), begin(), end()

◆ size()

size_t PIByteArray::size ( ) const
inline

#include <pibytearray.h>

Number of elements in the container.

See also
size_s(), capacity(), isEmpty(), isNotEmpty(), resize(), reserve()

◆ size_s()

ssize_t PIByteArray::size_s ( ) const
inline

#include <pibytearray.h>

Number of elements in the container as signed value.

See also
size(), capacity(), isEmpty(), isNotEmpty(), resize(), reserve()

◆ length()

size_t PIByteArray::length ( ) const
inline

◆ capacity()

size_t PIByteArray::capacity ( ) const
inline

#include <pibytearray.h>

Number of elements that the container has currently allocated space for.

To find out the actual number of items, use the function size().

See also
reserve(), size(), size_s()

◆ isEmpty()

bool PIByteArray::isEmpty ( ) const
inline

#include <pibytearray.h>

Checks if the container has no elements.

Returns
true if the container is empty, false otherwise
See also
size(), size_s(), isEmpty(), isNotEmpty(), resize(), reserve()

◆ isNotEmpty()

bool PIByteArray::isNotEmpty ( ) const
inline

#include <pibytearray.h>

Checks if the container has elements.

Returns
true if the container is not empty, false otherwise
See also
size(), size_s(), isEmpty(), isNotEmpty(), resize(), reserve()

◆ any()

bool PIByteArray::any ( std::function< bool(uchar e)>  test) const
inline

#include <pibytearray.h>

Tests whether at least one element in the array passes the test implemented by the provided function test.

Returns
true if, in the array, it finds an element for which the provided function returns true; otherwise it returns false. Always returns false if is empty.
See also
every(), contains(), entries(), forEach()

◆ every()

bool PIByteArray::every ( std::function< bool(uchar e)>  test) const
inline

#include <pibytearray.h>

Tests whether all elements in the array passes the test implemented by the provided function test.

Returns
true if, in the array, it finds an element for which the provided function returns true; otherwise it returns false. Always returns true if is empty.
See also
any(), contains(), entries(), forEach()

◆ operator[]()

uchar & PIByteArray::operator[] ( size_t  index)
inline

#include <pibytearray.h>

Full access to element by index.

Element index starts from 0. Element index must be in range from 0 to size()-1. Otherwise will be undefined behavior.

See also
at()

◆ at()

uchar PIByteArray::at ( size_t  index) const
inline

#include <pibytearray.h>

Read only access to element by index.

Element index starts from 0. Element index must be in range from 0 to size()-1. Otherwise will be undefined behavior.

◆ back()

uchar & PIByteArray::back ( )
inline

#include <pibytearray.h>

Last element.

Returns a reference to the last item in the array. This function assumes that the array isn't empty. Otherwise will be undefined behavior.

◆ front()

uchar & PIByteArray::front ( )
inline

#include <pibytearray.h>

Last element.

Returns a reference to the last item in the array. This function assumes that the array isn't empty. Otherwise will be undefined behavior.

◆ contains()

bool PIByteArray::contains ( uchar  e,
ssize_t  start = 0 
) const
inline

#include <pibytearray.h>

Tests if element e exists in the array.

Optional argument start - the position in this array at which to begin searching. If the index is greater than or equal to the array's size, false is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. Default: 0 (entire array is searched).

PIByteArray v{1, 2, 3, 4};
piCout << v.contains(3); // true
piCout << v.contains(5); // false
piCout << v.contains(3, 3); // false
piCout << v.contains(3, -2); // true
piCout << v.contains(3, -99); // true
Returns
true if the array contains an occurrence of element e, otherwise it returns false.
See also
every(), any(), entries()

◆ entries() [1/2]

int PIByteArray::entries ( uchar  e,
ssize_t  start = 0 
) const
inline

#include <pibytearray.h>

Count elements equal e in the array.

Optional argument start - the position in this array at which to begin searching. If the index is greater than or equal to the array's size, 0 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. Default: 0 (entire array is searched).

See also
every(), any(), contains(), indexOf()

◆ entries() [2/2]

int PIByteArray::entries ( std::function< bool(uchar e)>  test,
ssize_t  start = 0 
) const
inline

#include <pibytearray.h>

Count elements in the array passes the test implemented by the provided function test.

Overloaded function. Optional argument start - the position in this array at which to begin searching. If the index is greater than or equal to the array's size, 0 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. Default: 0 (entire array is searched).

See also
every(), any(), contains(), indexWhere()

◆ indexOf()

ssize_t PIByteArray::indexOf ( const uchar &  e,
ssize_t  start = 0 
) const
inline

#include <pibytearray.h>

Returns the first index at which a given element e can be found in the array, or -1 if it is not present.

Optional argument start - the position in this array at which to begin searching. If the index is greater than or equal to the array's size, -1 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. Default: 0 (entire array is searched).

PIByteArray v{2, 5, 9};
piCout << v.indexOf(2); // 0
piCout << v.indexOf(7); // -1
piCout << v.indexOf(9, 2); // 2
piCout << v.indexOf(2, -1); // -1
piCout << v.indexOf(2, -3); // 0
See also
indexWhere(), lastIndexOf(), lastIndexWhere(), contains()

◆ indexWhere()

ssize_t PIByteArray::indexWhere ( std::function< bool(const uchar &e)>  test,
ssize_t  start = 0 
) const
inline

#include <pibytearray.h>

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.

Optional argument start - the position in this array at which to begin searching. If the index is greater than or equal to the array's size, -1 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. Default: 0 (entire array is searched).

PIByteArray v{2, 5, 9};
piCout << v.indexWhere([](const uchar & s){return s > 3;}); // 1
piCout << v.indexWhere([](const uchar & s){return s > 3;}, 2); // 2
piCout << v.indexWhere([](const uchar & s){return s > 10;}); // -1
return s
Store operator.
Definition: pisystemmonitor.h:312
See also
indexOf(), lastIndexOf(), lastIndexWhere(), contains()

◆ lastIndexOf()

ssize_t PIByteArray::lastIndexOf ( const uchar &  e,
ssize_t  start = -1 
) const
inline

#include <pibytearray.h>

Returns the last index at which a given element e can be found in the array, or -1 if it is not present.

Optional argument start - the position in this array at which to start searching backwards. If the index is greater than or equal to the array's size, causes the whole array to be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Therefore, if calculated index less than 0, the array is not searched, and the method returns -1. Note: if the provided index is negative, the array is still searched from back to front. Default: -1 (entire array is searched).

PIByteArray v{2, 5, 9, 2};
piCout << v.lastIndexOf(2); // 3
piCout << v.lastIndexOf(7); // -1
piCout << v.lastIndexOf(2, 2); // 0
piCout << v.lastIndexOf(2, -3); // 0
piCout << v.lastIndexOf(2, -300); // -1
piCout << v.lastIndexOf(2, 300); // 3
See also
indexOf(), indexWhere(), lastIndexWhere(), contains()

◆ lastIndexWhere()

ssize_t PIByteArray::lastIndexWhere ( std::function< bool(const uchar &e)>  test,
ssize_t  start = -1 
) const
inline

#include <pibytearray.h>

Returns the last index passes the test implemented by the provided function test, or -1 if it is not present.

Optional argument start - the position in this array at which to start searching backwards. If the index is greater than or equal to the array's size, causes the whole array to be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Therefore, if calculated index less than 0, the array is not searched, and the method returns -1. Note: if the provided index is negative, the array is still searched from back to front. Default: -1 (entire array is searched).

See also
indexOf(), lastIndexOf(), indexWhere(), contains()

◆ data() [1/2]

uchar * PIByteArray::data ( size_t  index = 0)
inline

#include <pibytearray.h>

Pointer to array.

Optional argument index the position in this array, where is pointer. Default: start of array.

◆ data() [2/2]

const uchar * PIByteArray::data ( size_t  index = 0) const
inline

#include <pibytearray.h>

Read only pointer to array.

The pointer can be used to access and modify the items in the array. The pointer remains valid as long as the array isn't reallocated. Optional argument index the position in this array, where is pointer. Default: start of array.

◆ clear()

PIByteArray & PIByteArray::clear ( )
inline

#include <pibytearray.h>

Clear array, remove all elements.

Note
Reserved memory will not be released.
See also
resize()

◆ fill() [1/2]

PIByteArray & PIByteArray::fill ( uchar  e = 0)
inline

#include <pibytearray.h>

Assigns element 'e' to all items in the array.

See also
resize()

◆ fill() [2/2]

PIByteArray & PIByteArray::fill ( std::function< uchar(size_t i)>  f)
inline

#include <pibytearray.h>

Assigns result of function 'f(size_t i)' to all items in the array.

See also
resize()

◆ assign() [1/2]

PIByteArray & PIByteArray::assign ( uchar  e = 0)
inline

#include <pibytearray.h>

Same as fill().

See also
fill(), resize()

◆ assign() [2/2]

PIByteArray & PIByteArray::assign ( size_t  new_size,
uchar  e 
)
inline

#include <pibytearray.h>

First does resize(new_size) then fill(e).

See also
fill(), resize()

◆ resize() [1/2]

PIByteArray & PIByteArray::resize ( size_t  new_size,
uchar  e = 0 
)
inline

#include <pibytearray.h>

Sets size of the array, new elements are copied from e.

If new_size is greater than the current size(), elements are added to the end; the new elements are initialized from e. If new_size is less than the current size(), elements are removed from the end.

See also
size(), clear()

◆ resize() [2/2]

PIByteArray & PIByteArray::resize ( size_t  new_size,
std::function< uchar(size_t i)>  f 
)
inline

#include <pibytearray.h>

Sets size of the array, new elements created by function f(size_t i).

If new_size is greater than the current size(), elements are added to the end; the new elements created by function f(size_t i). If new_size is less than the current size(), elements are removed from the end.

See also
size(), clear()

◆ reserve()

PIByteArray & PIByteArray::reserve ( size_t  new_size)
inline

#include <pibytearray.h>

Attempts to allocate memory for at least new_size elements.

If you know in advance how large the array will be, you should call this function to prevent reallocations and memory fragmentation. If new_size is greater than the current capacity(), new storage is allocated, otherwise the function does nothing. This function does not change the size() of the array.

See also
size(), capacity(), resize()

◆ insert() [1/3]

PIByteArray & PIByteArray::insert ( size_t  index,
uchar  e = 0 
)
inline

#include <pibytearray.h>

Inserts value e at index position in the array.

The index must be greater than 0 and less than or equal to size().

See also
append(), prepend(), remove()

◆ insert() [2/3]

PIByteArray & PIByteArray::insert ( size_t  index,
const PIByteArray v 
)
inline

#include <pibytearray.h>

Inserts array v at index position in the array.

The index must be greater than or equal to 0 and less than or equal to size().

See also
append(), prepend(), remove()

◆ insert() [3/3]

PIByteArray & PIByteArray::insert ( size_t  index,
std::initializer_list< uchar >  init_list 
)
inline

#include <pibytearray.h>

Inserts the given elements at index position in the array.

The index must be greater than or equal to 0 and less than or equal to size(). Inserts the given elements from C++11 initializer list.

See also
append(), prepend(), remove()

◆ remove()

PIByteArray & PIByteArray::remove ( size_t  index,
size_t  count = 1 
)
inline

#include <pibytearray.h>

Removes count elements from the middle of the array, starting at index position.

See also
resize(), insert(), removeOne(), removeAll(), removeWhere()

◆ takeRange()

PIByteArray PIByteArray::takeRange ( size_t  index,
size_t  count 
)
inline

#include <pibytearray.h>

Cut sub-array of this array.

Parameters
index- index of this array where sub-array starts
count- sub-array size

Index must be in range from 0 to size()-1. If sub-array size more than this array size, than ends early.

◆ reverse()

PIByteArray & PIByteArray::reverse ( )
inline

#include <pibytearray.h>

Reverses this array.

This method reverses an array in place. The first array element becomes the last, and the last array element becomes the first. The reverse method transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array.

See also
reversed()

◆ reversed()

PIByteArray PIByteArray::reversed ( ) const
inline

#include <pibytearray.h>

Returns reversed array.

Returns a copy of the array with elements in reverse order. The first array element becomes the last, and the last array element becomes the first.

See also
reverse()

◆ enlarge()

PIByteArray & PIByteArray::enlarge ( ssize_t  add_size,
uchar  e = 0 
)
inline

#include <pibytearray.h>

Increases or decreases the size of the array by add_size elements.

If add_size > 0 then elements are added to the end of the array. If add_size < 0 then elements are removed from the end of the array. If add_size < 0 and there are fewer elements in the array than specified, then the array becomes empty.

See also
resize()

◆ removeOne()

PIByteArray & PIByteArray::removeOne ( uchar  e)
inline

#include <pibytearray.h>

Remove no more than one element equal e.

See also
remove(), removeAll(), removeWhere()

◆ removeAll()

PIByteArray & PIByteArray::removeAll ( uchar  e)
inline

#include <pibytearray.h>

Remove all elements equal e.

See also
remove(), removeOne(), removeWhere()

◆ removeWhere()

PIByteArray & PIByteArray::removeWhere ( std::function< bool(uchar e)>  test)
inline

#include <pibytearray.h>

Remove all elements in the array passes the test implemented by the provided function test.

See also
remove(), removeOne(), removeWhere()

◆ push_back() [1/3]

PIByteArray & PIByteArray::push_back ( uchar  e)
inline

#include <pibytearray.h>

Appends the given element e to the end of the array.

If size() is less than capacity(), which is most often then the addition will be very fast. In any case, the addition is fast and does not depend on the size of the array. If the new size() is greater than capacity() then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.

See also
push_front(), append(), prepend(), insert()

◆ push_back() [2/3]

PIByteArray & PIByteArray::push_back ( std::initializer_list< uchar >  init_list)
inline

#include <pibytearray.h>

Appends the given elements to the end of the array.

Overloaded function. Appends the given elements from C++11 initializer list.

See also
push_back()

◆ push_back() [3/3]

PIByteArray & PIByteArray::push_back ( const PIByteArray v)
inline

#include <pibytearray.h>

Appends the given array v to the end of the array.

Overloaded function.

See also
push_back()

◆ push_front() [1/3]

PIByteArray & PIByteArray::push_front ( uchar  e)
inline

#include <pibytearray.h>

Appends the given element e to the begin of the array.

If there is free space at the beginning of the array, which is most often, then the addition will be very fast. In any case, the addition is fast and does not depend on the size of the array. If there is no free space at the beginning of the array then all iterators and references (including the past-the-begin iterator) are invalidated. Otherwise only the past-the-begin iterator is invalidated.

See also
push_back(), append(), prepend(), insert()

◆ push_front() [2/3]

PIByteArray & PIByteArray::push_front ( const PIByteArray v)
inline

#include <pibytearray.h>

Appends the given array v to the begin of the array.

Overloaded function.

See also
push_front()

◆ push_front() [3/3]

PIByteArray & PIByteArray::push_front ( std::initializer_list< uchar >  init_list)
inline

#include <pibytearray.h>

Appends the given elements to the begin of the array.

Overloaded function. Appends the given elements from C++11 initializer list.

See also
append()

◆ prepend() [1/3]

PIByteArray & PIByteArray::prepend ( uchar  e)
inline

#include <pibytearray.h>

Appends the given element e to the begin of the array.

If there is free space at the beginning of the array, which is most often, then the addition will be very fast. In any case, the addition is fast and does not depend on the size of the array. If there is no free space at the beginning of the array then all iterators and references (including the past-the-begin iterator) are invalidated. Otherwise only the past-the-begin iterator is invalidated.

See also
push_back(), append(), prepend(), insert()

◆ prepend() [2/3]

PIByteArray & PIByteArray::prepend ( const PIByteArray v)
inline

#include <pibytearray.h>

Appends the given array v to the begin of the array.

Overloaded function.

See also
prepend()

◆ prepend() [3/3]

PIByteArray & PIByteArray::prepend ( std::initializer_list< uchar >  init_list)
inline

#include <pibytearray.h>

Appends the given elements to the begin of the array.

Overloaded function. Appends the given elements from C++11 initializer list.

See also
append()

◆ pop_back()

PIByteArray & PIByteArray::pop_back ( )
inline

#include <pibytearray.h>

Remove one element from the end of the array.

Deleting an element from the end is very fast and does not depend on the size of the array.

See also
pop_front(), take_back(), take_front()

◆ pop_front()

PIByteArray & PIByteArray::pop_front ( )
inline

#include <pibytearray.h>

Remove one element from the begining of the array.

Removing an element from the beginning takes longer than from the end. This time is directly proportional to the size of the array. All iterators and references are invalidated.

See also
pop_back(), take_back(), take_front()

◆ take_back()

uchar PIByteArray::take_back ( )
inline

#include <pibytearray.h>

Remove one element from the end of the array and return it.

See also
take_front(), pop_back(), pop_front()

◆ take_front()

uchar PIByteArray::take_front ( )
inline

#include <pibytearray.h>

Remove one element from the begining of the array and return it.

See also
take_front(), pop_back(), pop_front()

◆ filter()

PIByteArray PIByteArray::filter ( std::function< bool(const uchar &e)>  test) const
inline

#include <pibytearray.h>

Returns a new array with all elements that pass the test implemented by the provided function test.

PIByteArray v{3, 2, 5, 2, 7};
PIByteArray v2 = v.filter([](const uchar & i){return i > 2;});
piCout << v2; // {3, 5, 7}
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.
Definition: pibytearray.h:953
See also
map(), any(), every()

◆ forEach() [1/2]

void PIByteArray::forEach ( std::function< void(const uchar &e)>  f) const
inline

#include <pibytearray.h>

Execute function void f(const uchar & e) for every element in array.

Does not allow changing array elements. To edit elements, use the function like void f(T & e)

PIByteArray v{1, 2, 3, 4, 5};
int s = 0;
v.forEach([&s](const uchar & e){s += e;});
piCout << s; // 15
See also
filter(), map(), reduce(), any(), every()

◆ forEach() [2/2]

PIByteArray & PIByteArray::forEach ( std::function< void(uchar &e)>  f)
inline

#include <pibytearray.h>

Execute function void f(uchar & e) for every element in array.

Overloaded function. Allows you to change the elements of the array.

PIByteArray v{1, 2, 3, 4, 5};
v.forEach([](uchar & e){e++;});
piCout << v; // {2, 3, 4, 5, 6}
void forEach(std::function< void(const uchar &e)> f) const
Execute function void f(const uchar & e) for every element in array.
Definition: pibytearray.h:969
See also
filter(), map(), reduce(), any(), every()

◆ map()

template<typename ST >
PIDeque< ST > PIByteArray::map ( std::function< ST(const uchar &e)>  f) const
inline

#include <pibytearray.h>

С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.

Calls a provided functionST f(const uchar & e) once for each element in an array, in order, and constructs a new array from the results.

PIByteArray v{0x31, 0x0A, 0xFF};
PIStringList sl = v.map<PIString>([](const uchar & i){return PIString::fromNumber(i, 16);});
piCout << sl; {"31", "A", "FF"}
String class.
Definition: pistring.h:42
static PIString fromNumber(const short value, int base=10, bool *ok=0)
Returns string contains numeric representation of "value" in base "base".
Definition: pistring.h:1776
Based on PIDeque<PIString> strings list.
Definition: pistringlist.h:36
See also
forEach(), reduce()

◆ reduce()

template<typename ST >
ST PIByteArray::reduce ( std::function< ST(const uchar &e, const ST &acc)>  f,
const ST &  initial = ST() 
) const
inline

#include <pibytearray.h>

Applies the function ST f(const uchar & e, const ST & acc) to each element of the array (from left to right), returns one value.

The reduce() method performs the f function once for each element in the array. If the initial argument is passed when calling reduce(), then when the function f is called for the first time, the value of acc will be assigned to initial. If the array is empty, the value initial will be returned.

Parameters
fis a function like ST f(const uchar & e, const ST & acc), executed for each element of the array. It takes two arguments:
  • e - current element of the array
  • acc - accumulator accumulating the value which this function returns after visiting the next element
initialoptional Object used as the second argument when the f function is first called.
PIByteArray v{1, 2, 3, 4, 5};
PIString s = v.reduce<PIString>([](const uchar & e, const PIString & acc){return acc + PIString::fromNumber(e);});
piCout << s; // "12345"
See also
forEach(), map()

◆ append()

PIByteArray & PIByteArray::append ( std::initializer_list< uchar >  init_list)
inline

#include <pibytearray.h>

Appends the given elements to the end of the array.

Overloaded function. Appends the given elements from C++11 initializer list.

See also
push_back()

◆ checksumPlain8()

uchar PIByteArray::checksumPlain8 ( bool  inverse = true) const

#include <pibytearray.h>

Returns 8-bit checksum.

This is simple sum of all bytes, if "inverse" then add 1 and inverse. Pseudocode:

for (i)
sum += at(i);
if (inverse) return ~(sum + 1);
else return sum;
uchar at(size_t index) const
Read only access to element by index.
Definition: pibytearray.h:240

◆ checksumPlain32()

uint PIByteArray::checksumPlain32 ( bool  inverse = true) const

#include <pibytearray.h>

Returns 32-bit checksum.

This is sum of all bytes multiplied by index+1, if inverse then add 1 and inverse. Pseudocode:

for (i)
sum += at(i) * (i + 1);
if (inverse) return ~(sum + 1);
else return sum;

◆ piUSleep()

void piUSleep ( int  usecs)

#include <pitime.h>

Precise sleep for "usecs" microseconds.

This function consider "usleep" offset on QNX/Linux/Mac, which is calculated with pip_sys_test program. If this is correct offset value in system config, this function wait exactly "usecs" microseconds.

◆ piMSleep()

void piMSleep ( double  msecs)
inline

#include <pitime.h>

Precise sleep for "msecs" milliseconds.

This function exec piUSleep (msecs * 1000)

◆ piSleep()

void piSleep ( double  secs)
inline

#include <pitime.h>

Precise sleep for "secs" seconds.

This function exec piUSleep (msecs * 1000000)

Variable Documentation

◆ s

return s

#include <pisystemmonitor.h>

Initial value:
{
s << PIMemoryBlock(&v, sizeof(PISystemMonitor::ProcessStatsFixed)) << v.exec_name << v.state
Helper struct to store and restore custom blocks of data to/from PIBinaryStream.
Definition: pimemoryblock.h:40
Process statistics (fixed-size fields).
Definition: pisystemmonitor.h:59

Store operator.

Binary stream read operator for PFTFileInfo.

Binary stream write operator for PFTFileInfo.

Binary stream read operator for PFTHeader.

Binary stream read operator for StartRequest.

Binary stream write operator for StartRequest.

Binary stream read operator for Part.

Binary stream write operator for Part.

Binary stream read operator for PacketHeader.

Restore operator for WheelEvent.

Store operator for WheelEvent.

Restore operator for MouseEvent.

Restore operator.

See also
BINARY_STREAM_WRITE