List:MySQL++« Previous MessageNext Message »
From:Chris Frey Date:May 18 2005 2:51pm
Subject:Re: [PATCH] documentation and type_info fix
View as plain text  
On Fri, May 13, 2005 at 04:17:01AM -0400, Chris Frey wrote:
> > >Also in type_info.cpp, I changed part of the type lookup table, to match
> > 
> > I didn't study it deeply enough to know whether this is the right thing, 
> > so I've decided to trust that you know what you're doing here.  :)
> 
> If you can hold off the next release for a couple days, I can be even
> more definite I'm right, and can post a little test to prove it.

Below is a test patch only, not intended for inclusion with the distro.
All it does is dump the contents of the lookups map to stdout, displaying
the C++ type name, and the corresponding mysql enum code.

I ran it twice: once with the type_info patch from earlier, and one with
the original 'true' settings.  The dump was identical for both test runs,
proving that the earlier patch makes no change to the underlying behaviour.

Here is the dump... kinda messy with all the C++ names, but included for
completeness.

First: N7mysqlpp4NullIyNS_10NullisNullEEE Second: 60
First: N7mysqlpp4NullIjNS_10NullisNullEEE Second: 59
First: N7mysqlpp4NullItNS_10NullisNullEEE Second: 54
First: N7mysqlpp4NullIhNS_10NullisNullEEE Second: 53
First: N7mysqlpp4NullINS_3SetISsEENS_10NullisNullEEE Second: 45
First: N7mysqlpp4NullISsNS_10NullisNullEEE Second: 50
First: N7mysqlpp4NullINS_8DateTimeENS_10NullisNullEEE Second: 43
First: N7mysqlpp4NullINS_4DateENS_10NullisNullEEE Second: 41
First: N7mysqlpp4NullIxNS_10NullisNullEEE Second: 39
First: N7mysqlpp4NullINS_4TimeENS_10NullisNullEEE Second: 42
First: N7mysqlpp4NullIfNS_10NullisNullEEE Second: 35
First: N7mysqlpp4NullIiNS_10NullisNullEEE Second: 34
First: N7mysqlpp4NullIsNS_10NullisNullEEE Second: 33
First: N7mysqlpp4NullIaNS_10NullisNullEEE Second: 32
First: N7mysqlpp4NullIdNS_10NullisNullEEE Second: 36
First: N7mysqlpp3SetISsEE Second: 14
First: Ss Second: 19
First: N7mysqlpp4DateE Second: 10
First: N7mysqlpp4TimeE Second: 11
First: N7mysqlpp8DateTimeE Second: 12
First: a Second: 1
First: h Second: 22
First: s Second: 2
First: t Second: 23
First: i Second: 3
First: j Second: 28
First: x Second: 8
First: y Second: 29
First: f Second: 4
First: d Second: 5


And here is the patch including the test code.

- Chris



Index: software/mysql++/examples/Makefile.am
diff -u software/mysql++/examples/Makefile.am:1.2
software/mysql++/examples/Makefile.am:1.3
--- software/mysql++/examples/Makefile.am:1.2	Wed May 11 02:08:37 2005
+++ software/mysql++/examples/Makefile.am	Wed May 18 10:40:03 2005
@@ -5,12 +5,16 @@
 
 EXTRA_DIST = *.vcproj *.bpf *.bpr *.bpg Makefile.simple
 
-noinst_PROGRAMS = resetdb simple1 custom1 custom2 custom3 custom4 \
+noinst_PROGRAMS = dump_types \
+		resetdb simple1 custom1 custom2 custom3 custom4 \
 		custom5 \
 		complic1 fieldinf1 dbinfo updel load_file cgi_image
 
 noinst_HEADERS = util.h
 
+dump_types_SOURCES = dump_types.cpp
+dump_types_DEPENDENCIES = $(MYSQLPP_LIB)
+
 simple1_SOURCES = simple1.cpp util.cpp
 simple1_DEPENDENCIES = $(MYSQLPP_LIB)
 
Index: software/mysql++/examples/dump_types.cpp
diff -u /dev/null software/mysql++/examples/dump_types.cpp:1.1
--- /dev/null	Wed May 18 10:42:11 2005
+++ software/mysql++/examples/dump_types.cpp	Wed May 18 10:40:03 2005
@@ -0,0 +1,9 @@
+#include <iostream>
+#include <mysql++.h>
+
+int main()
+{
+	mysqlpp::mysql_type_info::dump_lookups(std::cout);
+	return 0;
+}
+
Index: software/mysql++/lib/type_info.cpp
diff -u software/mysql++/lib/type_info.cpp:1.3 software/mysql++/lib/type_info.cpp:1.4
--- software/mysql++/lib/type_info.cpp:1.3	Wed May 11 02:40:10 2005
+++ software/mysql++/lib/type_info.cpp	Wed May 18 10:40:03 2005
@@ -174,5 +174,15 @@
 		return false;
 }
 
+void mysql_type_info::dump_lookups(std::ostream &os)
+{
+	std::map<const std::type_info *, unsigned char, type_info_cmp>::const_iterator i =
lookups._map.begin();
+	for( ; i != lookups._map.end(); i++ ) {
+		os << "First: " << i->first->name()
+		   << " Second: " << static_cast<unsigned int> (i->second)
+		   << endl;
+	}
+}
+
 } // end namespace mysqlpp
 
Index: software/mysql++/lib/type_info.h
diff -u software/mysql++/lib/type_info.h:1.4 software/mysql++/lib/type_info.h:1.5
--- software/mysql++/lib/type_info.h:1.4	Mon May  2 06:25:53 2005
+++ software/mysql++/lib/type_info.h	Wed May 18 10:40:03 2005
@@ -170,6 +170,8 @@
   /// Returns true if the SQL ID of this type is lower than that of
   /// another.  Used by mysqlpp::type_info_cmp when comparing types.
   bool before(mysql_type_info &b) { return num < b.num; }
+
+  static void dump_lookups(std::ostream &os);
 };
 
 inline const mysql_type_info::sql_type_info& mysql_type_info::deref() const

Thread
[PATCH] documentation and type_info fixChris Frey11 May
  • Re: [PATCH] documentation and type_info fixWarren Young12 May
    • Re: [PATCH] documentation and type_info fixWarren Young13 May
    • Re: [PATCH] documentation and type_info fixChris Frey13 May
      • Re: [PATCH] documentation and type_info fixWarren Young13 May
        • Re: [PATCH] documentation and type_info fixChris Frey13 May
        • Re: [PATCH] documentation and type_info fixWarren Young13 May
          • Re: [PATCH] documentation and type_info fixWarren Young13 May
      • Re: [PATCH] documentation and type_info fixChris Frey18 May
        • Re: [PATCH] documentation and type_info fixWarren Young18 May
          • Re: [PATCH] documentation and type_info fixChris Frey18 May