32 #ifndef REGISTER_SET_HELPER_H 33 #define REGISTER_SET_HELPER_H 45 static size_t CopyData(
void *pvDestination,
size_t nbyDestSize,
const void *pvSource,
size_t nbySourceSize )
47 if (nbyDestSize != nbySourceSize)
49 throw OUT_OF_RANGE_EXCEPTION(
"CopyData : Destination size (%ld) does not fit source size (%d)", nbyDestSize, nbySourceSize);
52 #if defined(_WINDOWS_) 53 if ( IsBadWritePtr(pvDestination, nbyDestSize) || IsBadReadPtr(pvSource, nbySourceSize) )
59 memcpy( pvDestination, pvSource, nbySourceSize );
67 static size_t CopyToBuffer(
void *pvDestination,
size_t nbyDestSize, T *d )
69 return CopyData( pvDestination, nbyDestSize, d,
sizeof( *d ) );
76 static size_t CopyFromBuffer( T *d,
const void *pvDestination,
size_t nbyDestSize)
78 return CopyData( d,
sizeof( *d ), pvDestination, nbyDestSize);
84 #endif // ifndef REGISTER_SET_HELPER_H static size_t CopyData(void *pvDestination, size_t nbyDestSize, const void *pvSource, size_t nbySourceSize)
memcpy firing exceptions
static size_t CopyToBuffer(void *pvDestination, size_t nbyDestSize, T *d)
Typesafe copy from variable to buffer.
Copies data from buffer to variables in a typesafe manner.
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
static size_t CopyFromBuffer(T *d, const void *pvDestination, size_t nbyDestSize)
Typesafe copy from buffer to variable.
#define OUT_OF_RANGE_EXCEPTION
Fires an out of range exception, e.g. throw OUT_OF_RANGE_EXCEPTION("%ld too large", Value);.
Part of the generic device API.