Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00032 #ifndef REGISTER_SET_HELPER_H
00033 #define REGISTER_SET_HELPER_H
00034
00035 namespace GENAPI_NAMESPACE
00036 {
00041 class GENAPI_DECL CRegisterSetHelper
00042 {
00043 public:
00045 static size_t CopyData( void *pvDestination, size_t nbyDestSize, const void *pvSource, size_t nbySourceSize )
00046 {
00047 if (nbyDestSize != nbySourceSize)
00048 {
00049 throw OUT_OF_RANGE_EXCEPTION("CopyData : Destination size (%ld) does not fit source size (%d)", nbyDestSize, nbySourceSize);
00050 }
00051
00052 #if defined(_WINDOWS_)
00053 if ( IsBadWritePtr(pvDestination, nbyDestSize) || IsBadReadPtr(pvSource, nbySourceSize) )
00054 {
00055 throw RUNTIME_EXCEPTION("Invalid user buffer");
00056 }
00057 #endif
00058
00059 memcpy( pvDestination, pvSource, nbySourceSize );
00060 return nbySourceSize;
00061 }
00062
00066 template<typename T>
00067 static size_t CopyToBuffer( void *pvDestination, size_t nbyDestSize, T *d )
00068 {
00069 return CopyData( pvDestination, nbyDestSize, d, sizeof( *d ) );
00070 }
00071
00075 template<typename T>
00076 static size_t CopyFromBuffer( T *d, const void *pvDestination, size_t nbyDestSize)
00077 {
00078 return CopyData( d, sizeof( *d ), pvDestination, nbyDestSize);
00079 }
00080 };
00081
00082 }
00083
00084 #endif // ifndef REGISTER_SET_HELPER_H