enum_variant.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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
  3. // found in the LICENSE file.
  4. #ifndef BASE_WIN_ENUM_VARIANT_H_
  5. #define BASE_WIN_ENUM_VARIANT_H_
  6. #include <wrl/implements.h>
  7. #include <memory>
  8. #include <vector>
  9. #include "base/win/scoped_variant.h"
  10. namespace base {
  11. namespace win {
  12. // A simple implementation of IEnumVARIANT.
  13. class BASE_EXPORT EnumVariant
  14. : public Microsoft::WRL::RuntimeClass<
  15. Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
  16. IEnumVARIANT> {
  17. public:
  18. // The constructor allocates a vector of empty ScopedVariants of size |count|.
  19. // Use ItemAt to set the value of each item in the array.
  20. explicit EnumVariant(ULONG count);
  21. // IEnumVARIANT:
  22. IFACEMETHODIMP Next(ULONG requested_count,
  23. VARIANT* out_elements,
  24. ULONG* out_elements_received) override;
  25. IFACEMETHODIMP Skip(ULONG skip_count) override;
  26. IFACEMETHODIMP Reset() override;
  27. IFACEMETHODIMP Clone(IEnumVARIANT** out_cloned_object) override;
  28. // Returns a mutable pointer to the item at position |index|.
  29. VARIANT* ItemAt(ULONG index);
  30. private:
  31. ~EnumVariant() override;
  32. std::vector<ScopedVariant> items_;
  33. ULONG current_index_;
  34. };
  35. } // namespace win
  36. } // namespace base
  37. #endif // BASE_WIN_ENUM_VARIANT_H_