Thread: [Mockpp-commits] mockpp/mockpp/builder ArgumentsMatchBuilderN.h,NONE,1.1 gen_argumentsmatchbuilder_N
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-10-28 19:04:14
|
Update of /cvsroot/mockpp/mockpp/mockpp/builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7258/mockpp/builder Modified Files: ArgumentsMatchBuilder.h Makefile.am Added Files: ArgumentsMatchBuilderN.h gen_argumentsmatchbuilder_N.pl Log Message: basic file set working --- NEW FILE: gen_argumentsmatchbuilder_N.pl --- #!/usr/bin/perl -w # # $Id: gen_argumentsmatchbuilder_N.pl,v 1.1 2005/10/28 19:04:04 ewald-arnold Exp $ use English; if ($#ARGV < 0) { print "Usage: perl gen_invocation_N <number of arguments>\n"; exit; } $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } open OUT, ">ArgumentsMatchBuilderN.h"; print OUT "/** \@file \@internal NOT INTENDED FOR PUBLIC INCLUSION \@brief Generated with gen_argumentsmatchbuilder_N.pl. \$I" . "d: InvocationN.h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ /************************************************************************** begin : Sun Aug 22 2004 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_ARGUMENTSMATCHBUILDER_N_H #define MOCKPP_ARGUMENTSMATCHBUILDER_N_H //#include <mockpp/builder/ArgumentsMatchBuilder.h> namespace mockpp { "; for ($numArgs = 1; $numArgs <= $totalNumArgs; ++$numArgs) { $templateParms = ""; $templateParms_colon = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $templateParms .= ", "; } $templateParms .= "typename P$i"; } if ($numArgs > 0) { $templateParms_colon = ", " . $templateParms; } $templateArgs_colon = ""; $_ = $templateParms; s/typename //g; $templateArgs = $_; if ($numArgs > 0) { $templateArgs_colon = ", ". $templateArgs; } $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $parms .= ", "; } $parms .= "const P$i &p$i"; } $percentParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $percentParms .= ", "; } $percentParms .= "%$i"; } $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $holderParms .= ", "; } $holderParms .= "const ConstraintHolder<P$i> &p$i"; } $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $args .= ", "; } $args .= "p$i"; } $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $boundArgs .= ", "; } $boundArgs .= "args->a$i"; } $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $copyParms .= ", "; } $copyParms .= "P$i ia$i"; } $hArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $hArgs .= ", "; } $hArgs .= "h$i"; } $initArgs = ""; if ($numArgs > 0) { $initArgs = ":"; } for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $initArgs .= ", "; } $initArgs .= "p$i(ip$i)"; } $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argTypes .= "typedef P$i p". ($i+1) . "_type; "; } print "Creating ArgumentsMatchBuilder" . $numArgs ."\n"; print OUT " /** Build a matcher for an invocation with " . $numArgs ." argument. * \@ingroup grp_chainer * \@internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder" . $numArgs ." : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType;"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " typedef typename I::T" .$p . "Type P" .$p . ";"; } print OUT " typedef ConstraintSet" . $numArgs ."<" . $templateArgs . "> ConstraintSetType; /** Adds another matcher. * \@param matcher the matcher object * \@return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for " . $numArgs ." arguments. * \@ingroup grp_chainer"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param cons" .$p . " pointer to the constraint for method parameter " .$p; } print OUT " * \@return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1"; for($p = 2; $p <= $numArgs; ++$p) { print OUT " , const ConstraintHolder<P" .$p . "> &p" .$p; } print OUT " ) { return with_cs( ConstraintSetType( " . $args . " ) ); } protected: /** Indicate a matcher for a set of arguments. * \@param constraintset constraint set * \@return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; "; } print OUT " } // ns mockpp #endif // MOCKPP_ARGUMENTSMATCHBUILDER_N_H "; close OUT; Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/builder/Makefile.am,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Makefile.am 19 Sep 2005 18:34:35 -0000 1.9 +++ Makefile.am 28 Oct 2005 19:04:04 -0000 1.10 @@ -1,10 +1,19 @@ INCLUDES = $(all_includes) -I$(top_srcdir) -I$(top_builddir) $(EA_EXTRA_INC) DEFAULT_INCLUDES = $(INCLUDES) -libbuilderinclude_HEADERS = ArgumentsMatchBuilder.h BuilderNamespace.h IdentityBuilder.h InvocationMockerBuilder.h MatchBuilder.h StubBuilder.h +libbuilderinclude_HEADERS = ArgumentsMatchBuilder.h \ + ArgumentsMatchBuilderN.h \ + BuilderNamespace.h \ + IdentityBuilder.h \ + InvocationMockerBuilder.h \ + MatchBuilder.h \ + StubBuilder.h libbuilderincludedir = $(includedir)/mockpp/builder +EXTRA_DIST = \ + gen_argumentsmatchbuilder_N.pl + CLEANFILES = *.~* *.~~* *~ *.old noinst_LTLIBRARIES = libbuilder.la --- NEW FILE: ArgumentsMatchBuilderN.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_argumentsmatchbuilder_N.pl. $Id: ArgumentsMatchBuilderN.h,v 1.1 2005/10/28 19:04:04 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sun Aug 22 2004 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_ARGUMENTSMATCHBUILDER_N_H #define MOCKPP_ARGUMENTSMATCHBUILDER_N_H //#include <mockpp/builder/ArgumentsMatchBuilder.h> namespace mockpp { /** Build a matcher for an invocation with 1 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder1 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef ConstraintSet1<P1> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 1 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 ) { return with_cs( ConstraintSetType( p1 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; /** Build a matcher for an invocation with 2 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder2 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef typename I::T2Type P2; typedef ConstraintSet2<P1, P2> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 2 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @param cons2 pointer to the constraint for method parameter 2 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 , const ConstraintHolder<P2> &p2 ) { return with_cs( ConstraintSetType( p1, p2 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; /** Build a matcher for an invocation with 3 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder3 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef typename I::T2Type P2; typedef typename I::T3Type P3; typedef ConstraintSet3<P1, P2, P3> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 3 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @param cons2 pointer to the constraint for method parameter 2 * @param cons3 pointer to the constraint for method parameter 3 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 , const ConstraintHolder<P2> &p2 , const ConstraintHolder<P3> &p3 ) { return with_cs( ConstraintSetType( p1, p2, p3 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; /** Build a matcher for an invocation with 4 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder4 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef typename I::T2Type P2; typedef typename I::T3Type P3; typedef typename I::T4Type P4; typedef ConstraintSet4<P1, P2, P3, P4> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 4 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @param cons2 pointer to the constraint for method parameter 2 * @param cons3 pointer to the constraint for method parameter 3 * @param cons4 pointer to the constraint for method parameter 4 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 , const ConstraintHolder<P2> &p2 , const ConstraintHolder<P3> &p3 , const ConstraintHolder<P4> &p4 ) { return with_cs( ConstraintSetType( p1, p2, p3, p4 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; /** Build a matcher for an invocation with 5 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder5 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef typename I::T2Type P2; typedef typename I::T3Type P3; typedef typename I::T4Type P4; typedef typename I::T5Type P5; typedef ConstraintSet5<P1, P2, P3, P4, P5> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 5 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @param cons2 pointer to the constraint for method parameter 2 * @param cons3 pointer to the constraint for method parameter 3 * @param cons4 pointer to the constraint for method parameter 4 * @param cons5 pointer to the constraint for method parameter 5 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 , const ConstraintHolder<P2> &p2 , const ConstraintHolder<P3> &p3 , const ConstraintHolder<P4> &p4 , const ConstraintHolder<P5> &p5 ) { return with_cs( ConstraintSetType( p1, p2, p3, p4, p5 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; } // ns mockpp #endif // MOCKPP_ARGUMENTSMATCHBUILDER_N_H Index: ArgumentsMatchBuilder.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/builder/ArgumentsMatchBuilder.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- ArgumentsMatchBuilder.h 26 Oct 2005 20:04:29 -0000 1.29 +++ ArgumentsMatchBuilder.h 28 Oct 2005 19:04:04 -0000 1.30 @@ -50,6 +50,7 @@ namespace mockpp { + /** Build a matcher for an invocation with no arguments. * @ingroup grp_chainer * @internal @@ -89,242 +90,12 @@ }; -/** Build a matcher for an invocation with 1 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder1 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef ConstraintSet1<T1> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 1 argument. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for the method parameter - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1 ) - { - return with_cs( ConstraintSetType( cons1 ) ); - } - - protected: - - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; - - -/** Build a matcher for an invocation with 2 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder2 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef typename I::T2Type T2; - typedef ConstraintSet2<T1, T2> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 2 arguments. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for method parameter 1 - * @param cons2 pointer to the constraint for method parameter 2 - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1, - const ConstraintHolder<T2> &cons2 ) - { - return with_cs( ConstraintSetType( cons1, cons2 ) ); - } - - protected: - - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; - - -/** Build a matcher for an invocation with 3 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder3 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef typename I::T2Type T2; - typedef typename I::T3Type T3; - typedef ConstraintSet3<T1, T2, T3> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 3 arguments. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for method parameter 1 - * @param cons2 pointer to the constraint for method parameter 2 - * @param cons3 pointer to the constraint for method parameter 3 - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1, - const ConstraintHolder<T2> &cons2, - const ConstraintHolder<T3> &cons3 ) - { - return with_cs( ConstraintSetType( cons1, cons2, cons3 ) ); - } - - protected: - - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; - - -/** Build a matcher for an invocation with 4 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder4 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef typename I::T2Type T2; - typedef typename I::T3Type T3; - typedef typename I::T4Type T4; - typedef ConstraintSet4<T1, T2, T3, T4> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 4 arguments. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for method parameter 1 - * @param cons2 pointer to the constraint for method parameter 2 - * @param cons3 pointer to the constraint for method parameter 3 - * @param cons4 pointer to the constraint for method parameter 4 - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1, - const ConstraintHolder<T2> &cons2, - const ConstraintHolder<T3> &cons3, - const ConstraintHolder<T4> &cons4 ) - { - return with_cs( ConstraintSetType( cons1, cons2, cons3, cons4 ) ); - } - - protected: - - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; - - -/** Build a matcher for an invocation with 5 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder5 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef typename I::T2Type T2; - typedef typename I::T3Type T3; - typedef typename I::T4Type T4; - typedef typename I::T5Type T5; - typedef ConstraintSet5<T1, T2, T3, T4, T5> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 5 arguments. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for method parameter 1 - * @param cons2 pointer to the constraint for method parameter 2 - * @param cons3 pointer to the constraint for method parameter 3 - * @param cons4 pointer to the constraint for method parameter 4 - * @param cons5 pointer to the constraint for method parameter 5 - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1, - const ConstraintHolder<T2> &cons2, - const ConstraintHolder<T3> &cons3, - const ConstraintHolder<T4> &cons4, - const ConstraintHolder<T5> &cons5 ) - { - return with_cs( ConstraintSetType( cons1, cons2, cons3, cons4, cons5 ) ); - } +} // namespace mockpp - protected: - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; +#endif // MOCKPP_ARGUMENTSMATCHBUILDER_H -} // namespace mockpp +#include "ArgumentsMatchBuilderN.h" -#endif // MOCKPP_ARGUMENTSMATCHBUILDER_H |