Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
base::win::ScopedSafearray Class Reference

#include <scoped_safearray.h>

Classes

class  LockScope
 

Public Member Functions

 ScopedSafearray (SAFEARRAY *safearray=nullptr)
 
 ScopedSafearray (ScopedSafearray &&r) noexcept
 
ScopedSafearrayoperator= (ScopedSafearray &&rvalue)
 
 ~ScopedSafearray ()
 
template<VARTYPE ElementVartype>
std::optional< LockScope< ElementVartype > > CreateLockScope () const
 
void Destroy ()
 
void Reset (SAFEARRAY *safearray=nullptr)
 
SAFEARRAY * Release ()
 
SAFEARRAY ** Receive ()
 
size_t GetCount (UINT dimension=0) const
 
SAFEARRAY * Get () const
 
bool operator== (const ScopedSafearray &safearray2) const =delete
 
bool operator!= (const ScopedSafearray &safearray2) const =delete
 

Detailed Description

Definition at line 22 of file scoped_safearray.h.

Constructor & Destructor Documentation

◆ ScopedSafearray() [1/2]

base::win::ScopedSafearray::ScopedSafearray ( SAFEARRAY *  safearray = nullptr)
inlineexplicit

Definition at line 119 of file scoped_safearray.h.

120 : safearray_(safearray) {}

◆ ScopedSafearray() [2/2]

base::win::ScopedSafearray::ScopedSafearray ( ScopedSafearray &&  r)
inlinenoexcept

Definition at line 123 of file scoped_safearray.h.

123 : safearray_(r.safearray_) {
124 r.safearray_ = nullptr;
125 }

◆ ~ScopedSafearray()

base::win::ScopedSafearray::~ScopedSafearray ( )
inline

Definition at line 133 of file scoped_safearray.h.

Member Function Documentation

◆ CreateLockScope()

template<VARTYPE ElementVartype>
std::optional< LockScope< ElementVartype > > base::win::ScopedSafearray::CreateLockScope ( ) const
inline

Definition at line 138 of file scoped_safearray.h.

138 {
139 if (!safearray_ || SafeArrayGetDim(safearray_) != 1)
140 return std::nullopt;
141
142 VARTYPE vartype;
143 HRESULT hr = SafeArrayGetVartype(safearray_, &vartype);
144 if (FAILED(hr) ||
146 return std::nullopt;
147 }
148
149 typename LockScope<ElementVartype>::pointer array = nullptr;
150 hr = SafeArrayAccessData(safearray_, reinterpret_cast<void**>(&array));
151 if (FAILED(hr))
152 return std::nullopt;
153
154 const size_t array_size = GetCount();
155 return LockScope<ElementVartype>(safearray_, vartype, array, array_size);
156 }
size_t GetCount(UINT dimension=0) const
static constexpr bool IsConvertibleTo(VARTYPE vartype)
Definition: variant_util.h:124
#define FAILED(hr)

◆ Destroy()

void base::win::ScopedSafearray::Destroy ( )
inline

Definition at line 158 of file scoped_safearray.h.

158 {
159 if (safearray_) {
160 HRESULT hr = SafeArrayDestroy(safearray_);
161 BASE_DCHECK(S_OK == hr);
162 safearray_ = nullptr;
163 }
164 }
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ Get()

SAFEARRAY * base::win::ScopedSafearray::Get ( ) const
inline

Definition at line 209 of file scoped_safearray.h.

209{ return safearray_; }

◆ GetCount()

size_t base::win::ScopedSafearray::GetCount ( UINT  dimension = 0) const
inline

Definition at line 193 of file scoped_safearray.h.

193 {
194 BASE_DCHECK(safearray_);
195 // Initialize |lower| and |upper| so this method will return zero if either
196 // SafeArrayGetLBound or SafeArrayGetUBound returns failure because they
197 // only write to the output parameter when successful.
198 LONG lower = 0;
199 LONG upper = -1;
200 BASE_DCHECK(dimension < SafeArrayGetDim(safearray_));
201 HRESULT hr = SafeArrayGetLBound(safearray_, dimension + 1, &lower);
203 hr = SafeArrayGetUBound(safearray_, dimension + 1, &upper);
205 return (upper - lower + 1);
206 }
#define SUCCEEDED(hr)
long LONG
Definition: windows_types.h:23

◆ operator!=()

bool base::win::ScopedSafearray::operator!= ( const ScopedSafearray safearray2) const
delete

◆ operator=()

ScopedSafearray & base::win::ScopedSafearray::operator= ( ScopedSafearray &&  rvalue)
inline

Definition at line 128 of file scoped_safearray.h.

128 {
129 Reset(rvalue.Release());
130 return *this;
131 }
void Reset(SAFEARRAY *safearray=nullptr)

◆ operator==()

bool base::win::ScopedSafearray::operator== ( const ScopedSafearray safearray2) const
delete

◆ Receive()

SAFEARRAY ** base::win::ScopedSafearray::Receive ( )
inline

Definition at line 187 of file scoped_safearray.h.

187 {
188 Destroy();
189 return &safearray_;
190 }

◆ Release()

SAFEARRAY * base::win::ScopedSafearray::Release ( )
inline

Definition at line 176 of file scoped_safearray.h.

176 {
177 SAFEARRAY* safearray = safearray_;
178 safearray_ = nullptr;
179 return safearray;
180 }

◆ Reset()

void base::win::ScopedSafearray::Reset ( SAFEARRAY *  safearray = nullptr)
inline

Definition at line 168 of file scoped_safearray.h.

168 {
169 if (safearray != safearray_) {
170 Destroy();
171 safearray_ = safearray;
172 }
173 }

The documentation for this class was generated from the following file: