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

#include <enum_variant.h>

Inheritance diagram for base::win::EnumVariant:

Public Member Functions

 EnumVariant (ULONG count)
 
IFACEMETHODIMP Next (ULONG requested_count, VARIANT *out_elements, ULONG *out_elements_received) override
 
IFACEMETHODIMP Skip (ULONG skip_count) override
 
IFACEMETHODIMP Reset () override
 
IFACEMETHODIMP Clone (IEnumVARIANT **out_cloned_object) override
 
VARIANT * ItemAt (ULONG index)
 

Detailed Description

Definition at line 19 of file enum_variant.h.

Constructor & Destructor Documentation

◆ EnumVariant()

base::win::EnumVariant::EnumVariant ( ULONG  count)
explicit

Definition at line 16 of file enum_variant.cc.

16 : current_index_(0) {
17 for (ULONG i = 0; i < count; ++i)
18 items_.emplace_back(ScopedVariant::kEmptyVariant);
19}
int count
Definition: FontMgrTest.cpp:50
static const VARIANT kEmptyVariant
DWORD ULONG
Definition: windows_types.h:40

Member Function Documentation

◆ Clone()

HRESULT base::win::EnumVariant::Clone ( IEnumVARIANT **  out_cloned_object)
override

Definition at line 66 of file enum_variant.cc.

66 {
67 if (!out_cloned_object)
68 return E_INVALIDARG;
69
70 size_t count = items_.size();
71 Microsoft::WRL::ComPtr<EnumVariant> other =
72 Microsoft::WRL::Make<EnumVariant>(static_cast<ULONG>(count));
73 for (size_t i = 0; i < count; ++i)
74 other->items_[i] = static_cast<const VARIANT&>(items_[i]);
75
76 other->Skip(current_index_);
77 return other.CopyTo(IID_PPV_ARGS(out_cloned_object));
78}

◆ ItemAt()

VARIANT * base::win::EnumVariant::ItemAt ( ULONG  index)

Definition at line 23 of file enum_variant.cc.

23 {
24 BASE_DCHECK(index < items_.size());
25 // This is a hack to return a mutable pointer to the ScopedVariant, even
26 // though the original intent of the AsInput method was to allow only readonly
27 // access to the wrapped variant.
28 return items_[index].AsInput();
29}
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ Next()

HRESULT base::win::EnumVariant::Next ( ULONG  requested_count,
VARIANT *  out_elements,
ULONG out_elements_received 
)
override

Definition at line 31 of file enum_variant.cc.

33 {
34 if (!out_elements)
35 return E_INVALIDARG;
36
37 BASE_DCHECK(current_index_ <= items_.size());
38 ULONG available_count = static_cast<ULONG>(items_.size()) - current_index_;
39 ULONG count = std::min(requested_count, available_count);
40 for (ULONG i = 0; i < count; ++i)
41 out_elements[i] = items_[current_index_ + i].Copy();
42 current_index_ += count;
43
44 // The caller can choose not to get the number of received elements by setting
45 // |out_elements_received| to nullptr.
46 if (out_elements_received)
47 *out_elements_received = count;
48
49 return (count == requested_count ? S_OK : S_FALSE);
50}
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ Reset()

HRESULT base::win::EnumVariant::Reset ( )
override

Definition at line 61 of file enum_variant.cc.

61 {
62 current_index_ = 0;
63 return S_OK;
64}

◆ Skip()

HRESULT base::win::EnumVariant::Skip ( ULONG  skip_count)
override

Definition at line 52 of file enum_variant.cc.

52 {
53 ULONG count = skip_count;
54 if (current_index_ + count > static_cast<ULONG>(items_.size()))
55 count = static_cast<ULONG>(items_.size()) - current_index_;
56
57 current_index_ += count;
58 return (count == skip_count ? S_OK : S_FALSE);
59}

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