Chromium Code Reviews| Index: base/win/enum_variant.h |
| =================================================================== |
| --- base/win/enum_variant.h (revision 0) |
| +++ base/win/enum_variant.h (revision 0) |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_WIN_ENUM_VARIANT_H_ |
| +#define BASE_WIN_ENUM_VARIANT_H_ |
| +#pragma once |
| + |
| +#include <unknwn.h> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/win/iunknown_impl.h" |
| + |
| +namespace base { |
| +namespace win { |
| + |
| +// A simple implementation of IEnumVARIANT. |
| +class BASE_EXPORT EnumVariant |
| + : public IEnumVARIANT, |
| + public IUnknownImpl { |
| + public: |
| + // The constructor allocates an array of size |count|. Then use |
| + // ItemAt to set the value of each item in the array to initialize it. |
| + explicit EnumVariant(unsigned long count); |
| + |
| + // Returns a mutable pointer to the item at position |index|. |
| + VARIANT* ItemAt(unsigned long index); |
|
M-A Ruel
2011/12/01 00:35:13
Why doesn't it return a reference? Just wondering.
dmazzoni
2011/12/02 00:44:07
I'm used to the Google coding style of pointers fo
|
| + |
| + // IUnknown. |
| + ULONG STDMETHODCALLTYPE AddRef() OVERRIDE; |
| + ULONG STDMETHODCALLTYPE Release() OVERRIDE; |
| + STDMETHODIMP QueryInterface(REFIID riid, void** ppv) OVERRIDE; |
| + |
| + // IEnumVARIANT. |
| + STDMETHODIMP Next(ULONG requested_count, |
| + VARIANT* out_elements, |
| + ULONG* out_elements_received); |
| + STDMETHODIMP Skip(ULONG skip_count); |
| + STDMETHODIMP Reset(); |
| + STDMETHODIMP Clone(IEnumVARIANT** out_cloned_object); |
| + |
| + private: |
| + ~EnumVariant(); |
| + |
| + scoped_array<VARIANT> items_; |
| + unsigned long count_; |
| + unsigned long current_index_; |
| +}; |
| + |
| +} // namespace win |
| +} // namespace base |
| + |
| +#endif // BASE_WIN_ENUM_VARIANT_H_ |