|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include "hsserializer.h" |
|
18 |
|
19 // ----------------------------------------------------------------------------- |
|
20 // |
|
21 // ----------------------------------------------------------------------------- |
|
22 // |
|
23 RBuf8& operator <<(RBuf8& dst, const QVariantHash& src) |
|
24 { |
|
25 QByteArray buffer; |
|
26 QDataStream stream(&buffer, QIODevice::WriteOnly); |
|
27 |
|
28 QT_TRYCATCH_LEAVING(stream << src); |
|
29 const int dataLength(buffer.length()); |
|
30 const unsigned char* dataPtr(reinterpret_cast<const unsigned char*>(buffer.constData())); |
|
31 if( dst.MaxLength() < dataLength ) { |
|
32 dst.ReAllocL(dataLength); |
|
33 } |
|
34 dst.Copy(dataPtr, dataLength); |
|
35 return dst; |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 QVariantHash& operator <<(QVariantHash& dst, const TDesC8& src) |
|
43 { |
|
44 QByteArray buffer( QByteArray::fromRawData(reinterpret_cast<const char*>(src.Ptr()), |
|
45 src.Length()) ); |
|
46 |
|
47 QDataStream stream(&buffer, QIODevice::ReadOnly); |
|
48 QT_TRYCATCH_LEAVING(stream >> dst); |
|
49 return dst; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 RBuf8& operator <<(RBuf8& dst, const QList<QVariantHash>& src) |
|
57 { |
|
58 QByteArray buffer; |
|
59 QDataStream stream(&buffer, QIODevice::WriteOnly); |
|
60 |
|
61 QT_TRYCATCH_LEAVING(stream << src); |
|
62 |
|
63 if( dst.MaxLength() < buffer.length() ) { |
|
64 dst.ReAllocL(buffer.length()); |
|
65 } |
|
66 dst.Copy(reinterpret_cast<const TUint8*>(buffer.data()), buffer.length()); |
|
67 return dst; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 QList<QVariantHash>& operator <<(QList<QVariantHash>& dst, const TDesC8& src) |
|
75 { |
|
76 QByteArray buffer(QByteArray::fromRawData(reinterpret_cast<const char*>(src.Ptr()), |
|
77 src.Length())); |
|
78 |
|
79 QDataStream stream(&buffer, QIODevice::ReadOnly); |
|
80 QT_TRYCATCH_LEAVING(stream >> dst); |
|
81 return dst; |
|
82 } |