From 39a95f6939417ebc5d8e716ca1664a1da1fc722c Mon Sep 17 00:00:00 2001
From: znone <glyc@sina.com.cn>
Date: Thu, 09 Feb 2017 12:04:19 +0000
Subject: [PATCH] 根据回调函数参数推断绑定的数据类型。

---
 test/TestMysql.cpp |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/test/TestMysql.cpp b/test/TestMysql.cpp
index 68dcb6f..53330c1 100644
--- a/test/TestMysql.cpp
+++ b/test/TestMysql.cpp
@@ -17,6 +17,12 @@
 	{
 		memset(this, 0, sizeof(TestMysqlRecord));
 	}
+
+	void print() const
+	{
+		printf("ID=\"%d\", Name=\"%s\"\n",
+			id, name);
+	}
 };
 
 namespace qtl
@@ -57,11 +63,9 @@
 	try
 	{
 		db.query("select 0, 'hello world' from dual",
-			std::tuple<uint32_t, std::string>(),
 			[](uint32_t i, const std::string& str) {
 				printf("0=\"%d\", 'hello world'=\"%s\"\n",
 					i, str.data());
-				return true;
 		});
 	}
 	catch(qtl::mysql::error& e)
@@ -77,21 +81,20 @@
 
 	try
 	{
-		db.query("select * from test where id=?", 0,
-			id, std::tuple<uint32_t, std::string, qtl::mysql::time>(),
-			[](uint32_t id, const std::string& name, qtl::mysql::time& create_time) {
+		db.query("select * from test where id=?", id, 
+			[](const qtl::indicator<uint32_t>& id, const std::string& name, const qtl::mysql::time& create_time) {
 				printf("ID=\"%d\", Name=\"%s\"\n",
-					id, name.data());
-				return true;
+					id.data, name.data());
 		});
 
-		db.query("select * from test where id=?", 0,
-			id, TestMysqlRecord(),
-			[](TestMysqlRecord& record) {
+		db.query("select * from test where id=?", id,
+			[](const TestMysqlRecord& record) {
 				printf("ID=\"%d\", Name=\"%s\"\n",
 					record.id, record.name);
-				return true;
 		});
+
+		db.query("select * from test where id=?", id, 
+			&TestMysqlRecord::print);
 	}
 	catch(qtl::mysql::error& e)
 	{

--
Gitblit v1.9.3