Template for allocating/deallocating memory for structs. More...
#include <record.h>
Public Member Functions | |
| T * | getData () |
| Get the pointer to the struct. | |
| const T * | getData () const |
| Get the pointer to the struct. | |
| operator const T * () const | |
| Cast to the pointer of the struct. | |
| operator const uint8_t * () const | |
| Cast operator. | |
| operator T * () | |
| Cast to the pointer of the struct. | |
| operator uint8_t * () | |
| Cast operator. | |
| const Record< T > & | operator= (const T &r) throw (YAPETException) |
| Assignment operator. | |
| const Record< T > & | operator= (const BDBuffer &bdb) throw (YAPETException) |
| Assignment operator. | |
| const Record< T > & | operator= (const Record< T > &r) throw (YAPETException) |
| Assignment operator. | |
| const Record< T > & | operator= (const T *r) throw (YAPETException) |
| Assignment operator. | |
| Record (const T &d) throw (YAPETException) | |
| Allocates memory. | |
| Record (const Record< T > &r) throw (YAPETException) | |
| Record () throw (YAPETException) | |
| uint32_t | size () const |
| virtual | ~Record () |
Private Member Functions | |
| void | alloc_mem () throw (YAPETException) |
| Allocate memory for the struct. | |
| void | free_mem () |
| Zero out and free memory. | |
Private Attributes | |
| uint32_t | _size |
| The size of the memory allocated. | |
| T * | data |
| Pointer to the struct. | |
The primary intend of this template is to make sure the memory allocated for a struct is zero'ed out upon deallocation.
The template allocates enough memory on the heap for holding the struct of type T.
It allows direct manipulation of the struct on the heap.
Definition at line 71 of file record.h.
| YAPET::Record< T >::Record | ( | const T & | d | ) | throw (YAPETException) [inline] |
Allocates memory of the proper size and copies the content of the given struct d.
| d | reference to the struct from where the content is copied to the allocated memory. |
| YAPET::Record< T >::Record | ( | ) | throw (YAPETException) [inline] |
Allocates memory to hold a struct of the type T.
| YAPET::Record< T >::Record | ( | const Record< T > & | r | ) | throw (YAPETException) [inline] |
| virtual YAPET::Record< T >::~Record | ( | ) | [inline, virtual] |
| void YAPET::Record< T >::alloc_mem | ( | ) | throw (YAPETException) [inline, private] |
Allocates the proper amount of memory for holding the struct and sets the _size field.
Definition at line 93 of file record.h.
References YAPET::Record< T >::_size, and YAPET::Record< T >::data.
Referenced by YAPET::Record< T >::operator=().

| void YAPET::Record< T >::free_mem | ( | ) | [inline, private] |
Zero'es the memory out and frees it.
Definition at line 107 of file record.h.
References YAPET::Record< T >::_size, and YAPET::Record< T >::data.
Referenced by YAPET::Record< T >::operator=().

| T* YAPET::Record< T >::getData | ( | ) | [inline] |
Gets the pointer to the struct on the heap.
Definition at line 162 of file record.h.
References YAPET::Record< T >::data.
| const T* YAPET::Record< T >::getData | ( | ) | const [inline] |
Gets the pointer to the struct on the heap.
Definition at line 172 of file record.h.
References YAPET::Record< T >::data.
| YAPET::Record< T >::operator const T * | ( | ) | const [inline] |
Cast to the pointer of the struct on the heap.
Definition at line 193 of file record.h.
References YAPET::Record< T >::data.
| YAPET::Record< T >::operator const uint8_t * | ( | ) | const [inline] |
Cast operator used by the openssl functions.
Definition at line 215 of file record.h.
References YAPET::Record< T >::data.
| YAPET::Record< T >::operator T * | ( | ) | [inline] |
Cast to the pointer of the struct on the heap.
Definition at line 183 of file record.h.
References YAPET::Record< T >::data.
| YAPET::Record< T >::operator uint8_t * | ( | ) | [inline] |
Cast operator used by the openssl functions.
Definition at line 204 of file record.h.
References YAPET::Record< T >::data.
| const Record<T>& YAPET::Record< T >::operator= | ( | const T * | r | ) | throw (YAPETException) [inline] |
Assigns a struct of type T to this.
| r | pointer to a struct of type T. |
this. Definition at line 265 of file record.h.
References YAPET::Record< T >::_size, YAPET::Record< T >::alloc_mem(), YAPET::Record< T >::data, and YAPET::Record< T >::free_mem().

| const Record<T>& YAPET::Record< T >::operator= | ( | const Record< T > & | r | ) | throw (YAPETException) [inline] |
Assigns another Record to this.
| r | reference to a Record. |
this. Definition at line 228 of file record.h.
References YAPET::Record< T >::alloc_mem(), YAPET::Record< T >::data, and YAPET::Record< T >::free_mem().

| const Record<T>& YAPET::Record< T >::operator= | ( | const BDBuffer & | bdb | ) | throw (YAPETException) [inline] |
Assigns a BDBuffer. If the size of the BDBuffer is smaller than the size of the struct, an exception is thrown.
Only as much bytes as fit into struct are copied from the BDBuffer.
| bdb | reference to a BDBuffer. |
this. Definition at line 286 of file record.h.
References YAPET::Record< T >::_size, YAPET::Record< T >::alloc_mem(), YAPET::Record< T >::data, and YAPET::Record< T >::free_mem().

| const Record<T>& YAPET::Record< T >::operator= | ( | const T & | r | ) | throw (YAPETException) [inline] |
Assigns a struct of type T to this.
| r | reference to a struct of type T. |
this. Definition at line 248 of file record.h.
References YAPET::Record< T >::_size, YAPET::Record< T >::alloc_mem(), YAPET::Record< T >::data, and YAPET::Record< T >::free_mem().

| uint32_t YAPET::Record< T >::size | ( | ) | const [inline] |
Get the size of the allocated memory.
Definition at line 151 of file record.h.
References YAPET::Record< T >::_size.
uint32_t YAPET::Record< T >::_size [private] |
The size of the memory allocated. Used to zero out the memory used by the struct.
Definition at line 79 of file record.h.
Referenced by YAPET::Record< T >::alloc_mem(), YAPET::Record< T >::free_mem(), YAPET::Record< T >::operator=(), and YAPET::Record< T >::size().
T* YAPET::Record< T >::data [private] |
Pointer to the struct on the heap.
Definition at line 85 of file record.h.
Referenced by YAPET::Record< T >::alloc_mem(), YAPET::Record< T >::free_mem(), YAPET::Record< T >::getData(), YAPET::Record< T >::operator const T *(), YAPET::Record< T >::operator const uint8_t *(), YAPET::Record< T >::operator T *(), YAPET::Record< T >::operator uint8_t *(), and YAPET::Record< T >::operator=().
1.7.1