1 // This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
3 // Copyright 2007, Google Inc.
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following disclaimer
14 // in the documentation and/or other materials provided with the
16 // * Neither the name of Google Inc. nor the names of its
17 // contributors may be used to endorse or promote products derived from
18 // this software without specific prior written permission.
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // Author: wan@google.com (Zhanyong Wan)
34 // Google Mock - a framework for writing C++ mock classes.
36 // This file contains template meta-programming utility classes needed
37 // for implementing Google Mock.
39 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
40 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
42 #include <gmock/internal/gmock-port.h>
51 // An IgnoredValue object can be implicitly constructed from ANY value.
52 // This is used in implementing the IgnoreResult(a) action.
55 // This constructor template allows any value to be implicitly
56 // converted to IgnoredValue. The object has no data member and
57 // doesn't try to remember anything about the argument. We
58 // deliberately omit the 'explicit' keyword in order to allow the
59 // conversion to be implicit.
61 IgnoredValue(const T&) {}
64 // MatcherTuple<T>::type is a tuple type where each field is a Matcher
65 // for the corresponding field in tuple type T.
66 template <typename Tuple>
70 struct MatcherTuple< ::std::tr1::tuple<> > {
71 typedef ::std::tr1::tuple< > type;
74 template <typename A1>
75 struct MatcherTuple< ::std::tr1::tuple<A1> > {
76 typedef ::std::tr1::tuple<Matcher<A1> > type;
79 template <typename A1, typename A2>
80 struct MatcherTuple< ::std::tr1::tuple<A1, A2> > {
81 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2> > type;
84 template <typename A1, typename A2, typename A3>
85 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3> > {
86 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
89 template <typename A1, typename A2, typename A3, typename A4>
90 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4> > {
91 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
95 template <typename A1, typename A2, typename A3, typename A4, typename A5>
96 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5> > {
97 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
101 template <typename A1, typename A2, typename A3, typename A4, typename A5,
103 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {
104 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
105 Matcher<A5>, Matcher<A6> > type;
108 template <typename A1, typename A2, typename A3, typename A4, typename A5,
109 typename A6, typename A7>
110 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {
111 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
112 Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
115 template <typename A1, typename A2, typename A3, typename A4, typename A5,
116 typename A6, typename A7, typename A8>
117 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
118 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
119 Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
122 template <typename A1, typename A2, typename A3, typename A4, typename A5,
123 typename A6, typename A7, typename A8, typename A9>
124 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
125 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
126 Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
129 template <typename A1, typename A2, typename A3, typename A4, typename A5,
130 typename A6, typename A7, typename A8, typename A9, typename A10>
131 struct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
133 typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
134 Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
138 // Template struct Function<F>, where F must be a function type, contains
139 // the following typedefs:
141 // Result: the function's return type.
142 // ArgumentN: the type of the N-th argument, where N starts with 1.
143 // ArgumentTuple: the tuple type consisting of all parameters of F.
144 // ArgumentMatcherTuple: the tuple type consisting of Matchers for all
146 // MakeResultVoid: the function type obtained by substituting void
147 // for the return type of F.
148 // MakeResultIgnoredValue:
149 // the function type obtained by substituting Something
150 // for the return type of F.
151 template <typename F>
154 template <typename R>
155 struct Function<R()> {
157 typedef ::std::tr1::tuple<> ArgumentTuple;
158 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
159 typedef void MakeResultVoid();
160 typedef IgnoredValue MakeResultIgnoredValue();
163 template <typename R, typename A1>
164 struct Function<R(A1)>
166 typedef A1 Argument1;
167 typedef ::std::tr1::tuple<A1> ArgumentTuple;
168 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
169 typedef void MakeResultVoid(A1);
170 typedef IgnoredValue MakeResultIgnoredValue(A1);
173 template <typename R, typename A1, typename A2>
174 struct Function<R(A1, A2)>
176 typedef A2 Argument2;
177 typedef ::std::tr1::tuple<A1, A2> ArgumentTuple;
178 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
179 typedef void MakeResultVoid(A1, A2);
180 typedef IgnoredValue MakeResultIgnoredValue(A1, A2);
183 template <typename R, typename A1, typename A2, typename A3>
184 struct Function<R(A1, A2, A3)>
185 : Function<R(A1, A2)> {
186 typedef A3 Argument3;
187 typedef ::std::tr1::tuple<A1, A2, A3> ArgumentTuple;
188 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
189 typedef void MakeResultVoid(A1, A2, A3);
190 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);
193 template <typename R, typename A1, typename A2, typename A3, typename A4>
194 struct Function<R(A1, A2, A3, A4)>
195 : Function<R(A1, A2, A3)> {
196 typedef A4 Argument4;
197 typedef ::std::tr1::tuple<A1, A2, A3, A4> ArgumentTuple;
198 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
199 typedef void MakeResultVoid(A1, A2, A3, A4);
200 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
203 template <typename R, typename A1, typename A2, typename A3, typename A4,
205 struct Function<R(A1, A2, A3, A4, A5)>
206 : Function<R(A1, A2, A3, A4)> {
207 typedef A5 Argument5;
208 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
209 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
210 typedef void MakeResultVoid(A1, A2, A3, A4, A5);
211 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
214 template <typename R, typename A1, typename A2, typename A3, typename A4,
215 typename A5, typename A6>
216 struct Function<R(A1, A2, A3, A4, A5, A6)>
217 : Function<R(A1, A2, A3, A4, A5)> {
218 typedef A6 Argument6;
219 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
220 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
221 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
222 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
225 template <typename R, typename A1, typename A2, typename A3, typename A4,
226 typename A5, typename A6, typename A7>
227 struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
228 : Function<R(A1, A2, A3, A4, A5, A6)> {
229 typedef A7 Argument7;
230 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
231 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
232 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
233 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
236 template <typename R, typename A1, typename A2, typename A3, typename A4,
237 typename A5, typename A6, typename A7, typename A8>
238 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
239 : Function<R(A1, A2, A3, A4, A5, A6, A7)> {
240 typedef A8 Argument8;
241 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
242 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
243 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
244 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
247 template <typename R, typename A1, typename A2, typename A3, typename A4,
248 typename A5, typename A6, typename A7, typename A8, typename A9>
249 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
250 : Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
251 typedef A9 Argument9;
252 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
253 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
254 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
255 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
259 template <typename R, typename A1, typename A2, typename A3, typename A4,
260 typename A5, typename A6, typename A7, typename A8, typename A9,
262 struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
263 : Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
264 typedef A10 Argument10;
265 typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
267 typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
268 typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
269 typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
273 } // namespace internal
275 } // namespace testing
277 #endif // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_