Changeset View
Changeset View
Standalone View
Standalone View
src/drivers/sqlite/SqliteCursor.cpp
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 84 | //! @todo support for UTF-16 | |||
---|---|---|---|---|---|
106 | } else { | 106 | } else { | ||
107 | return QVariant(); //!< @todo | 107 | return QVariant(); //!< @todo | ||
108 | } | 108 | } | ||
109 | } else if (type == SQLITE_INTEGER) { | 109 | } else if (type == SQLITE_INTEGER) { | ||
110 | const KDbField::Type t = f->type(); // cache: evaluating type of expressions can be expensive | 110 | const KDbField::Type t = f->type(); // cache: evaluating type of expressions can be expensive | ||
111 | if (t == KDbField::BigInteger) { | 111 | if (t == KDbField::BigInteger) { | ||
112 | return QVariant(qint64(sqlite3_column_int64(prepared_st_handle, i))); | 112 | return QVariant(qint64(sqlite3_column_int64(prepared_st_handle, i))); | ||
113 | } else if (KDbField::isIntegerType(t)) { | 113 | } else if (KDbField::isIntegerType(t)) { | ||
114 | return QVariant(sqlite3_column_int(prepared_st_handle, i)); | 114 | const int intVal = sqlite3_column_int(prepared_st_handle, i); | ||
115 | return f->isUnsigned() ? QVariant(static_cast<uint>(intVal)) : QVariant(intVal); | ||||
115 | } else if (t == KDbField::Boolean) { | 116 | } else if (t == KDbField::Boolean) { | ||
116 | return sqlite3_column_int(prepared_st_handle, i) != 0; | 117 | return sqlite3_column_int(prepared_st_handle, i) != 0; | ||
117 | } else if (KDbField::isFPNumericType(t)) { //WEIRD, YEAH? | 118 | } else if (KDbField::isFPNumericType(t)) { //WEIRD, YEAH? | ||
118 | return QVariant(double(sqlite3_column_int(prepared_st_handle, i))); | 119 | return QVariant(double(sqlite3_column_int(prepared_st_handle, i))); | ||
119 | } else { | 120 | } else { | ||
120 | return QVariant(); //!< @todo | 121 | return QVariant(); //!< @todo | ||
121 | } | 122 | } | ||
122 | } else if (type == SQLITE_FLOAT) { | 123 | } else if (type == SQLITE_FLOAT) { | ||
123 | const KDbField::Type t = f->type(); // cache: evaluating type of expressions can be expensive | 124 | const KDbField::Type t = f->type(); // cache: evaluating type of expressions can be expensive | ||
124 | if (KDbField::isFPNumericType(t)) { | 125 | if (KDbField::isFPNumericType(t)) { | ||
125 | return QVariant(sqlite3_column_double(prepared_st_handle, i)); | 126 | return QVariant(sqlite3_column_double(prepared_st_handle, i)); | ||
126 | } else if (t == KDbField::BigInteger) { | 127 | } else if (t == KDbField::BigInteger) { | ||
127 | return QVariant(qint64(sqlite3_column_int64(prepared_st_handle, i))); | 128 | return QVariant(qint64(sqlite3_column_int64(prepared_st_handle, i))); | ||
128 | } else if (KDbField::isIntegerType(t)) { | 129 | } else if (KDbField::isIntegerType(t)) { | ||
129 | return QVariant(int(sqlite3_column_double(prepared_st_handle, i))); | 130 | const double doubleVal = sqlite3_column_double(prepared_st_handle, i); | ||
131 | return f->isUnsigned() ? QVariant(static_cast<uint>(doubleVal)) : QVariant(static_cast<int>(doubleVal)); | ||||
130 | } else { | 132 | } else { | ||
131 | return QVariant(); //!< @todo | 133 | return QVariant(); //!< @todo | ||
132 | } | 134 | } | ||
133 | } else if (type == SQLITE_BLOB) { | 135 | } else if (type == SQLITE_BLOB) { | ||
134 | if (f && f->type() == KDbField::BLOB) { | 136 | if (f && f->type() == KDbField::BLOB) { | ||
135 | //! @todo efficient enough? | 137 | //! @todo efficient enough? | ||
136 | return QByteArray((const char*)sqlite3_column_blob(prepared_st_handle, i), | 138 | return QByteArray((const char*)sqlite3_column_blob(prepared_st_handle, i), | ||
137 | sqlite3_column_bytes(prepared_st_handle, i)); | 139 | sqlite3_column_bytes(prepared_st_handle, i)); | ||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |