OpendTect-6_4  6.4
varlenarray.h
Go to the documentation of this file.
1 #ifndef varlenarray_h
2 #define varlenarray_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: September 2007
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "ptrman.h"
16 
17 #ifdef __msvc__
18 # define __varlenwithptr__
19 #endif
20 
21 #ifdef __mac__
22 # define __varlenwithptr__
23 #endif
24 
25 #ifdef __lux__
26 # ifdef __debug__
27 # define __varlenwithptr__
28 # endif
29 #endif
30 
31 #define mAllocLargeVarLenArr( type, varnm, __size ) \
32 ArrPtrMan<type> varnm; \
33 { \
34  const std::size_t __allocsize = __size; \
35  if ( __allocsize ) \
36  { \
37  mTryAllocPtrMan( varnm, type [__allocsize] ); \
38  } \
39  varnm.setSize( __allocsize ); \
40 }
41 
42 
43 
44 #ifdef __varlenwithptr__
45 
46 # define mAllocVarLenArr( type, varnm, __size ) \
47  mAllocLargeVarLenArr( type, varnm, __size )
48 
49 # define mVarLenArr(varnm) varnm.ptr()
50 # define mIsVarLenArrOK(varnm) ((bool)varnm.ptr())
51 
52 #else
53 
54 # define mAllocVarLenArr( type, varnm, __size ) \
55  type varnm[__size];
56 # define mVarLenArr(varnm) varnm
57 # define mIsVarLenArrOK(varnm) (true)
58 
59 #endif
60 
61 
62 #define mAllocVarLenIdxArr(tp,var,sz) \
63  mAllocVarLenArr(tp,var,sz) \
64  if ( mIsVarLenArrOK(var) ) \
65  for ( tp idx=sz-1; idx>=0; idx-- ) \
66  var[idx] = idx;
67 
68 
69 #undef __varlenwithptr__
70 
71 #endif

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019