]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/ole/safearray.cpp
db62ad2fd9099224b19920742cf04b80571c22af
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/ole/safearray.cpp
3 // Purpose: Implementation of wxSafeArrayBase class.
6 // Copyright: (c) 2012 wxWidgets development team
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
25 #if wxUSE_OLE && wxUSE_VARIANT
28 #include "wx/variant.h"
31 #include "wx/msw/ole/safearray.h"
33 // ============================================================================
35 // ============================================================================
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 void wxSafeArrayBase::Destroy()
46 HRESULT hr
= SafeArrayDestroy(m_array
);
49 wxLogApiError(wxS("SafeArrayDestroy()"), hr
);
55 SAFEARRAY
* wxSafeArrayBase::Detach()
57 wxCHECK_MSG( m_array
, NULL
, wxS("Uninitialized safe array") );
60 SAFEARRAY
* array
= m_array
;
65 size_t wxSafeArrayBase::GetDim() const
69 return SafeArrayGetDim(m_array
);
72 bool wxSafeArrayBase::GetLBound(size_t dim
, long& bound
) const
74 wxCHECK_MSG( m_array
, false, wxS("Uninitialized safe array") );
75 wxCHECK_MSG( dim
> 0, false, wxS("Invalid dimension index") );
77 HRESULT hr
= SafeArrayGetLBound(m_array
, dim
, &bound
);
80 wxLogApiError(wxS("SafeArrayGetLBound()"), hr
);
86 bool wxSafeArrayBase::GetUBound(size_t dim
, long& bound
) const
88 wxCHECK_MSG( m_array
, false, wxS("Uninitialized safe array") );
89 wxCHECK_MSG( dim
> 0, false, wxS("Invalid dimension index") );
91 HRESULT hr
= SafeArrayGetUBound(m_array
, dim
, &bound
);
94 wxLogApiError(wxS("SafeArrayGetUBound()"), hr
);
100 size_t wxSafeArrayBase::GetCount(size_t dim
) const
104 if ( GetLBound(dim
, lBound
) && GetUBound(dim
, uBound
) )
105 return uBound
- lBound
+ 1;
109 bool wxSafeArrayBase::Lock()
111 wxCHECK_MSG( m_array
, false, wxS("Uninitialized safe array") );
113 HRESULT hr
= SafeArrayLock(m_array
);
116 wxLogApiError(wxS("SafeArrayLock()"), hr
);
122 bool wxSafeArrayBase::Unlock()
124 wxCHECK_MSG( m_array
, false, wxS("Uninitialized safe array") );
126 HRESULT hr
= SafeArrayUnlock(m_array
);
129 wxLogApiError(wxS("SafeArrayUnlock()"), hr
);
135 #endif // wxUSE_OLE && wxUSE_VARIANT