RegisterSetHelper.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2006 by Basler Vision Technologies
3 // Section: Vision Components
4 // Project: GenApi
5 // Author: Alexander Happe / Fritz Dierks
6 // $Header$
7 //
8 // License: This file is published under the license of the EMVA GenICam Standard Group.
9 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
10 // If for some reason you are missing this file please contact the EMVA or visit the website
11 // (http://www.genicam.org) for a full copy.
12 //
13 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
14 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
17 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 // POSSIBILITY OF SUCH DAMAGE.
24 //-----------------------------------------------------------------------------
32 #ifndef REGISTER_SET_HELPER_H
33 #define REGISTER_SET_HELPER_H
34 
35 namespace GENAPI_NAMESPACE
36 {
42  {
43  public:
45  static size_t CopyData( void *pvDestination, size_t nbyDestSize, const void *pvSource, size_t nbySourceSize )
46  {
47  if (nbyDestSize != nbySourceSize)
48  {
49  throw OUT_OF_RANGE_EXCEPTION("CopyData : Destination size (%ld) does not fit source size (%d)", nbyDestSize, nbySourceSize);
50  }
51 
52 #if defined(_WINDOWS_)
53  if ( IsBadWritePtr(pvDestination, nbyDestSize) || IsBadReadPtr(pvSource, nbySourceSize) )
54  {
55  throw RUNTIME_EXCEPTION("Invalid user buffer");
56  }
57 #endif
58 
59  memcpy( pvDestination, pvSource, nbySourceSize );
60  return nbySourceSize;
61  }
62 
66  template<typename T>
67  static size_t CopyToBuffer( void *pvDestination, size_t nbyDestSize, T *d )
68  {
69  return CopyData( pvDestination, nbyDestSize, d, sizeof( *d ) );
70  }
71 
75  template<typename T>
76  static size_t CopyFromBuffer( T *d, const void *pvDestination, size_t nbyDestSize)
77  {
78  return CopyData( d, sizeof( *d ), pvDestination, nbyDestSize);
79  }
80  };
81 
82 } // namespace GenApi
83 
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 GENAPI_DECL
Definition: GenApiDll.h:55
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
Definition: GCException.h:247
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);.
Definition: GCException.h:241
Lexical analyzer for CIntSwissKnife.
Definition: Autovector.h:48


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Mar 17 2021 02:48:41