Home | History | Annotate | Download | only in internal
      1 // This file was GENERATED by a script.  DO NOT EDIT BY HAND!!!
      2 
      3 // Copyright 2007, Google Inc.
      4 // All rights reserved.
      5 //
      6 // Redistribution and use in source and binary forms, with or without
      7 // modification, are permitted provided that the following conditions are
      8 // met:
      9 //
     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
     15 // distribution.
     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.
     19 //
     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.
     31 //
     32 // Author: wan (at) google.com (Zhanyong Wan)
     33 
     34 // Google Mock - a framework for writing C++ mock classes.
     35 //
     36 // This file contains template meta-programming utility classes needed
     37 // for implementing Google Mock.
     38 
     39 #ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
     40 #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
     41 
     42 #include "gmock/internal/gmock-port.h"
     43 
     44 namespace testing {
     45 
     46 template <typename T>
     47 class Matcher;
     48 
     49 namespace internal {
     50 
     51 // An IgnoredValue object can be implicitly constructed from ANY value.
     52 // This is used in implementing the IgnoreResult(a) action.
     53 class IgnoredValue {
     54  public:
     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.
     60   template <typename T>
     61   IgnoredValue(const T&) {}
     62 };
     63 
     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>
     67 struct MatcherTuple;
     68 
     69 template <>
     70 struct MatcherTuple< ::std::tr1::tuple<> > {
     71   typedef ::std::tr1::tuple< > type;
     72 };
     73 
     74 template <typename A1>
     75 struct MatcherTuple< ::std::tr1::tuple<A1> > {
     76   typedef ::std::tr1::tuple<Matcher<A1> > type;
     77 };
     78 
     79 template <typename A1, typename A2>
     80 struct MatcherTuple< ::std::tr1::tuple<A1, A2> > {
     81   typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2> > type;
     82 };
     83 
     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;
     87 };
     88 
     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>,
     92       Matcher<A4> > type;
     93 };
     94 
     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>,
     98       Matcher<A5> > type;
     99 };
    100 
    101 template <typename A1, typename A2, typename A3, typename A4, typename A5,
    102     typename A6>
    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;
    106 };
    107 
    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;
    113 };
    114 
    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;
    120 };
    121 
    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;
    127 };
    128 
    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,
    132     A10> > {
    133   typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
    134       Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
    135       Matcher<A10> > type;
    136 };
    137 
    138 // Template struct Function<F>, where F must be a function type, contains
    139 // the following typedefs:
    140 //
    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
    145 //                         parameters of F.
    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>
    152 struct Function;
    153 
    154 template <typename R>
    155 struct Function<R()> {
    156   typedef R Result;
    157   typedef ::std::tr1::tuple<> ArgumentTuple;
    158   typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
    159   typedef void MakeResultVoid();
    160   typedef IgnoredValue MakeResultIgnoredValue();
    161 };
    162 
    163 template <typename R, typename A1>
    164 struct Function<R(A1)>
    165     : Function<R()> {
    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);
    171 };
    172 
    173 template <typename R, typename A1, typename A2>
    174 struct Function<R(A1, A2)>
    175     : Function<R(A1)> {
    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);
    181 };
    182 
    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);
    191 };
    192 
    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);
    201 };
    202 
    203 template <typename R, typename A1, typename A2, typename A3, typename A4,
    204     typename A5>
    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);
    212 };
    213 
    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);
    223 };
    224 
    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);
    234 };
    235 
    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);
    245 };
    246 
    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,
    256       A9);
    257 };
    258 
    259 template <typename R, typename A1, typename A2, typename A3, typename A4,
    260     typename A5, typename A6, typename A7, typename A8, typename A9,
    261     typename A10>
    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,
    266       A10> ArgumentTuple;
    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,
    270       A9, A10);
    271 };
    272 
    273 }  // namespace internal
    274 
    275 }  // namespace testing
    276 
    277 #endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
    278