]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/ole/safearray.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/ole/safearray.cpp
3 // Purpose: Implementation of wxSafeArrayBase class.
7 // Copyright: (c) 2012 wxWidgets development team
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #if wxUSE_OLE && wxUSE_VARIANT
29 #include "wx/variant.h"
32 #include "wx/msw/ole/safearray.h"
34 // ============================================================================
36 // ============================================================================
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 void wxSafeArrayBase::Destroy()
47 HRESULT hr
= SafeArrayDestroy(m_array
);
50 wxLogApiError(wxS("SafeArrayDestroy()"), hr
);
56 SAFEARRAY
* wxSafeArrayBase::Detach()
58 wxCHECK_MSG( m_array
, NULL
, wxS("Uninitialized safe array") );
61 SAFEARRAY
* array
= m_array
;
66 size_t wxSafeArrayBase::GetDim() const
70 return SafeArrayGetDim(m_array
);
73 bool wxSafeArrayBase::GetLBound(size_t dim
, long& bound
) const
75 wxCHECK_MSG( m_array
, false, wxS("Uninitialized safe array") );
76 wxCHECK_MSG( dim
> 0, false, wxS("Invalid dimension index") );
78 HRESULT hr
= SafeArrayGetLBound(m_array
, dim
, &bound
);
81 wxLogApiError(wxS("SafeArrayGetLBound()"), hr
);
87 bool wxSafeArrayBase::GetUBound(size_t dim
, long& bound
) const
89 wxCHECK_MSG( m_array
, false, wxS("Uninitialized safe array") );
90 wxCHECK_MSG( dim
> 0, false, wxS("Invalid dimension index") );
92 HRESULT hr
= SafeArrayGetUBound(m_array
, dim
, &bound
);
95 wxLogApiError(wxS("SafeArrayGetUBound()"), hr
);
101 size_t wxSafeArrayBase::GetCount(size_t dim
) const
105 if ( GetLBound(dim
, lBound
) && GetUBound(dim
, uBound
) )
106 return uBound
- lBound
+ 1;
110 bool wxSafeArrayBase::Lock()
112 wxCHECK_MSG( m_array
, false, wxS("Uninitialized safe array") );
114 HRESULT hr
= SafeArrayLock(m_array
);
117 wxLogApiError(wxS("SafeArrayLock()"), hr
);
123 bool wxSafeArrayBase::Unlock()
125 wxCHECK_MSG( m_array
, false, wxS("Uninitialized safe array") );
127 HRESULT hr
= SafeArrayUnlock(m_array
);
130 wxLogApiError(wxS("SafeArrayUnlock()"), hr
);
136 #endif // wxUSE_OLE && wxUSE_VARIANT