diff options
-rw-r--r-- | src/bson/bson.cpp | 2 | ||||
-rw-r--r-- | src/bson/bson_p.h | 3 | ||||
-rw-r--r-- | src/bson/qt-bson.cpp | 18 |
3 files changed, 11 insertions, 12 deletions
diff --git a/src/bson/bson.cpp b/src/bson/bson.cpp index e60decc..09eaa46 100644 --- a/src/bson/bson.cpp +++ b/src/bson/bson.cpp @@ -89,7 +89,7 @@ void bson_print_raw( const char * data , int depth ){ case bson_double: printf( "%f" , bson_iterator_double( &i ) ); break; case bson_bool: printf( "%s" , bson_iterator_bool( &i ) ? "true" : "false" ); break; case bson_string: printf( "%s" , bson_iterator_string( &i ) ); break; - case bson_utf16: printf( "%s" , bson_iterator_utf16( &i ) ); break; + case bson_utf16: printf( "%ls" , (wchar_t *) bson_iterator_utf16( &i ) ); break; case bson_null: printf( "null" ); break; case bson_timestamp: ts = bson_iterator_timestamp( &i ); diff --git a/src/bson/bson_p.h b/src/bson/bson_p.h index 352746e..e8295d3 100644 --- a/src/bson/bson_p.h +++ b/src/bson/bson_p.h @@ -43,8 +43,7 @@ typedef enum { bson_int = 16, bson_timestamp = 17, bson_long = 18, - bson_utf16 = 19, - bson_object_utf16 = 20 + bson_utf16 = 19 } bson_type; typedef enum bson_bool { diff --git a/src/bson/qt-bson.cpp b/src/bson/qt-bson.cpp index 386062b..da7315c 100644 --- a/src/bson/qt-bson.cpp +++ b/src/bson/qt-bson.cpp @@ -95,7 +95,7 @@ BsonObject::BsonObject(const QVariantList &v) { d->mBsonType = bson_array; for (int i = 0; i < v.size(); i++) { - insert(QByteArray::number(i), v[i]); + insert(QString::number(i), v[i]); } finish(); } @@ -133,7 +133,7 @@ void BsonObject::finish() bson_iterator_init(&j, bson.data); while (bson_iterator_next(&j) != bson_eoo) { const char *jkey = bson_iterator_key(&j); - QString s(jkey); + QString s = QString::fromUtf8(jkey); if (newKeys.contains(s)) { qCritical() << "BsonObject::finish" << "duplicate key" << s; } @@ -149,7 +149,7 @@ void BsonObject::finish() bson_iterator_init(&i, d->mBson.data); while (bson_iterator_next(&i) != bson_eoo) { const char *ikey = bson_iterator_key(&i); - QString s(ikey); + QString s = QString::fromUtf8(ikey); if (newKeys.contains(s)) { continue; } @@ -175,10 +175,10 @@ QVariantMap BsonObject::toMap() while ((bt = bson_iterator_next(&it)) && (bt != bson_eoo)) { const char *ckey = bson_iterator_key(&it); QVariant v = elementToVariant(bt, &it); - - if (map.contains(QByteArray(ckey))) + QString s = QString::fromUtf8(ckey); + if (map.contains(s)) qDebug() << "BsonObject::toMap" << "duplicate key" << ckey; - map.insert(QByteArray(ckey), v); + map.insert(s, v); } return map; } @@ -229,7 +229,7 @@ QList<QString> BsonObject::keys() bson_iterator_init(&it, d->mBson.data); bson_type bt; while ((bt = bson_iterator_next(&it)) && (bt != bson_eoo)) { - keys.append(QByteArray(bson_iterator_key(&it))); + keys.append(QString::fromUtf8(bson_iterator_key(&it))); } return keys; } @@ -370,7 +370,7 @@ BsonObject &BsonObject::insert(const QString &key, const char *s) finish(); } d->mAddedKeys.insert(key); - return insert(key, QString(s)); + return insert(key, QString::fromUtf8(s)); } BsonObject &BsonObject::insert(const QString &key, const QString &v) @@ -563,7 +563,7 @@ QVariant BsonObject::value(const QString &key) case bson_eoo: // when attempting to fetch a value from an empty object return QVariant(); default: - qCritical() << QString("Converting BsonObject element of type %1 to QVariant()").arg(t); + qCritical() << QString::fromLatin1("Converting BsonObject element of type %1 to QVariant()").arg(t); return QVariant(); } } |