mysqlxx: development.

This commit is contained in:
Alexey Milovidov 2011-03-15 21:14:05 +00:00
parent 7b05734af8
commit 5f180b071c
4 changed files with 47 additions and 21 deletions

View File

@ -34,9 +34,9 @@ private:
if (length < 10)
throw Exception("Cannot parse Date: " + std::string(s, length));
m_year = s[0] * 1000 + s[1] * 100 + s[2] * 10 + s[3];
m_month = s[5] * 10 + s[6];
m_day = s[8] * 10 + s[9];
m_year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
m_month = (s[5] - '0') * 10 + (s[6] - '0');
m_day = (s[8] - '0') * 10 + (s[9] - '0');
}
public:

View File

@ -39,13 +39,13 @@ private:
if (length < 19)
throw Exception("Cannot parse DateTime: " + std::string(s, length));
m_year = s[0] * 1000 + s[1] * 100 + s[2] * 10 + s[3];
m_month = s[5] * 10 + s[6];
m_day = s[8] * 10 + s[9];
m_year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
m_month = (s[5] - '0') * 10 + (s[6] - '0');
m_day = (s[8] - '0') * 10 + (s[9] - '0');
m_hour = s[11] * 10 + s[12];
m_minute = s[14] * 10 + s[15];
m_second = s[17] * 10 + s[18];
m_hour = (s[11] - '0') * 10 + (s[12] - '0');
m_minute = (s[14] - '0') * 10 + (s[15] - '0');
m_second = (s[17] - '0') * 10 + (s[18] - '0');
}
public:

View File

@ -244,19 +244,19 @@ private:
if (m_length == 10)
{
return date_lut.makeDate(
m_data[0] * 1000 + m_data[1] * 100 + m_data[2] * 10 + m_data[3],
m_data[5] * 10 + m_data[6],
m_data[8] * 10 + m_data[9]);
(m_data[0] - '0') * 1000 + (m_data[1] - '0') * 100 + (m_data[2] - '0') * 10 + (m_data[3] - '0'),
(m_data[5] - '0') * 10 + (m_data[6] - '0'),
(m_data[8] - '0') * 10 + (m_data[9] - '0'));
}
else
{
return date_lut.makeDateTime(
m_data[0] * 1000 + m_data[1] * 100 + m_data[2] * 10 + m_data[3],
m_data[5] * 10 + m_data[6],
m_data[8] * 10 + m_data[9],
m_data[11] * 10 + m_data[12],
m_data[14] * 10 + m_data[15],
m_data[17] * 10 + m_data[18]);
(m_data[0] - '0') * 1000 + (m_data[1] - '0') * 100 + (m_data[2] - '0') * 10 + (m_data[3] - '0'),
(m_data[5] - '0') * 10 + (m_data[6] - '0'),
(m_data[8] - '0') * 10 + (m_data[9] - '0'),
(m_data[11] - '0') * 10 + (m_data[12] - '0'),
(m_data[14] - '0') * 10 + (m_data[15] - '0'),
(m_data[17] - '0') * 10 + (m_data[18] - '0'));
}
}
@ -267,9 +267,9 @@ private:
if (m_length == 10 || m_length == 19)
{
return date_lut.makeDate(
m_data[0] * 1000 + m_data[1] * 100 + m_data[2] * 10 + m_data[3],
m_data[5] * 10 + m_data[6],
m_data[8] * 10 + m_data[9]);
(m_data[0] - '0') * 1000 + (m_data[1] - '0') * 100 + (m_data[2] - '0') * 10 + (m_data[3] - '0'),
(m_data[5] - '0') * 10 + (m_data[6] - '0'),
(m_data[8] - '0') * 10 + (m_data[9] - '0'));
}
else
throw Exception("Cannot parse Date: " + getString());

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <mysqlxx/mysqlxx.h>
int main(int argc, char ** argv)
{
mysqlxx::Connection connection("", "127.0.0.1", "root", "qwerty", 3306);
std::cerr << "Connected." << std::endl;
mysqlxx::Query query = connection.query();
query << "SELECT 1 x, '2010-01-01 01:01:01' d";
mysqlxx::UseQueryResult result = query.use();
std::cerr << "use() called." << std::endl;
while (mysqlxx::Row row = result.fetch())
{
std::cerr << "Fetched row." << std::endl;
std::cerr << row[0] << ", " << row["x"] << std::endl;
std::cerr << row[1] << ", " << row["d"]
<< ", " << row[1].getDate()
<< ", " << row[1].getDateTime()
<< std::endl;
}
return 0;
}