1#ifndef _VARIANT_COLLECTION_H
2#define _VARIANT_COLLECTION_H
3
4#include <comutil.h>
5#pragma comment(lib,"comsuppw.lib")
6
7class variant_collection : public STLCollection<_variant_t>
8{
9 typedef STLCollection<_variant_t> base;
10
11public:
12 using base::add;
13 using base::insert;
14 using base::set;
15
16 void add(signed char val)
17 {
18 add<signed char>(val);
19 }
20 void add(unsigned char val)
21 {
22 add<unsigned char>(val);
23 }
24 void add(short val)
25 {
26 add<short>(val);
27 }
28 void add(unsigned short val)
29 {
30 add<unsigned short>(val);
31 }
32 void add(int val)
33 {
34 add<int>(val);
35 }
36 void add(unsigned int val)
37 {
38 add<unsigned int>(val);
39 }
40 void add(float val)
41 {
42 add<float>(val);
43 }
44 void add(double val)
45 {
46 add<double>(val);
47 }
48 void add(const char* val)
49 {
50 add<const char*>(val);
51 }
52
53 void insert(size_t index,signed char val)
54 {
55 insert<signed char>(index,val);
56 }
57 void insert(size_t index,unsigned char val)
58 {
59 insert<unsigned char>(index,val);
60 }
61 void insert(size_t index,short val)
62 {
63 insert<short>(index,val);
64 }
65 void insert(size_t index,unsigned short val)
66 {
67 insert<unsigned short>(index,val);
68 }
69 void insert(size_t index,int val)
70 {
71 insert<int>(index,val);
72 }
73 void insert(size_t index,unsigned int val)
74 {
75 insert<unsigned int>(index,val);
76 }
77 void insert(size_t index,float val)
78 {
79 insert<float>(index,val);
80 }
81 void insert(size_t index,double val)
82 {
83 insert<double>(index,val);
84 }
85 void insert(size_t index,const char* val)
86 {
87 insert<const char*>(index,val);
88 }
89
90 void set(size_t index,signed char val)
91 {
92 set<signed char>(index,val);
93 }
94 void set(size_t index,unsigned char val)
95 {
96 set<unsigned char>(index,val);
97 }
98 void set(size_t index,short val)
99 {
100 set<short>(index,val);
101 }
102 void set(size_t index,unsigned short val)
103 {
104 set<unsigned short>(index,val);
105 }
106 void set(size_t index,int val)
107 {
108 set<int>(index,val);
109 }
110 void set(size_t index,unsigned int val)
111 {
112 set<unsigned int>(index,val);
113 }
114 void set(size_t index,float val)
115 {
116 set<float>(index,val);
117 }
118 void set(size_t index,double val)
119 {
120 set<double>(index,val);
121 }
122 void set(size_t index,const char* val)
123 {
124 set<const char*>(index,val);
125 }
126
127protected:
128 template<typename T>
129 void add(T val)
130 {
131 _variant_t var(val);
132 base::add(var);
133 }
134 template<typename T>
135 void insert(size_t index,T val)
136 {
137 _variant_t var(val);
138 base::insert(index,var);
139 }
140 template<typename T>
141 void set(size_t index,T val)
142 {
143 _variant_t* p_var = base::get(index);
144 if (p_var) *p_var = val;
145 }
146};
147
148#endif