gmock-generated-internal-utils.h 11 KB

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