]> git.saurik.com Git - wxWidgets.git/blame - src/msw/ole/safearray.cpp
No real changes, just use wxString::clear() instead of assignment.
[wxWidgets.git] / src / msw / ole / safearray.cpp
CommitLineData
226fa6db
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/ole/safearray.cpp
3// Purpose: Implementation of wxSafeArrayBase class.
4// Author: PB
5// Created: 2012-09-23
6// RCS-ID: $Id$
7// Copyright: (c) 2012 wxWidgets development team
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// for compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
0555b2a0
VZ
26#if wxUSE_OLE && wxUSE_VARIANT
27
226fa6db
VZ
28#ifndef WX_PRECOMP
29 #include "wx/variant.h"
30#endif // WX_PRECOMP
31
32#include "wx/msw/ole/safearray.h"
33
34// ============================================================================
35// implementation
36// ============================================================================
37
38// ----------------------------------------------------------------------------
39// wxSafeArrayBase
40// ----------------------------------------------------------------------------
41
42void wxSafeArrayBase::Destroy()
43{
44 if ( m_array )
45 {
46 Unlock();
47 HRESULT hr = SafeArrayDestroy(m_array);
48 if ( FAILED(hr) )
49 {
50 wxLogApiError(wxS("SafeArrayDestroy()"), hr);
51 }
52 m_array = NULL;
53 }
54}
55
56SAFEARRAY* wxSafeArrayBase::Detach()
57{
58 wxCHECK_MSG( m_array, NULL, wxS("Uninitialized safe array") );
59
60 Unlock();
61 SAFEARRAY* array = m_array;
62 m_array = NULL;
63 return array;
64}
65
66size_t wxSafeArrayBase::GetDim() const
67{
68 wxASSERT( m_array );
69
70 return SafeArrayGetDim(m_array);
71}
72
73bool wxSafeArrayBase::GetLBound(size_t dim, long& bound) const
74{
75 wxCHECK_MSG( m_array, false, wxS("Uninitialized safe array") );
76 wxCHECK_MSG( dim > 0, false, wxS("Invalid dimension index") );
77
78 HRESULT hr = SafeArrayGetLBound(m_array, dim, &bound);
79 if ( FAILED(hr) )
80 {
81 wxLogApiError(wxS("SafeArrayGetLBound()"), hr);
82 return false;
83 }
84 return true;
85}
86
87bool wxSafeArrayBase::GetUBound(size_t dim, long& bound) const
88{
89 wxCHECK_MSG( m_array, false, wxS("Uninitialized safe array") );
90 wxCHECK_MSG( dim > 0, false, wxS("Invalid dimension index") );
91
92 HRESULT hr = SafeArrayGetUBound(m_array, dim, &bound);
93 if ( FAILED(hr) )
94 {
95 wxLogApiError(wxS("SafeArrayGetUBound()"), hr);
96 return false;
97 }
98 return true;
99}
100
101size_t wxSafeArrayBase::GetCount(size_t dim) const
102{
103 long lBound, uBound;
104
105 if ( GetLBound(dim, lBound) && GetUBound(dim, uBound) )
106 return uBound - lBound + 1;
107 return 0;
108}
109
110bool wxSafeArrayBase::Lock()
111{
112 wxCHECK_MSG( m_array, false, wxS("Uninitialized safe array") );
113
114 HRESULT hr = SafeArrayLock(m_array);
115 if ( FAILED(hr) )
116 {
117 wxLogApiError(wxS("SafeArrayLock()"), hr);
118 return false;
119 }
120 return true;
121}
122
123bool wxSafeArrayBase::Unlock()
124{
125 wxCHECK_MSG( m_array, false, wxS("Uninitialized safe array") );
126
127 HRESULT hr = SafeArrayUnlock(m_array);
128 if ( FAILED(hr) )
129 {
130 wxLogApiError(wxS("SafeArrayUnlock()"), hr);
131 return false;
132 }
133 return true;
134}
135
0555b2a0 136#endif // wxUSE_OLE && wxUSE_VARIANT