OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_WIN_ENUM_VARIANT_H_ | 5 #ifndef BASE_WIN_ENUM_VARIANT_H_ |
6 #define BASE_WIN_ENUM_VARIANT_H_ | 6 #define BASE_WIN_ENUM_VARIANT_H_ |
7 | 7 |
8 #include <unknwn.h> | 8 #include <unknwn.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/win/iunknown_impl.h" | 11 #include "base/win/iunknown_impl.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 namespace win { | 14 namespace win { |
15 | 15 |
16 // A simple implementation of IEnumVARIANT. | 16 // A simple implementation of IEnumVARIANT. |
17 class BASE_EXPORT EnumVariant | 17 class BASE_EXPORT EnumVariant |
18 : public IEnumVARIANT, | 18 : public IEnumVARIANT, |
19 public IUnknownImpl { | 19 public IUnknownImpl { |
20 public: | 20 public: |
21 // The constructor allocates an array of size |count|. Then use | 21 // The constructor allocates an array of size |count|. Then use |
22 // ItemAt to set the value of each item in the array to initialize it. | 22 // ItemAt to set the value of each item in the array to initialize it. |
23 explicit EnumVariant(unsigned long count); | 23 explicit EnumVariant(unsigned long count); |
24 | 24 |
25 // Returns a mutable pointer to the item at position |index|. | 25 // Returns a mutable pointer to the item at position |index|. |
26 VARIANT* ItemAt(unsigned long index); | 26 VARIANT* ItemAt(unsigned long index); |
27 | 27 |
28 // IUnknown. | 28 // IUnknown. |
29 ULONG STDMETHODCALLTYPE AddRef() OVERRIDE; | 29 ULONG STDMETHODCALLTYPE AddRef() override; |
30 ULONG STDMETHODCALLTYPE Release() OVERRIDE; | 30 ULONG STDMETHODCALLTYPE Release() override; |
31 STDMETHODIMP QueryInterface(REFIID riid, void** ppv) OVERRIDE; | 31 STDMETHODIMP QueryInterface(REFIID riid, void** ppv) override; |
32 | 32 |
33 // IEnumVARIANT. | 33 // IEnumVARIANT. |
34 STDMETHODIMP Next(ULONG requested_count, | 34 STDMETHODIMP Next(ULONG requested_count, |
35 VARIANT* out_elements, | 35 VARIANT* out_elements, |
36 ULONG* out_elements_received); | 36 ULONG* out_elements_received); |
37 STDMETHODIMP Skip(ULONG skip_count); | 37 STDMETHODIMP Skip(ULONG skip_count); |
38 STDMETHODIMP Reset(); | 38 STDMETHODIMP Reset(); |
39 STDMETHODIMP Clone(IEnumVARIANT** out_cloned_object); | 39 STDMETHODIMP Clone(IEnumVARIANT** out_cloned_object); |
40 | 40 |
41 private: | 41 private: |
42 ~EnumVariant(); | 42 ~EnumVariant(); |
43 | 43 |
44 scoped_ptr<VARIANT[]> items_; | 44 scoped_ptr<VARIANT[]> items_; |
45 unsigned long count_; | 45 unsigned long count_; |
46 unsigned long current_index_; | 46 unsigned long current_index_; |
47 }; | 47 }; |
48 | 48 |
49 } // namespace win | 49 } // namespace win |
50 } // namespace base | 50 } // namespace base |
51 | 51 |
52 #endif // BASE_WIN_ENUM_VARIANT_H_ | 52 #endif // BASE_WIN_ENUM_VARIANT_H_ |
OLD | NEW |