mmserv/metadatautility/Src/MetaDataField.cpp
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2004 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: Contains implementation of the CMetaDataField class.
       
    15 *              This class provides.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include	"MetaDataField.h"
       
    23 #ifdef _DEBUG
       
    24 #include	<e32svr.h>
       
    25 #endif
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CMetaDataField::CMetaDataField
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CMetaDataField::CMetaDataField()
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CMetaDataField::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CMetaDataField::ConstructL(
       
    45 	TMetaDataFieldId aId,
       
    46 	const TDesC& aData )
       
    47     {
       
    48     iId = aId;
       
    49     iData = aData.AllocL();
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CMetaDataField::ConstructL for 8 bit field data
       
    54 // Symbian 2nd phase constructor can leave.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CMetaDataField::ConstructL(
       
    58 	TMetaDataFieldId aId,
       
    59 	const TDesC8& aData )
       
    60     {
       
    61 	#ifdef _DEBUG
       
    62 		RDebug::Print(_L("CMetaDataField::ConstructL "));
       
    63 	#endif
       
    64     iId = aId;
       
    65     iData8 = aData.AllocL();
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CMetaDataField::NewLC
       
    70 // Two-phased constructor.
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 CMetaDataField* CMetaDataField::NewLC(
       
    74 	TMetaDataFieldId aId,
       
    75 	const TDesC& aData )
       
    76     {
       
    77 	#ifdef _DEBUG
       
    78 	RDebug::Print(_L("CMetaDataField::NewLC - [%d]"), aId);
       
    79 	#endif
       
    80 		CMetaDataField* self = new( ELeave ) CMetaDataField;
       
    81 	    CleanupStack::PushL( self );
       
    82 	    self->ConstructL( aId, aData );
       
    83 	    return self;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CMetaDataField::NewLC
       
    88 // Two-phased constructor for 8 bit data fields
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CMetaDataField* CMetaDataField::NewLC(
       
    92 	TMetaDataFieldId aId,
       
    93 	const TDesC8& aData )
       
    94     {
       
    95 	#ifdef _DEBUG
       
    96 		RDebug::Print(_L("CMetaDataField::NewLC with 8bit"));
       
    97 	#endif
       
    98 		CMetaDataField* self = new( ELeave ) CMetaDataField;
       
    99     	CleanupStack::PushL( self );
       
   100     	self->ConstructL( aId, aData );
       
   101     	return self;
       
   102     }
       
   103 
       
   104 // Destructor
       
   105 CMetaDataField::~CMetaDataField()
       
   106 	{
       
   107 		delete iData;
       
   108 		delete iData8;
       
   109 	}
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CMetaDataField::Id
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 TMetaDataFieldId CMetaDataField::Id() const
       
   116     {
       
   117     return iId;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CMetaDataField::Data
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TPtrC CMetaDataField::Data() const
       
   125     {
       
   126     if(iData)
       
   127     	{
       
   128     	return iData->Des();	
       
   129     	}
       
   130     return KNullDesC();
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CMetaDataField::Data
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 TPtrC8 CMetaDataField::Data8() const
       
   138     {
       
   139     #ifdef _DEBUG	
       
   140 		RDebug::Print(_L("CMetaDataField::Data8"));   
       
   141 	#endif 	
       
   142     if (iData8)
       
   143     	{
       
   144     	return iData8->Des();
       
   145 		}
       
   146 	return KNullDesC8();
       
   147 	}
       
   148 //  End of File