CFX_ObjectArray< ObjectClass > Class Template Reference
Inheritance diagram for CFX_ObjectArray< ObjectClass >:
CFX_BasicArray

Public Member Functions

 CFX_ObjectArray (IFX_Allocator *pAllocator=0)
 The constructor. More...
 
 CFX_ObjectArray (const CFX_ObjectArray &other, IFX_Allocator *pAllocator=0)
 The copy constructor. More...
 
 ~CFX_ObjectArray ()
 The destructor.
 
void Add (const ObjectClass &data)
 Add a copy of an existing object to the array. More...
 
ObjectClass & Add ()
 Add an empty object to the array. More...
 
void * AddSpace ()
 Add an empty space to the array. More...
 
FX_INT32 Append (const CFX_ObjectArray &src, FX_INT32 nStart=0, FX_INT32 nCount=-1)
 Append an array. More...
 
FX_INT32 Copy (const CFX_ObjectArray &src, FX_INT32 nStart=0, FX_INT32 nCount=-1)
 Copy from an array. More...
 
ObjectClass * GetDataPtr (int index) const
 Get a pointer to the specified element in the array. Direct pointer access. More...
 
int GetSize () const
 Get the size of the array. More...
 
CFX_ObjectArrayoperator= (const CFX_ObjectArray &other)
 The assignment operator. More...
 
ObjectClass & operator[] (int index) const
 Subscript([]) operator overload. This function returns a reference to the specified object specified by the zero-based index in nIndex. More...
 
void RemoveAll ()
 Remove all objects in the array. More...
 
void RemoveAt (int index)
 Remove an object at specified position. More...
 

Additional Inherited Members

- Public Attributes inherited from CFX_BasicArray
IFX_Allocatorm_pAllocator
 Special allocator pointer. NULL to use default allocator.
 

Detailed Description

template<class ObjectClass>
class CFX_ObjectArray< ObjectClass >

The class represents Object array template. Each object in the array is "owned" by the array, so when this array is destructed, or an object is removed from the array, the object(s) will be destructed.

The template parameter <class T> must support "placement new". (any class derived from CFX_Object supports placement new).

Constructor & Destructor Documentation

◆ CFX_ObjectArray() [1/2]

template<class ObjectClass>
CFX_ObjectArray< ObjectClass >::CFX_ObjectArray ( IFX_Allocator pAllocator = 0)
inline

The constructor.

Parameters
[in]pAllocatorAn allocator. Default value: NULL.

◆ CFX_ObjectArray() [2/2]

template<class ObjectClass>
CFX_ObjectArray< ObjectClass >::CFX_ObjectArray ( const CFX_ObjectArray< ObjectClass > &  other,
IFX_Allocator pAllocator = 0 
)
inline

The copy constructor.

Parameters
[in]otherThe other object array.
[in]pAllocatorAn allocator. Default value: NULL.

Member Function Documentation

◆ Add() [1/2]

template<class ObjectClass>
void CFX_ObjectArray< ObjectClass >::Add ( const ObjectClass &  data)
inline

Add a copy of an existing object to the array.

To call this function, the template parameter class must support copy constructor.

Parameters
[in]dataThe input object.
Returns
None.

◆ Add() [2/2]

template<class ObjectClass>
ObjectClass& CFX_ObjectArray< ObjectClass >::Add ( )
inline

Add an empty object to the array.

To call this function, the template parameter class must support default constructor.

Returns
A reference to the newly added object.

◆ AddSpace()

template<class ObjectClass>
void* CFX_ObjectArray< ObjectClass >::AddSpace ( )
inline

Add an empty space to the array.

Caller should initialize object at once to make sure object is available.

Returns
Pointer to allocated space.

◆ Append()

template<class ObjectClass>
FX_INT32 CFX_ObjectArray< ObjectClass >::Append ( const CFX_ObjectArray< ObjectClass > &  src,
FX_INT32  nStart = 0,
FX_INT32  nCount = -1 
)
inline

Append an array.

Parameters
[in]srcThe source array.
[in]nStartThe starting position to be appended in source array. Default value: 0.
[in]nCountThe total count of source elements to be appended. -1 means all elements from nStart position. Default value: -1.
Returns
The number of appended elements from source array.

◆ Copy()

template<class ObjectClass>
FX_INT32 CFX_ObjectArray< ObjectClass >::Copy ( const CFX_ObjectArray< ObjectClass > &  src,
FX_INT32  nStart = 0,
FX_INT32  nCount = -1 
)
inline

Copy from an array.

Parameters
[in]srcThe source array.
[in]nStartThe starting position to be copied in source array. Default value: 0
[in]nCountThe total count of source elements to be copied, -1 means all elements from nStart position. Default value: -1.
Returns
The number of copied elements from source array.

◆ GetDataPtr()

template<class ObjectClass>
ObjectClass* CFX_ObjectArray< ObjectClass >::GetDataPtr ( int  index) const
inline

Get a pointer to the specified element in the array. Direct pointer access.

Parameters
[in]indexSpecifies the zero-based index of element in the array.
Returns
A pointer to the specified element.

◆ GetSize()

template<class ObjectClass>
int CFX_ObjectArray< ObjectClass >::GetSize ( ) const
inline

Get the size of the array.

Returns
The size in objects in the array.

◆ operator=()

template<class ObjectClass>
CFX_ObjectArray& CFX_ObjectArray< ObjectClass >::operator= ( const CFX_ObjectArray< ObjectClass > &  other)
inline

The assignment operator.

Parameters
[in]otherThe other object array.
Returns
A reference to current object itself.

◆ operator[]()

template<class ObjectClass>
ObjectClass& CFX_ObjectArray< ObjectClass >::operator[] ( int  index) const
inline

Subscript([]) operator overload. This function returns a reference to the specified object specified by the zero-based index in nIndex.

Parameters
[in]indexSpecifies the zero-based index in the array.
Returns
A reference to the specified object.

◆ RemoveAll()

template<class ObjectClass>
void CFX_ObjectArray< ObjectClass >::RemoveAll ( )
inline

Remove all objects in the array.

Returns
None.

◆ RemoveAt()

template<class ObjectClass>
void CFX_ObjectArray< ObjectClass >::RemoveAt ( int  index)
inline

Remove an object at specified position.

Parameters
[in]indexSpecifies the zero-based index of object in the array.
Returns
None.

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.