1 // Copyright 2011 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_WIN_ENUM_VARIANT_H_ 6 #define BASE_WIN_ENUM_VARIANT_H_ 7 8 #include <wrl/implements.h> 9 10 #include <memory> 11 #include <vector> 12 13 #include "base/win/scoped_variant.h" 14 15 namespace base { 16 namespace win { 17 18 // A simple implementation of IEnumVARIANT. 19 class BASE_EXPORT EnumVariant 20 : public Microsoft::WRL::RuntimeClass< 21 Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, 22 IEnumVARIANT> { 23 public: 24 // The constructor allocates a vector of empty ScopedVariants of size |count|. 25 // Use ItemAt to set the value of each item in the array. 26 explicit EnumVariant(ULONG count); 27 28 // IEnumVARIANT: 29 IFACEMETHODIMP Next(ULONG requested_count, 30 VARIANT* out_elements, 31 ULONG* out_elements_received) override; 32 IFACEMETHODIMP Skip(ULONG skip_count) override; 33 IFACEMETHODIMP Reset() override; 34 IFACEMETHODIMP Clone(IEnumVARIANT** out_cloned_object) override; 35 36 // Returns a mutable pointer to the item at position |index|. 37 VARIANT* ItemAt(ULONG index); 38 39 private: 40 ~EnumVariant() override; 41 42 std::vector<ScopedVariant> items_; 43 ULONG current_index_; 44 }; 45 46 } // namespace win 47 } // namespace base 48 49 #endif // BASE_WIN_ENUM_VARIANT_H_ 50