All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HSEP::Array< T > Class Template Reference

Template Array class that complements the base functionality found in an STL vector. More...

#include <Array.h>

+ Inheritance diagram for HSEP::Array< T >:
+ Collaboration diagram for HSEP::Array< T >:

Public Types

typedef function< void(T
*pValuePtr)> 
ForEachWorker
 Function type prototype to be used to create C style or lambda style functions for the forEach method.
 

Public Member Functions

 Array ()
 
 Array (Array &pReference)
 
virtual ~Array ()
 
void operator() (Array &pReference)
 
T * ptr (size_t pPos)
 Returns a pointer to the actually stored element locate at pPos position.
 
void push (T &pValueRef)
 Creetes a copy of the value passed by reference and stores it at the end of the array.
 
void push (T *pValuePtr)
 Stores the given pointer (not a copy or a copy of the pointed element) at the end of the array.
 
T * pop ()
 Retrieves the last element stored in the Array, deleting it from the Array.
 
void clear ()
 Disposes all contained elements running their delete method and clear the internal container.
 
bool forEach (ForEachWorker pWorker)
 Executes the given pWorker function on every contained element.
 
size_t size ()
 Returns the container size.
 
- Public Member Functions inherited from HSEP::HSEPObject
string & lastErrorRef ()
 Returns a reference to the last stored error message.
 
ErrorCode lastCode ()
 Returns the last stored code.
 
bool valid ()
 Permits to know if the object has a valid internal state.
 
string & typeRef ()
 Permits to know the type of this particular object.
 

Additional Inherited Members

- Protected Member Functions inherited from HSEP::HSEPObject
 HSEPObject (const char *pType)
 Constructor, providing the base for the state controlling instance.
 
virtual ~HSEPObject ()
 
void setLastError (string &pErrorMsgRef)
 Assigns an error message text to the last executed operation.
 
void setLastError (const string &pErrorMsgRef)
 Assigns an error message text to the last executed operation.
 
void setLastError (const char *pErrorMsg)
 Assigns an error message text to the last executed operation.
 
void setValid ()
 Defines that the object has a valid state.
 
void setInvalid ()
 Defines that the object has an invalid state.
 
void setLastCode (const ErrorCode pErrorCode)
 Defines the internal result code for the object.
 

Detailed Description

template<class T>
class HSEP::Array< T >

Template Array class that complements the base functionality found in an STL vector.

It is important to note that this container stores pointers to the contained elements, to avoid the traditional STL behavior of storing references. The STL's vector behavior, although looks harmless, can produce very dangerous programs when the given elements are created as local variables in the given function stack. As an interesting point, this problem can't be detected by the compiler.

Definition at line 46 of file Array.h.

Member Typedef Documentation

template<class T>
typedef function<void (T* pValuePtr)> HSEP::Array< T >::ForEachWorker

Function type prototype to be used to create C style or lambda style functions for the forEach method.

Definition at line 54 of file Array.h.

Constructor & Destructor Documentation

template<class T>
HSEP::Array< T >::Array ( )
inline

Definition at line 56 of file Array.h.

template<class T>
HSEP::Array< T >::Array ( Array< T > &  pReference)
inline

Definition at line 60 of file Array.h.

template<class T>
virtual HSEP::Array< T >::~Array ( )
inlinevirtual

Definition at line 67 of file Array.h.

Member Function Documentation

template<class T>
void HSEP::Array< T >::clear ( )
inline

Disposes all contained elements running their delete method and clear the internal container.

Definition at line 126 of file Array.h.

Referenced by HSEPData::DBResultSet::destroyMetadata(), HSEP::FileTool::retrieve(), and HSEP::StringTool::split().

+ Here is the caller graph for this function:

template<class T>
bool HSEP::Array< T >::forEach ( ForEachWorker  pWorker)
inline

Executes the given pWorker function on every contained element.

Parameters
pWorkerThe given function

It is possible to assign a regular C style function pointer or a lambda style function.

Definition at line 143 of file Array.h.

Referenced by HSEP::Array< SQLResultRow >::Array(), HSEPData::DBResultSet::destroyMetadata(), HSEPData::QueryUniqueCycle::execute(), HSEPDataSqLite::feedData(), HSEPDataSqLite::SqLiteResultSet::forEach(), HSEP::BaseDriverSet::load(), HSEPData::DB::loadDrivers(), HSEPData::DB::loadInstances(), HSEP::Array< SQLResultRow >::operator()(), and HSEP::FileTool::store().

+ Here is the caller graph for this function:

template<class T>
void HSEP::Array< T >::operator() ( Array< T > &  pReference)
inline

Definition at line 72 of file Array.h.

template<class T>
T* HSEP::Array< T >::pop ( )
inline

Retrieves the last element stored in the Array, deleting it from the Array.

Returns

Definition at line 117 of file Array.h.

template<class T>
T* HSEP::Array< T >::ptr ( size_t  pPos)
inline

Returns a pointer to the actually stored element locate at pPos position.

Parameters
pPos
Returns
the pointer to the stored element
nullptr in case no stored element can be found or the pPos is out of bounds (higher or lower than limits).

Definition at line 86 of file Array.h.

Referenced by HSEPDataSqLite::SQLResultData::current(), and HSEPDataSqLite::SQLResultData::getString().

+ Here is the caller graph for this function:

template<class T>
void HSEP::Array< T >::push ( T &  pValueRef)
inline

Creetes a copy of the value passed by reference and stores it at the end of the array.

Parameters
pValueRef

Definition at line 98 of file Array.h.

Referenced by HSEPDataSqLite::feedData(), HSEPDataSqLite::feedMetadata(), HSEP::fillArray(), HSEP::DriverSet< Type >::info(), HSEP::FileTool::retrieve(), HSEP::StringTool::split(), and HSEP::DirTool::traverse().

+ Here is the caller graph for this function:

template<class T>
void HSEP::Array< T >::push ( T *  pValuePtr)
inline

Stores the given pointer (not a copy or a copy of the pointed element) at the end of the array.

Parameters
pValuePtr

Definition at line 109 of file Array.h.

template<class T>
size_t HSEP::Array< T >::size ( )
inline

Returns the container size.

Returns

Definition at line 171 of file Array.h.


The documentation for this class was generated from the following file: