89
|
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 |
*
|
92
|
14 |
* Description:
|
89
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "hsserializer.h"
|
93
|
18 |
#include <s32mem.h>
|
89
|
19 |
// -----------------------------------------------------------------------------
|
|
20 |
//
|
|
21 |
// -----------------------------------------------------------------------------
|
|
22 |
//
|
92
|
23 |
RBuf8 &operator <<(RBuf8 &dst, const QVariantHash &src)
|
89
|
24 |
{
|
|
25 |
QByteArray buffer;
|
|
26 |
QDataStream stream(&buffer, QIODevice::WriteOnly);
|
92
|
27 |
|
89
|
28 |
QT_TRYCATCH_LEAVING(stream << src);
|
92
|
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);
|
89
|
33 |
}
|
92
|
34 |
dst.Copy(dataPtr, dataLength);
|
89
|
35 |
return dst;
|
|
36 |
}
|
|
37 |
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
//
|
92
|
42 |
QVariantHash &operator <<(QVariantHash &dst, const TDesC8 &src)
|
89
|
43 |
{
|
92
|
44 |
QByteArray buffer(QByteArray::fromRawData(reinterpret_cast<const char *>(src.Ptr()),
|
|
45 |
src.Length()) );
|
|
46 |
|
89
|
47 |
QDataStream stream(&buffer, QIODevice::ReadOnly);
|
|
48 |
QT_TRYCATCH_LEAVING(stream >> dst);
|
|
49 |
return dst;
|
|
50 |
}
|
92
|
51 |
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
QList<QVariantHash>& operator <<(QList<QVariantHash>& dst, const TDesC8 &src)
|
|
57 |
{
|
93
|
58 |
dst.clear();
|
|
59 |
|
|
60 |
QVariantHash item;
|
|
61 |
TRAP_IGNORE(
|
|
62 |
RDesReadStream srcStream(src);
|
|
63 |
int numOfItems(srcStream.ReadInt32L());
|
|
64 |
int bufferSize;
|
|
65 |
|
|
66 |
RBuf8 tmpBuff;
|
|
67 |
CleanupClosePushL(tmpBuff);
|
|
68 |
for (int iter(0); iter < numOfItems; ++iter) {
|
|
69 |
bufferSize = srcStream.ReadInt32L();
|
|
70 |
if (tmpBuff.MaxLength() < bufferSize) {
|
|
71 |
tmpBuff.ReAllocL(bufferSize);
|
|
72 |
}
|
|
73 |
item.clear();
|
|
74 |
if (0 < bufferSize) {
|
|
75 |
srcStream.ReadL(tmpBuff, bufferSize);
|
|
76 |
item << tmpBuff;
|
|
77 |
}
|
|
78 |
dst.append(item);
|
|
79 |
}
|
|
80 |
CleanupStack::PopAndDestroy(&tmpBuff));
|
92
|
81 |
return dst;
|
|
82 |
}
|