aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-03-23 18:15:28 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-03-23 18:15:28 +0200
commitcb23b26f09cdc4f2da380dac7bd43327839526de (patch)
treeb70c4ddd9d4137c2514844f02a57fcac39307314
parent4be822c6c918e02578b55947486d5a57784bea71 (diff)
Persist and load QString as UTF8 string
-rw-r--r--odb/qt/mysql/qstring-traits.hxx25
1 files changed, 13 insertions, 12 deletions
diff --git a/odb/qt/mysql/qstring-traits.hxx b/odb/qt/mysql/qstring-traits.hxx
index 5b0191a..d179972 100644
--- a/odb/qt/mysql/qstring-traits.hxx
+++ b/odb/qt/mysql/qstring-traits.hxx
@@ -10,16 +10,17 @@
#include <cstddef> // std::size_t
-#include <odb/mysql/traits.hxx>
-#include <odb/details/buffer.hxx>
-
#include <QString>
+#include <odb/details/buffer.hxx>
+#include <odb/mysql/traits.hxx>
+#include <odb/qt/details/export.hxx>
+
namespace odb
{
namespace mysql
{
- class LIBODB_MYSQL_EXPORT qstring_value_traits
+ class LIBODB_QT_EXPORT qstring_value_traits
{
public:
typedef QString value_type;
@@ -33,7 +34,7 @@ namespace odb
bool is_null)
{
if (!is_null)
- v = QString::fromLocal8Bit (b.data (), n);
+ v = QString::fromUtf8 (b.data (), n);
else
v.clear ();
}
@@ -46,37 +47,37 @@ namespace odb
{
is_null = false;
- const std::string& s (v.toStdString ());
- n = s.size ();
+ const QByteArray& a (v.toUtf8 ());
+ n = a.size ();
if (n > b.capacity ())
b.capacity (n);
if (n != 0)
- memcpy (b.data (), s.data (), n);
+ memcpy (b.data (), a.data (), n);
}
};
template <>
- struct LIBODB_MYSQL_EXPORT default_value_traits<
+ struct LIBODB_QT_EXPORT default_value_traits<
QString, details::buffer, id_string>: qstring_value_traits
{
};
template <>
- struct LIBODB_MYSQL_EXPORT default_value_traits<
+ struct LIBODB_QT_EXPORT default_value_traits<
QString, details::buffer, id_decimal>: qstring_value_traits
{
};
template <>
- struct LIBODB_MYSQL_EXPORT default_value_traits<
+ struct LIBODB_QT_EXPORT default_value_traits<
QString, details::buffer, id_enum>: qstring_value_traits
{
};
template <>
- struct LIBODB_MYSQL_EXPORT default_value_traits<
+ struct LIBODB_QT_EXPORT default_value_traits<
QString, details::buffer, id_set>: qstring_value_traits
{
};