phonebookui/Phonebook/BCardEng/inc/CBCardFieldUidMapping.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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 *    vCard data field <-> UID mapping class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CBCARDFIELDUIDMAPPING_H__
       
    21 #define __CBCARDFIELDUIDMAPPING_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>    // CBase
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class TResourceReader;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32  * vCard data field <-> UID mapping.
       
    33  */
       
    34 NONSHARABLE_CLASS(CBCardFieldUidMapping) : 
       
    35         public CBase
       
    36     {
       
    37     public:  // Constructors and destructor
       
    38         /**
       
    39          * Creates a new instance of this class and initializes it from 
       
    40          * a PBK_NAME_UID_MAPPING resource.
       
    41 		 * @param aReader reference to resources
       
    42          */
       
    43         static CBCardFieldUidMapping* NewL(TResourceReader& aReader);
       
    44 
       
    45         /**
       
    46          * Destructor.
       
    47          */
       
    48         ~CBCardFieldUidMapping();
       
    49 
       
    50     public:  // Types
       
    51         /**
       
    52          * vCard data field structure.
       
    53          */
       
    54         struct TVcardField
       
    55             {
       
    56             /// vCard property name
       
    57             TPtrC8 iName;
       
    58             /// vCard property sub field index
       
    59             TInt  iFieldIndex;
       
    60 
       
    61             /// Default constructor
       
    62             TVcardField();
       
    63             /// Constructor
       
    64             TVcardField(const TDesC8& aName, TInt aFieldIndex=0);
       
    65             };
       
    66 
       
    67         /**
       
    68          * vCard data field <-> UID mapping.
       
    69          */
       
    70         struct TMapping
       
    71             {
       
    72             TVcardField iVcardField;
       
    73             TUid iUid;
       
    74             };
       
    75 
       
    76     public:  // Interface
       
    77         /**
       
    78          * Returns the number of mappings held by this object.
       
    79          */
       
    80         TInt Count() const;
       
    81 
       
    82         /**
       
    83          * Returns the aIndex:th mapping held by this object.
       
    84          */
       
    85         TMapping operator[](TInt aIndex) const;
       
    86 
       
    87         /**
       
    88          * Finds a mapping for a vCard field.
       
    89          *
       
    90          * @param aVcardField   vCard field to search a mapping for.
       
    91          * @return  index of the mapping (for operator[]) or KErrNotFound if
       
    92          *          not found.
       
    93          * @see operator[]
       
    94          */
       
    95         TInt Find(const TVcardField& aVcardField) const;
       
    96 
       
    97         /**
       
    98          * Finds a mapping with an UID.
       
    99          *
       
   100          * @param aUid  UID to search for.
       
   101          * @return  index of the mapping (for operator[]) or KErrNotFound if
       
   102          *          not found.
       
   103          * @see operator[]
       
   104          */
       
   105         TInt Find(const TUid& aUid) const;
       
   106 
       
   107         /**
       
   108          * Finds the name of the field with an UID.
       
   109          *
       
   110          * @param aUid  UID to search for.
       
   111          * @return  The name of the mapping or KNullDesC if
       
   112          *          not found.
       
   113          * @see operator[]
       
   114          */
       
   115         TPtrC8 FindName(const TUid& aUid) const;
       
   116         
       
   117         /**
       
   118          * Finds the index of the field with an UID.
       
   119          *
       
   120          * @param aUid  UID to search for.
       
   121          * @return  The index of the mapping or KErrNotFound if
       
   122          *          not found.
       
   123          * @see operator[]
       
   124          */
       
   125         TInt FindIndex(const TUid& aUid) const;
       
   126 
       
   127 
       
   128     private:  // Implementation
       
   129         CBCardFieldUidMapping();
       
   130         void ConstructL(TResourceReader& aReader);
       
   131 
       
   132 
       
   133     private:  // Data
       
   134         struct TMappingImpl;
       
   135 		/// Own: array of mappings
       
   136         RArray<TMappingImpl> iMappings;
       
   137     };
       
   138 
       
   139 
       
   140 // INLINE FUNCTIONS
       
   141 inline CBCardFieldUidMapping::TVcardField::TVcardField()
       
   142     {
       
   143     }
       
   144 
       
   145 inline CBCardFieldUidMapping::TVcardField::TVcardField
       
   146         (const TDesC8& aName, TInt aFieldIndex/*=0*/) :
       
   147     iName(aName), iFieldIndex(aFieldIndex)
       
   148     {
       
   149     }
       
   150 
       
   151 #endif // __CBCARDFIELDUIDMAPPING_H__
       
   152 
       
   153 // End of File