ncdengine/engine/inc/catalogskeyvaluepair.h
changeset 4 32704c33136d
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     1 /*
       
     2 * Copyright (c) 2006 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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CATALOGSKEYVALUEPAIR_H
       
    20 #define C_CATALOGSKEYVALUEPAIR_H
       
    21 
       
    22 // Includes
       
    23 #include <e32base.h>
       
    24 
       
    25 class RReadStream;
       
    26 class RWriteStream;
       
    27 
       
    28 /**
       
    29  * Key - Value pair
       
    30  */
       
    31 class CCatalogsKeyValuePair : public CBase
       
    32     {
       
    33 public: // Construction & destruction
       
    34 
       
    35     /**
       
    36      * Static constructor.
       
    37      *
       
    38      * @param   aKey    Key for the pair.
       
    39      * @param   aValue  Valuefor the pair.
       
    40      *
       
    41      * @return  The created object.
       
    42      */
       
    43     static CCatalogsKeyValuePair* NewL( const TDesC16& aKey, 
       
    44         const TDesC16& aValue );
       
    45 
       
    46     
       
    47     /**
       
    48      * Static constructor. Leaves a pointer on the cleanup stack.
       
    49      *
       
    50      * @param   aKey    Key for the pair.
       
    51      * @param   aValue  Valuefor the pair.
       
    52      *
       
    53      * @return  The created object.
       
    54      */
       
    55     static CCatalogsKeyValuePair* NewLC( const TDesC16& aKey, 
       
    56         const TDesC16& aValue );
       
    57 
       
    58     
       
    59     /**
       
    60      * Static constructor.
       
    61      *
       
    62      * @param   aKey    Key for the pair.
       
    63      * @param   aValue  Valuefor the pair.
       
    64      *
       
    65      * @return  The created object.
       
    66      */
       
    67     static CCatalogsKeyValuePair* NewL( const TDesC8& aKey, 
       
    68         const TDesC8& aValue );
       
    69 
       
    70     
       
    71     /**
       
    72      * Static constructor. Leaves a pointer on the cleanup stack.
       
    73      *
       
    74      * @param   aKey    Key for the pair.
       
    75      * @param   aValue  Valuefor the pair.
       
    76      *
       
    77      * @return  The created object.
       
    78      */
       
    79     static CCatalogsKeyValuePair* NewLC( const TDesC8& aKey, 
       
    80         const TDesC8& aValue );
       
    81 
       
    82 
       
    83     /**
       
    84      * Creates a copy of the key-value -pair
       
    85      * 
       
    86      * @param aOther Pair to copy
       
    87      * @return A copy of the given pair
       
    88      */
       
    89     static CCatalogsKeyValuePair* NewL( const CCatalogsKeyValuePair& aOther );
       
    90     
       
    91 
       
    92     /**
       
    93      * Creates a copy of the key-value -pair and pushes it to the cleanup stack
       
    94      * 
       
    95      * @param aOther Pair to copy
       
    96      * @return A copy of the given pair
       
    97      */
       
    98     static CCatalogsKeyValuePair* NewLC( 
       
    99         const CCatalogsKeyValuePair& aOther );
       
   100 
       
   101 
       
   102     /**
       
   103      * Internalizes a key-value -pair from a stream
       
   104      * 
       
   105      * @param aStream Source stream
       
   106      * @return A pair
       
   107      */
       
   108     static CCatalogsKeyValuePair* NewL( RReadStream& aStream );
       
   109     
       
   110     /**
       
   111      * Internalizes a key-value -pair from a stream and pushes it to the
       
   112      * cleanup stack.
       
   113      * 
       
   114      * @param aStream Source stream
       
   115      * @return A pair
       
   116      */
       
   117     static CCatalogsKeyValuePair* NewLC( RReadStream& aStream );
       
   118 
       
   119     /**
       
   120      * Destructor.
       
   121      */
       
   122     ~CCatalogsKeyValuePair();
       
   123 
       
   124 
       
   125 private:    // Construction & destruction
       
   126     
       
   127     CCatalogsKeyValuePair();
       
   128     
       
   129     void ConstructL( const TDesC16& aKey, const TDesC16& aValue );
       
   130     void ConstructL( const TDesC8& aKey, const TDesC8& aValue );
       
   131 
       
   132 
       
   133 public:     // New methods
       
   134 
       
   135     /**
       
   136      * Returns the key of the pair.
       
   137      *
       
   138      * @return  Reference descriptor containing the key.
       
   139      */
       
   140     const TDesC8& Key() const;
       
   141     
       
   142     
       
   143     /**
       
   144      * Returns the value of the pair.
       
   145      *
       
   146      * @return  Reference descriptor containing the value.
       
   147      */
       
   148     const TDesC8& Value() const;
       
   149 
       
   150 
       
   151     /**
       
   152      * Returns the key of the pair.
       
   153      *
       
   154      * @return  Reference descriptor containing the key.
       
   155      */
       
   156     HBufC* KeyLC() const;
       
   157 
       
   158     /**
       
   159      * Returns the key of the pair.
       
   160      *
       
   161      * @return  Reference descriptor containing the key.
       
   162      */
       
   163     HBufC* KeyL() const;
       
   164 
       
   165 
       
   166     /**
       
   167      * Returns the value of the pair.
       
   168      *
       
   169      * @return  Reference descriptor containing the value.
       
   170      */
       
   171     HBufC* ValueLC() const;
       
   172     
       
   173     
       
   174     /**
       
   175      * Returns the value of the pair.
       
   176      *
       
   177      * @return  Reference descriptor containing the value.
       
   178      */
       
   179     HBufC* ValueL() const;
       
   180 
       
   181     /**
       
   182      * Comparison method. Compares the keys of two pairs to 
       
   183      * determine equivalence.
       
   184      *
       
   185      * @return  Boolean, ETrue if pairs match.
       
   186      */
       
   187     static TBool MatchByKey( const CCatalogsKeyValuePair& aFirst, 
       
   188                              const CCatalogsKeyValuePair& aSecond );
       
   189                              
       
   190                              
       
   191     /**
       
   192      * Externalize
       
   193      *
       
   194      * @param aStream Target stream
       
   195      */                             
       
   196     void ExternalizeL( RWriteStream& aStream ) const;
       
   197     
       
   198     
       
   199     /**
       
   200      * Internalize
       
   201      *
       
   202      * @param aStream Source stream
       
   203      */
       
   204     void InternalizeL( RReadStream& aStream );                             
       
   205 
       
   206 private:    // Data
       
   207 
       
   208     HBufC8* iKey;
       
   209     HBufC8* iValue;
       
   210     };
       
   211 
       
   212 #endif // C_CATALOGSKEYVALUEPAIR_H
       
   213