81 PINDEX elementSizeInBytes,
82 PINDEX initialSize = 0
104 PINDEX elementSizeInBytes,
107 PINDEX bufferSizeInElements,
240 PINDEX elementSizeInBytes
288 PINDEX initialSize = 0
335 return index < GetSize() ? (reinterpret_cast<T *>(
theArray))[index] : T();
421 operator T
const *()
const {
448 stream <<
GetAt(index);
462 #define PBASEARRAY(cls, T) typedef PBaseArray<T> cls
476 #define PDECLARE_BASEARRAY(cls, T) \
477 PDECLARE_CLASS(cls, PBaseArray<T>) \
478 cls(PINDEX initialSize = 0) \
479 : PBaseArray<T>(initialSize) { } \
480 cls(PContainerReference & reference_) \
481 : PBaseArray<T>(reference_) { } \
482 cls(T const * buffer, PINDEX length, PBoolean dynamic = true) \
483 : PBaseArray<T>(buffer, length, dynamic) { } \
484 virtual PObject * Clone() const \
485 { return PNEW cls(*this, GetSize()); } \
515 PINDEX initialSize = 0
524 ) :
PBaseArray<T>(buffer, length, dynamic) { }
535 this->
SetAt(index, t);
548 #define PSCALAR_ARRAY(cls, T) typedef PScalarArray<T> cls
563 PINDEX initialSize = 0
616 PINDEX initialSize = 0
649 template <
typename T>
const T &
GetAs(PINDEX offset = 0)
652 return *(
const T *)(
theArray+offset);
663 PHexDump(
const void * data, PINDEX length,
bool compact =
true)
664 :
PBYTEArray(static_cast<const BYTE *>(data), length, false)
673 virtual void PrintOn(ostream & strm)
const;
727 PINDEX initialSize = 0
767 virtual PINDEX
GetSize()
const;
938 PINDEX initialSize = 0
965 return dynamic_cast<T &
>(*obj);
985 #define PARRAY(cls, T) typedef PArray<T> cls
1000 #define PDECLARE_ARRAY(cls, T) \
1001 PARRAY(cls##_PTemplate, T); \
1002 PDECLARE_CLASS(cls, cls##_PTemplate) \
1004 inline cls(int dummy, const cls * c) \
1005 : cls##_PTemplate(dummy, c) { } \
1007 inline cls(PINDEX initialSize = 0) \
1008 : cls##_PTemplate(initialSize) { } \
1009 virtual PObject * Clone() const \
1010 { return PNEW cls(0, this); } \
1025 PINDEX initialSize = 0
1031 const void * buffer,
1052 virtual PINDEX
GetSize()
const;
1096 const void * buffer,
1131 )
const {
return GetAt(index); }
1140 ) {
SetAt(index,
true);
return *
this; }
1149 ) {
SetAt(index,
false);
return *
this; }
1169 #endif // PTLIB_ARRAY_H
virtual PObject * RemoveAt(PINDEX index)
Remove the object at the specified ordinal index from the collection.
PBaseArray(PContainerReference &reference_)
Definition: array.h:451
PBYTEArray(PINDEX initialSize=0)
Construct a new dynamic array of unsigned chars.
Definition: array.h:615
PBYTEArray(PContainerReference &reference_)
Definition: array.h:627
An array of objects.
Definition: array.h:714
virtual PBoolean SetAt(PINDEX index, PObject *val)
Set the object at the specified ordinal position to the new value.
PHexDump(const void *data, PINDEX length, bool compact=true)
Definition: array.h:663
const T & GetAs(PINDEX offset=0)
Function to cast block of memory in PBYTEArray to another structure.
Definition: array.h:649
virtual PINDEX GetSize() const
Get size of array.
virtual void ReadElementFrom(istream &stream, PINDEX index)
Definition: array.h:528
Array of characters.
Definition: array.h:552
T & operator[](PINDEX index) const
Retrieve a reference to the object in the array.
Definition: array.h:960
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
virtual PObject * GetAt(PINDEX index) const
Get the object at the specified ordinal position.
PBitArray & operator+=(PINDEX index)
Set a bit to the array.
Definition: array.h:1138
T & operator[](PINDEX index)
Get a reference to value from the array.
Definition: array.h:400
void Attach(const void *buffer, PINDEX bufferSize)
Attach a pointer to a static block to the bit array type.
This template class maps the PAbstractArray to a specific element type.
Definition: array.h:276
PBaseArray(PINDEX initialSize=0)
Construct a new dynamic array of elements of the specified type.
Definition: array.h:287
virtual void RemoveAll()
Remove all of the elements in the collection.
void Attach(const T *buffer, PINDEX bufferSize)
Attach a pointer to a static block to the base array type.
Definition: array.h:346
PHexDump(const PBYTEArray &data, bool compact=true)
Definition: array.h:668
PScalarArray< DWORD > PDWORDArray
Array of unsigned long integers.
Definition: array.h:687
PINLINE PArrayObjects(PINDEX initialSize=0)
Create a new array of objects.
#define PINLINE
Definition: object.h:194
PBoolean SetAt(PINDEX index, T val)
Set the specific element in the array.
Definition: array.h:318
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
A new or malloc failed.
Definition: object.h:371
PBoolean Concatenate(const PBitArray &array)
Concatenate one array to the end of this array.
T operator[](PINDEX index) const
Get a value from the array.
Definition: array.h:384
PScalarArray< WORD > PWORDArray
Array of unsigned short integers.
Definition: array.h:681
virtual Comparison Compare(const PObject &obj) const
Get the relative rank of the two arrays.
virtual PBoolean SetSize(PINDEX newSize)
Set the size of the array in bits.
PBoolean operator[](PINDEX index) const
Get a value from the array.
Definition: array.h:1129
virtual void ReadElementFrom(istream &stream, PINDEX index)
PScalarArray(PINDEX initialSize=0)
Construct a new dynamic array of elements of the specified type.
Definition: array.h:514
virtual void ReadFrom(istream &strm)
Read the array.
PBaseArray(T const *buffer, PINDEX length, PBoolean dynamic=true)
Construct a new dynamic array of elements of the specified type.
Definition: array.h:293
virtual PObject * Clone() const
Make a complete duplicate of the array.
Definition: array.h:947
PCharArray(PINDEX initialSize=0)
Construct a new dynamic array of char.
Definition: array.h:562
virtual void PrintOn(ostream &strm) const
Print the array.
This class contains a variable length array of arbitrary memory blocks.
Definition: array.h:65
PScalarArray< short > PShortArray
Array of short integers.
Definition: array.h:596
PBoolean GetAt(PINDEX index) const
Get a bit from the array.
virtual PObject * Clone() const
Clone the object.
Definition: array.h:641
virtual PINDEX GetLength() const
Retrun the length in bytes for the array.
PScalarArray< long > PLongArray
Array of long integers.
Definition: array.h:602
PScalarArray< unsigned > PUnsignedArray
Array of unsigned integers.
Definition: array.h:684
PCharArray(PContainerReference &reference_)
Definition: array.h:574
PBaseArray< PObject * > * theArray
Definition: array.h:914
Array of unsigned characters.
Definition: array.h:605
void Attach(const void *buffer, PINDEX bufferSize)
Attach a pointer to a static block to the base array type.
char * theArray
Pointer to the allocated block of memory.
Definition: array.h:247
virtual void PrintOn(ostream &strm) const
Output the contents of the object to the stream.
PINDEX elementSize
Size of an element in bytes.
Definition: array.h:244
virtual PINDEX Append(PObject *obj)
Append a new object to the collection.
PBoolean SetAt(PINDEX index, PBoolean val)
Set the specific bit in the array.
virtual PINDEX GetSize() const
Get the current size of the container.
virtual PObject * Clone() const
Clone the object.
Definition: array.h:588
bool PBoolean
Definition: object.h:174
virtual PINDEX InsertAt(PINDEX index, PObject *obj)
Insert a new object at the specified ordinal index.
virtual void ReadFrom(istream &strm)
Input the contents of the object from the stream.
virtual PINDEX GetSize() const
Get the current size of the container.
This class represents a dynamic bit array.
Definition: array.h:1015
virtual void PrintElementOn(ostream &stream, PINDEX index) const
virtual void PrintOn(ostream &strm) const
Print the array.
const void * GetPointer() const
Definition: array.h:204
T * GetPointer(PINDEX minSize=0)
Get a pointer to the internal array and assure that it is of at least the specified size...
Definition: array.h:366
PBYTEArray(BYTE const *buffer, PINDEX length, PBoolean dynamic=true)
Construct a new dynamic array of unsigned chars.
Definition: array.h:621
Abstract class to embody the base functionality of a container.
Definition: contain.h:99
#define PASSERTINDEX(idx)
Definition: object.h:88
virtual PBoolean Remove(const PObject *obj)
Remove the object from the collection.
virtual PObject * Clone() const
Clone the object.
PBoolean InternalSetSize(PINDEX newSize, PBoolean force)
PScalarArray< int > PIntArray
Array of integers.
Definition: array.h:599
Helper class for outputting a block of memory in hex.
Definition: array.h:659
virtual Comparison Compare(const PObject &obj) const
Get the relative rank of the two arrays.
PArray(int dummy, const PArray *c)
Definition: array.h:970
PBitArray & operator-=(PINDEX index)
Set a bit to the array.
Definition: array.h:1147
virtual PObject * Clone() const
Clone the object.
Definition: array.h:304
Invalid parameter was passed to a function.
Definition: object.h:378
T GetAt(PINDEX index) const
Get a value from the array.
Definition: array.h:331
PBoolean allocatedDynamically
Flag indicating the array was allocated on the heap.
Definition: array.h:250
bool m_compact
Definition: array.h:676
virtual PINDEX Insert(const PObject &before, PObject *obj)
Insert a new object immediately before the specified object.
PBoolean SetMinSize(PINDEX minSize)
Set the minimum size of container.
This template class maps the PArrayObjects to a specific object type.
Definition: array.h:925
virtual void PrintElementOn(ostream &stream, PINDEX index) const
Definition: array.h:444
#define PAssert(b, msg)
This macro is used to assert that a condition must be true.
Definition: object.h:400
This template class maps the PAbstractArray to a specific element type.
Definition: array.h:504
PArray(PINDEX initialSize=0)
Create a new array of objects.
Definition: array.h:937
A NULL array element object was accessed.
Definition: object.h:375
PCharArray(char const *buffer, PINDEX length, PBoolean dynamic=true)
Construct a new dynamic array of char.
Definition: array.h:568
virtual PBoolean SetSize(PINDEX newSize)
Set the size of the array in objects.
virtual PBoolean SetSize(PINDEX newSize)
Set the size of the array in elements.
PContainerReference * reference
Definition: contain.h:288
PBoolean Concatenate(const PBaseArray &array)
Concatenate one array to the end of this array.
Definition: array.h:436
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
A collection is a container that collects together descendents of the PObject class.
Definition: contain.h:392
virtual PINDEX GetValuesIndex(const PObject &obj) const
Search the collection for the specified value of the object.
virtual PINDEX GetObjectsIndex(const PObject *obj) const
Search the collection for the specific instance of the object.
PBitArray(PINDEX initialSize=0)
Construct a new dynamic array of bits.
PScalarArray(T const *buffer, PINDEX length, PBoolean dynamic=true)
Construct a new dynamic array of elements of the specified type.
Definition: array.h:520
PBoolean Concatenate(const PAbstractArray &array)
Concatenate one array to the end of this array.
#define PNEW
Macro for overriding system default new operator.
Definition: object.h:1896
virtual void ReadFrom(istream &strm)
Read the array.
PAbstractArray(PINDEX elementSizeInBytes, PINDEX initialSize=0)
Create a new dynamic array of initalSize elements of elementSizeInBytes bytes each.
virtual void PrintOn(ostream &strm) const
Print the array.