Author: wyoung
Date: Sat Mar 11 06:24:37 2006
New Revision: 1245

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1245&view=rev
Log:
Removed mysql_query_define[0-2] macros from query.h, and wrote new
querydef.pl script to generate them in querydef.h.  This allows us to
easily change the number of arguments to the functions defined by these
macros.  We've increased the limit from 12 to 25, to match the SSQLS
data member limit.

Added:
    branches/v2.1-bakefile/lib/querydef.pl   (with props)
Modified:
    branches/v2.1-bakefile/Wishlist
    branches/v2.1-bakefile/lib/   (props changed)
    branches/v2.1-bakefile/lib/query.h

Modified: branches/v2.1-bakefile/Wishlist
URL: 
http://svn.gna.org/viewcvs/mysqlpp/branches/v2.1-bakefile/Wishlist?rev=1245&r1=1244&r2=1245&view=diff
==============================================================================
--- branches/v2.1-bakefile/Wishlist (original)
+++ branches/v2.1-bakefile/Wishlist Sat Mar 11 06:24:37 2006
@@ -29,10 +29,6 @@
        base class.
 
 
-       o Someone reported needing more than 12 parameters in a templatized
-         query.  We can just add some more overloads, but we should take
-         the opportunity to see if there's a cleaner way to handle this.
-       
        o The manual recommends using "0, 0" as the second and third
          parameters for creating SSQLSes, but this doesn't actually
          compile.  Try to enumerate all the possible function overloading

Propchange: branches/v2.1-bakefile/lib/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sat Mar 11 06:24:37 2006
@@ -42,6 +42,7 @@
 Doxyfile
 exceptions.h
 mysql++.h
+querydef.h
 release
 stamp-h2
 tags

Modified: branches/v2.1-bakefile/lib/query.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/branches/v2.1-bakefile/lib/query.h?rev=1245&r1=1244&r2=1245&view=diff
==============================================================================
--- branches/v2.1-bakefile/lib/query.h (original)
+++ branches/v2.1-bakefile/lib/query.h Sat Mar 11 06:24:37 2006
@@ -3,7 +3,7 @@
 
 /***********************************************************************
  Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
- MySQL AB, and (c) 2004, 2005 by Educational Technology Resources, Inc.
+ MySQL AB, and (c) 2004-2006 by Educational Technology Resources, Inc.
  Others may also hold copyrights on code in this file.  See the CREDITS
  file in the top directory of the distribution for details.
 
@@ -33,6 +33,7 @@
 #include "lockable.h"
 #include "noexceptions.h"
 #include "qparms.h"
+#include "querydef.h"
 #include "result.h"
 #include "row.h"
 #include "sql_string.h"
@@ -53,68 +54,6 @@
 #      include <slist>
 #  endif
 #endif
-
-
-/// \brief Used to define many similar functions in class Query.
-#define mysql_query_define0(RETURN, FUNC)\
-  RETURN FUNC (ss a)\
-    {return FUNC (parms() << a);}\
-  RETURN FUNC (ss a, ss b)\
-    {return FUNC (parms() << a << b);}\
-  RETURN FUNC (ss a, ss b, ss c)\
-    {return FUNC (parms() << a << b << c);}\
-  RETURN FUNC (ss a, ss b, ss c, ss d)\
-    {return FUNC (parms() << a << b << c << d);}\
-  RETURN FUNC (ss a, ss b, ss c, ss d, ss e)\
-    {return FUNC (parms() << a << b << c << d << e);} \
-  RETURN FUNC (ss a, ss b, ss c, ss d, ss e, ss f)\
-    {return FUNC (parms() << a << b << c << d << e << f);}\
-  RETURN FUNC (ss a, ss b, ss c, ss d, ss e, ss f, ss g)\
-    {return FUNC (parms() << a << b << c << d << e << f << g);}\
-  RETURN FUNC (ss a, ss b, ss c, ss d, ss e, ss f, ss g, ss h)\
-    {return FUNC (parms() << a << b << c << d << e << f << g << h);}\
-  RETURN FUNC (ss a, ss b, ss c, ss d, ss e, ss f, ss g, ss h, ss i)\
-    {return FUNC (parms() << a << b << c << d << e << f << g << h << i);}\
-  RETURN FUNC (ss a,ss b,ss c,ss d,ss e,ss f,ss g,ss h,ss i,ss j)\
-    {return FUNC (parms() <<a <<b <<c <<d <<e <<f <<g <<h <<i <<j);}\
-  RETURN FUNC (ss a,ss b,ss c,ss d,ss e,ss f,ss g,ss h,ss i,ss j,ss k)\
-    {return FUNC (parms() <<a <<b <<c <<d <<e <<f <<g <<h <<i <<j <<k);}\
-  RETURN FUNC (ss a,ss b,ss c,ss d,ss e,ss f,ss g,ss h,ss i,ss j,ss k,ss l)\
-    {return FUNC (parms() <<a <<b <<c <<d <<e <<f <<g <<h <<i <<j <<k <<l);}\
-
-/// \brief Used to define many similar member functions in class Query.
-#define mysql_query_define1(RETURN, FUNC) \
-  MYSQLPP_EXPORT RETURN FUNC (parms &p);\
-  mysql_query_define0(RETURN,FUNC) \
-
-/// \brief Used to define many similar member functions in class Query.
-#define mysql_query_define2(FUNC) \
-  template <class T1> void FUNC (T1 &con, const char* str); \
-  template <class T1> void FUNC (T1 &con, parms &p, query_reset r = 
RESET_QUERY);\
-  template <class T1> void FUNC (T1 &con, ss a)\
-       {FUNC (con, parms() << a);}\
-  template <class T1> void FUNC (T1 &con, ss a, ss b)\
-       {FUNC (con, parms() << a << b);}\
-  template <class T1> void FUNC (T1 &con, ss a, ss b, ss c)\
-       {FUNC (con, parms() << a << b << c);}\
-  template <class T1> void FUNC (T1 &con, ss a, ss b, ss c, ss d)\
-       {FUNC (con, parms() << a << b << c << d);}\
-  template <class T1> void FUNC (T1 &con, ss a, ss b, ss c, ss d, ss e)\
-       {FUNC (con, parms() << a << b << c << d << e);} \
-  template <class T1> void FUNC (T1 &con, ss a, ss b, ss c, ss d, ss e, ss f)\
-       {FUNC (con, parms() << a << b << c << d << e << f);}\
-  template <class T1> void FUNC (T1 &con,ss a,ss b,ss c,ss d,ss e,ss f,ss g)\
-       {FUNC (con, parms() << a << b << c << d << e << f << g);}\
-  template <class T1> void FUNC (T1 &con,ss a,ss b,ss c,ss d,ss e,ss f,ss g,ss 
h)\
-       {FUNC (con, parms() << a << b << c << d << e << f << g << h);}\
-  template <class T1> void FUNC (T1 &con, ss a, ss b, ss c, ss d, ss e, ss f, 
ss g, ss h, ss i)\
-       {FUNC (con, parms() << a << b << c << d << e << f << g << h << i);}\
-  template <class T1> void FUNC (T1 &con, ss a,ss b,ss c,ss d,ss e,ss f,ss 
g,ss h,ss i,ss j)\
-       {FUNC (con, parms() <<a <<b <<c <<d <<e <<f <<g <<h <<i <<j);}\
-  template <class T1> void FUNC (T1 &con, ss a,ss b,ss c,ss d,ss e,ss f,ss 
g,ss h,ss i,ss j,ss k)\
-       {FUNC (con, parms() <<a <<b <<c <<d <<e <<f <<g <<h <<i <<j <<k);}\
-  template <class T1> void FUNC (T1 &con, ss a,ss b,ss c,ss d,ss e,ss f,ss 
g,ss h,ss i,ss j,ss k,ss l)\
-       {FUNC (con, parms() <<a <<b <<c <<d <<e <<f <<g <<h <<i <<j <<k <<l);}\
 
 namespace mysqlpp {
 
@@ -176,8 +115,8 @@
                public OptionalExceptions, public Lockable
 {
 public:
-       typedef const SQLString& ss;    ///< to keep parameter lists short
-       typedef SQLQueryParms parms;    ///< shortens def'ns of above macros
+       //typedef const SQLString& ss;  ///< to keep parameter lists short
+       //typedef SQLQueryParms parms;  ///< shortens def'ns of above macros
 
        /// \brief Create a new query object attached to a connection.
        ///

Added: branches/v2.1-bakefile/lib/querydef.pl
URL: 
http://svn.gna.org/viewcvs/mysqlpp/branches/v2.1-bakefile/lib/querydef.pl?rev=1245&view=auto
==============================================================================
--- branches/v2.1-bakefile/lib/querydef.pl (added)
+++ branches/v2.1-bakefile/lib/querydef.pl Sat Mar 11 06:24:37 2006
@@ -1,0 +1,104 @@
+#!/usr/bin/perl -w
+
+########################################################################
+# querydef.pl - Generates querydef.h, which defines a number of macros
+#      used in query.h that differ only in the number of arguments.  That
+#      number limits the number of parameters a MySQL++ template query can
+#      accept.  This value can be changed from its default, below.
+#
+# Copyright (c) 2006 by Educational Technology Resources, Inc.  Others
+# may also hold copyrights on code in this file.  See the CREDITS file
+# in the top directory of the distribution for details.
+#
+# This file is part of MySQL++.
+#
+# MySQL++ 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.1 of the License, or
+# (at your option) any later version.
+#
+# MySQL++ 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 Lesser General Public
+# License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with MySQL++; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+# USA
+########################################################################
+
+
+# The number of parameters a template query can accept.  Make this value
+# larger only at need, as it adds code to the library proportionally.
+# You should not reduce this value if programs you did not write may
+# link to the library, as that would constitute an ABI breakage.
+my $max_parameters = 25;
+
+
+# No user-serviceable parts below.
+
+use strict;
+
+open (OUT, ">querydef.h");
+
+print OUT << "---";
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// This file is generated by the Perl script querydef.pl. Please do 
+// not modify this file directly. Change the script instead.
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+#ifndef MYSQLPP_QUERYDEF_H
+#define MYSQLPP_QUERYDEF_H
+
+---
+
+## Build mysql_query_define0 macro
+print OUT "#define mysql_query_define0(RETURN, FUNC) \\\n";
+for (my $i = 0; $i < $max_parameters; ++$i) {
+       print OUT "\tRETURN FUNC(";
+       for (my $j = 0; $j < $i + 1; ++$j) {
+               print OUT 'const SQLString& arg', $j;
+               print OUT ', ' unless $j == $i;
+       }
+       print OUT ") \\\n";
+
+       print OUT "\t\t{ return FUNC(SQLQueryParms()";
+       for (my $j = 0; $j < $i + 1; ++$j) {
+               print OUT ' << arg', $j;
+       }
+       print OUT "); } \\\n";
+}
+
+## Add mysql_query_define1 macro
+print OUT << "---";
+
+#define mysql_query_define1(RETURN, FUNC) \\
+       MYSQLPP_EXPORT RETURN FUNC(SQLQueryParms& p); \\
+       mysql_query_define0(RETURN, FUNC)
+---
+
+## Add mysql_query_define2 macro
+print OUT << "---";
+
+#define mysql_query_define2(FUNC) \\
+       template <class T> void FUNC(T& container, const char* str); \\
+       template <class T> void FUNC(T& container, SQLQueryParms& p, \\
+               query_reset r = RESET_QUERY); \\
+---
+for (my $i = 0; $i < $max_parameters; ++$i) {
+       print OUT "\ttemplate <class T> void FUNC(T& container";
+       for (my $j = 0; $j < $i + 1; ++$j) {
+               print OUT ', const SQLString& arg', $j;
+       }
+       print OUT ") \\\n";
+       print OUT "\t\t{ FUNC(con, SQLQueryParms()";
+       for (my $j = 0; $j < $i + 1; ++$j) {
+               print OUT ' << arg', $j;
+       }
+       print OUT "); } \\\n";
+}
+
+## That's all, folks!
+print OUT "\n#endif // !defined(MYSQLPP_QUERYDEF_H)\n";
+

Propchange: branches/v2.1-bakefile/lib/querydef.pl
------------------------------------------------------------------------------
    svn:executable = *


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to