30#ifndef REGISTER_SET_HELPER_H
31#define REGISTER_SET_HELPER_H
33namespace GENAPI_NAMESPACE
43 static size_t CopyData(
void *pvDestination,
size_t nbyDestSize,
const void *pvSource,
size_t nbySourceSize )
45 if (nbyDestSize != nbySourceSize)
47 throw OUT_OF_RANGE_EXCEPTION(
"CopyData : Destination size (%ld) does not fit source size (%d)", nbyDestSize, nbySourceSize);
51 if ( IsBadWritePtr(pvDestination, nbyDestSize) || IsBadReadPtr(pvSource, nbySourceSize) )
57 memcpy( pvDestination, pvSource, nbySourceSize );
65 static size_t CopyToBuffer(
void *pvDestination,
size_t nbyDestSize, T *d )
67 return CopyData( pvDestination, nbyDestSize, d,
sizeof( *d ) );
74 static size_t CopyFromBuffer( T *d,
const void *pvDestination,
size_t nbyDestSize)
76 return CopyData( d,
sizeof( *d ), pvDestination, nbyDestSize);
Copies data from buffer to variables in a typesafe manner.
Definition RegisterSetHelper.h:40
static size_t CopyToBuffer(void *pvDestination, size_t nbyDestSize, T *d)
Typesafe copy from variable to buffer.
Definition RegisterSetHelper.h:65
static size_t CopyFromBuffer(T *d, const void *pvDestination, size_t nbyDestSize)
Typesafe copy from buffer to variable.
Definition RegisterSetHelper.h:74
static size_t CopyData(void *pvDestination, size_t nbyDestSize, const void *pvSource, size_t nbySourceSize)
memcpy firing exceptions
Definition RegisterSetHelper.h:43
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
Definition GCException.h:246
#define OUT_OF_RANGE_EXCEPTION
Fires an out of range exception, e.g. throw OUT_OF_RANGE_EXCEPTION("%ld too large",...
Definition GCException.h:240