activityfw/activitydatabase/s60/src/hsserializer.cpp
changeset 92 782e3408c2ab
parent 90 0e41c72311af
child 93 82b66994846c
equal deleted inserted replaced
91:a6d55a2e75be 92:782e3408c2ab
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 #include "hsserializer.h"
    17 #include "hsserializer.h"
    18 
    18 
    19 // -----------------------------------------------------------------------------
    19 // -----------------------------------------------------------------------------
    20 //
    20 //
    21 // -----------------------------------------------------------------------------
    21 // -----------------------------------------------------------------------------
    22 //
    22 //
    23 RBuf8& operator <<(RBuf8& dst, const QVariantHash& src)
    23 RBuf8 &operator <<(RBuf8 &dst, const QPixmap &src)
    24 {
    24 {
    25     QByteArray buffer;
    25     QByteArray buffer;
    26     QDataStream stream(&buffer, QIODevice::WriteOnly);
    26     QDataStream stream(&buffer, QIODevice::WriteOnly);
    27     
    27 
    28     QT_TRYCATCH_LEAVING(stream << src);
    28     QT_TRYCATCH_LEAVING(stream << src);
    29     const int dataLength(buffer.length());
    29     const int dataLength(buffer.length());
    30     const unsigned char* dataPtr(reinterpret_cast<const unsigned char*>(buffer.constData()));
    30     const unsigned char *dataPtr(reinterpret_cast<const unsigned char *>(buffer.constData()));
    31     if( dst.MaxLength() < dataLength ) {
    31     if (dst.MaxLength() < dataLength) {
    32         dst.ReAllocL(dataLength);
    32         dst.ReAllocL(dataLength);
    33     }
    33     }
    34     dst.Copy(dataPtr, dataLength);
    34     dst.Copy(dataPtr, dataLength);
    35     return dst;
    35     return dst;
    36 }
    36 }
    37 
    37 
    38 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    39 //
    39 //
    40 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    41 //
    41 //
    42 QVariantHash& operator <<(QVariantHash& dst, const TDesC8& src)
    42 QPixmap &operator <<(QPixmap &dst, const TDesC8 &src)
    43 {
    43 {
    44     QByteArray buffer( QByteArray::fromRawData(reinterpret_cast<const char*>(src.Ptr()), 
    44     QByteArray buffer(QByteArray::fromRawData(reinterpret_cast<const char *>(src.Ptr()),
    45                                                src.Length()) );
    45                                               src.Length()) );
    46     
    46 
    47     QDataStream stream(&buffer, QIODevice::ReadOnly);
    47     QDataStream stream(&buffer, QIODevice::ReadOnly);
    48     QT_TRYCATCH_LEAVING(stream >> dst);
    48     QT_TRYCATCH_LEAVING(stream >> dst);
    49     return dst;
    49     return dst;
    50 }
    50 }
    51 
    51 
    52 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    53 //
    53 //
    54 // -----------------------------------------------------------------------------
    54 // -----------------------------------------------------------------------------
    55 //
    55 //
    56 RBuf8& operator <<(RBuf8& dst, const QList<QVariantHash>& src)
    56 RBuf8 &operator <<(RBuf8 &dst, const QVariantHash &src)
    57 {
    57 {
    58     QByteArray buffer;
    58     QByteArray buffer;
    59     QDataStream stream(&buffer, QIODevice::WriteOnly);
    59     QDataStream stream(&buffer, QIODevice::WriteOnly);
    60     
    60 
    61     QT_TRYCATCH_LEAVING(stream << src);
    61     QT_TRYCATCH_LEAVING(stream << src);
    62     
    62     const int dataLength(buffer.length());
    63     if( dst.MaxLength() < buffer.length() ) {
    63     const unsigned char *dataPtr(reinterpret_cast<const unsigned char *>(buffer.constData()));
    64         dst.ReAllocL(buffer.length());
    64     if (dst.MaxLength() < dataLength) {
       
    65         dst.ReAllocL(dataLength);
    65     }
    66     }
    66     dst.Copy(reinterpret_cast<const TUint8*>(buffer.data()), buffer.length());
    67     dst.Copy(dataPtr, dataLength);
    67     return dst;
    68     return dst;
    68 }
    69 }
    69 
    70 
    70 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    71 //
    72 //
    72 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    73 //
    74 //
    74 QList<QVariantHash>& operator <<(QList<QVariantHash>& dst, const TDesC8& src)
    75 QVariantHash &operator <<(QVariantHash &dst, const TDesC8 &src)
    75 {
    76 {
    76     QByteArray buffer(QByteArray::fromRawData(reinterpret_cast<const char*>(src.Ptr()), 
    77     QByteArray buffer(QByteArray::fromRawData(reinterpret_cast<const char *>(src.Ptr()),
    77                                               src.Length()));
    78                                                src.Length()) );
    78     
    79 
    79     QDataStream stream(&buffer, QIODevice::ReadOnly);
    80     QDataStream stream(&buffer, QIODevice::ReadOnly);
    80     QT_TRYCATCH_LEAVING(stream >> dst);
    81     QT_TRYCATCH_LEAVING(stream >> dst);
    81     return dst;
    82     return dst;
    82 }
    83 }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    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)
       
   108 {
       
   109     QByteArray buffer(QByteArray::fromRawData(reinterpret_cast<const char *>(src.Ptr()),
       
   110                                               src.Length()));
       
   111 
       
   112     QDataStream stream(&buffer, QIODevice::ReadOnly);
       
   113     QT_TRYCATCH_LEAVING(stream >> dst);
       
   114     return dst;
       
   115 }