activityfw/activitydatabase/s60/src/hsserializer.cpp
changeset 94 dbb8300717f7
parent 93 82b66994846c
child 98 d2f833ab7940
equal deleted inserted replaced
93:82b66994846c 94:dbb8300717f7
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 #include "hsserializer.h"
    17 #include "hsserializer.h"
    18 #include <s32mem.h>
    18 #include <s32mem.h>
    19 // -----------------------------------------------------------------------------
       
    20 //
       
    21 // -----------------------------------------------------------------------------
       
    22 //
       
    23 RBuf8 &operator <<(RBuf8 &dst, const QPixmap &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 QPixmap &operator <<(QPixmap &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 // -----------------------------------------------------------------------------
    19 // -----------------------------------------------------------------------------
    53 //
    20 //
    54 // -----------------------------------------------------------------------------
    21 // -----------------------------------------------------------------------------
    55 //
    22 //
    56 RBuf8 &operator <<(RBuf8 &dst, const QVariantHash &src)
    23 RBuf8 &operator <<(RBuf8 &dst, const QVariantHash &src)
    84 
    51 
    85 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    86 //
    53 //
    87 // -----------------------------------------------------------------------------
    54 // -----------------------------------------------------------------------------
    88 //
    55 //
    89 RBuf8 &operator <<(RBuf8 &dst, const QList<QVariantHash>& src)
       
    90 {
       
    91     QByteArray buffer;
       
    92     QDataStream stream(&buffer, QIODevice::WriteOnly);
       
    93 
       
    94     QT_TRYCATCH_LEAVING(stream << src);
       
    95 
       
    96     if (dst.MaxLength() < buffer.length()) {
       
    97         dst.ReAllocL(buffer.length());
       
    98     }
       
    99     dst.Copy(reinterpret_cast<const TUint8 *>(buffer.data()), buffer.length());
       
   100     return dst;
       
   101 }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 QList<QVariantHash>& operator <<(QList<QVariantHash>& dst, const TDesC8 &src)
    56 QList<QVariantHash>& operator <<(QList<QVariantHash>& dst, const TDesC8 &src)
   108 {
    57 {
   109     dst.clear();
    58     dst.clear();
   110     
    59     
   111     QVariantHash item;
    60     QVariantHash item;