Author: wyoung
Date: Thu Mar 15 23:14:00 2007
New Revision: 1438
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1438&view=rev
Log:
- Extracted the ugly dynamic_cast<ostream&)(*this) stuff used within the
Query class to work around a VC++ 2003 type conversion bug into a
macro.
- Made that macro conditionally resolve to '*this' instead on all other
platforms. The cast is unnecessary on these other platforms, and
actually causes warnings on VC++ 2005.
Modified:
trunk/lib/query.cpp
trunk/lib/query.h
Modified: trunk/lib/query.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=1438&r1=1437&r2=1438&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Thu Mar 15 23:14:00 2007
@@ -363,7 +363,7 @@
for (std::vector<SQLParseElement>::iterator i = parse_elems_.begin();
i != parse_elems_.end(); ++i) {
- dynamic_cast<std::ostream&>(*this) << i->before;
+ MYSQLPP_QUERY_THISPTR << i->before;
int num = i->num;
if (num >= 0) {
SQLQueryParms* c;
@@ -381,7 +381,7 @@
SQLString& param = (*c)[num];
SQLString* ss = pprepare(i->option, param, c->bound());
- dynamic_cast<std::ostream&>(*this) << *ss;
+ MYSQLPP_QUERY_THISPTR << *ss;
if (ss != ¶m) {
// pprepare() returned a new string object
instead of
// updating param in place, so we need to
delete it.
Modified: trunk/lib/query.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.h?rev=1438&r1=1437&r2=1438&view=diff
==============================================================================
--- trunk/lib/query.h (original)
+++ trunk/lib/query.h Thu Mar 15 23:14:00 2007
@@ -54,6 +54,16 @@
# if defined(HAVE_STD_SLIST) || defined(HAVE_GLOBAL_SLIST)
# include <slist>
# endif
+#endif
+
+// This macro returns '*this', either directly or upcast to Query's
+// base class to work around an error in the overloaded operator
+// lookup logic in VC++ 2003. For an explanation of the problem, see:
+//
http://groups.google.com/group/microsoft.public.vc.stl/browse_thread/thread/9a68d84644e64f15
+#if defined(_MSC_VER) && (_MSC_VER < 1400)
+# define MYSQLPP_QUERY_THISPTR dynamic_cast<std::ostream&>(*this)
+#else
+# define MYSQLPP_QUERY_THISPTR *this
#endif
namespace mysqlpp {
@@ -544,7 +554,7 @@
// Cast required for VC++ 2003 due to error in overloaded
operator
// lookup logic. For an explanation of the problem, see:
//
http://groups-beta.google.com/group/microsoft.public.vc.stl/browse_thread/thread/9a68d84644e64f15
- dynamic_cast<std::ostream&>(*this) << std::setprecision(16) <<
+ MYSQLPP_QUERY_THISPTR << std::setprecision(16) <<
"UPDATE " << o.table() << " SET " <<
n.equal_list() <<
" WHERE " << o.equal_list(" AND ",
sql_use_compare);
return *this;
@@ -564,7 +574,7 @@
reset();
// See above comment for cast rationale
- dynamic_cast<std::ostream&>(*this) << std::setprecision(16) <<
+ MYSQLPP_QUERY_THISPTR << std::setprecision(16) <<
"INSERT INTO " << v.table() << " (" <<
v.field_list() << ") VALUES (" <<
v.value_list() << ')';
@@ -593,15 +603,14 @@
}
// See above comment for cast rationale
- dynamic_cast<std::ostream&>(*this) << std::setprecision(16) <<
+ MYSQLPP_QUERY_THISPTR << std::setprecision(16) <<
"INSERT INTO " << first->table() << " (" <<
first->field_list() << ") VALUES (" <<
first->value_list() << ')';
Iter it = first + 1;
while (it != last) {
- dynamic_cast<std::ostream&>(*this) << ",(" <<
- it->value_list() << ')';
+ MYSQLPP_QUERY_THISPTR << ",(" << it->value_list() <<
')';
++it;
}
@@ -623,7 +632,7 @@
reset();
// See above comment for cast rationale
- dynamic_cast<std::ostream&>(*this) << std::setprecision(16) <<
+ MYSQLPP_QUERY_THISPTR << std::setprecision(16) <<
"REPLACE INTO " << v.table() << " (" <<
v.field_list() << ") VALUES (" <<
v.value_list() << ')';
return *this;
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits