Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cOleSafeArray.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cOleSafeArray_H
6 #define _INC_cOleSafeArray_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 #include "../WinAPI/cWinVariant.h"
11 
12 #if defined(_MFC_VER)
13 #include <afxdisp.h> // cOleSafeArray
14 
15 #elif defined(_WIN32) && defined(_MSC_VER)
16 
17 namespace GrayLib
18 {
19  class GRAYLIB_LINK cOleSafeArray : public tagVARIANT
20  {
24 
25  public:
26  cOleSafeArray() noexcept
27  {
28  this->vt = VT_EMPTY;
29  this->parray = nullptr;
30  }
31  ~cOleSafeArray() noexcept
32  {
33  ::SafeArrayDestroy(this->parray);
34  }
35 
36  void CreateOneDim(VARTYPE vtSrc, DWORD dwElements) noexcept
37  {
38  // normal 1 dimensional array
39  SAFEARRAYBOUND ArrayBound;
40  ArrayBound.cElements = dwElements;
41  ArrayBound.lLbound = 0;
42  this->parray = ::SafeArrayCreate(vtSrc, 1, &ArrayBound);
43  }
44 
45  void AccessData(void** ppVar) noexcept
46  {
47  // Pointer to the vector of vars.
48  ::SafeArrayAccessData(this->parray, ppVar);
49  }
50 
51  SAFEARRAY* get_SafeArray() const noexcept
52  {
53  return this->parray;
54  }
55  };
56 }
57 
58 #endif
59 #endif
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
Definition: cMesh.h:22