Separatista
enumvariant.h
1 /***************************************************************************
2  * Copyright (C) 2013 by Okkel Klaver *
3  * info@vanhetland.nl *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 #include "windows.h"
22 #include <vector>
23 #include <array>
24 #include "unknown.cpp"
25 #include "separatista/debug/debug.h"
26 
27 #ifndef SEPARATISTA_ENUMVARIANT_H
28 #define SEPARATISTA_ENUMVARIANT_H
29 
30 class EnumVariant : public SepaControlUnknown<IEnumVARIANT>
31 {
32 public:
33  EnumVariant();
34 
35  // IEnumVARIANT methods
36  STDMETHOD(Next)(unsigned long celt, VARIANT FAR* rgvar, unsigned long FAR* pceltFetched);
37  STDMETHOD(Skip)(unsigned long celt);
38  STDMETHOD(Reset)();
39  STDMETHOD(Clone)(IEnumVARIANT FAR* FAR* ppenum);
40 
41  // Other methods
45  HRESULT Add(const VARIANT &vt);
46 
47 protected:
53  ~EnumVariant();
54 
59  static const std::size_t VariantBlockSize = 10;
60 
64  HRESULT Grow();
65 
69  VARIANT& Get(std::size_t index);
70 
71  typedef std::array<VARIANT, VariantBlockSize> VariantBlockType;
72  typedef std::vector<VariantBlockType*> VariantBlockList;
73 
74 private:
75  ULONG m_uRefCount;
76 
80  VariantBlockList m_objects;
84  std::size_t m_size;
89  std::size_t m_wpos;
93  std::size_t m_pos;
94 
95 };
96 
97 #endif // !defined SEPARATISTA_ENUMVARIANT_H
HRESULT Grow()
Definition: enumvariant.cpp:148
Definition: enumvariant.h:30
Definition: unknown.h:28
VARIANT & Get(std::size_t index)
Definition: enumvariant.cpp:168
HRESULT Add(const VARIANT &vt)
Definition: enumvariant.cpp:124
~EnumVariant()
Definition: enumvariant.cpp:36
static const std::size_t VariantBlockSize
Definition: enumvariant.h:59