messagingappbase/smartmessaging/msgeditorutils/src/MsgNameValue.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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 *		This class encapsulates a name and value pair
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "MsgNameValue.h"
       
    24 
       
    25 //  MEMBER FUNCTIONS
       
    26 
       
    27 EXPORT_C CMsgNameValue* CMsgNameValue::NewL( HBufC* aName, HBufC* aValue)
       
    28     {
       
    29     CMsgNameValue* self = new (ELeave) CMsgNameValue(aName, aValue);
       
    30     return self;
       
    31     }
       
    32 
       
    33 EXPORT_C CMsgNameValue* CMsgNameValue::NewL(const TDesC& aName, const TDesC& aValue)
       
    34     {
       
    35     CMsgNameValue* self = CMsgNameValue::NewLC( aName, aValue );
       
    36     CleanupStack::Pop( self );
       
    37     return self;
       
    38     }
       
    39 
       
    40 EXPORT_C CMsgNameValue* CMsgNameValue::NewLC(const TDesC& aName, const TDesC& aValue)
       
    41     {
       
    42     CMsgNameValue* self = new (ELeave) CMsgNameValue;
       
    43     CleanupStack::PushL(self);
       
    44     self->ConstructL(aName, aValue);
       
    45     return self;
       
    46     }
       
    47 
       
    48 EXPORT_C CMsgNameValue::~CMsgNameValue()
       
    49     {
       
    50     delete iName;
       
    51     delete iValue;
       
    52     }
       
    53 
       
    54 EXPORT_C const TDesC& CMsgNameValue::Name() const
       
    55     {
       
    56     if (iName)
       
    57         {
       
    58         return *iName;
       
    59         }
       
    60     return KNullDesC;
       
    61     }
       
    62 
       
    63 EXPORT_C const TDesC& CMsgNameValue::Value() const
       
    64     {
       
    65     if (iValue)
       
    66         {
       
    67         return *iValue;
       
    68         }
       
    69     return KNullDesC;
       
    70     }
       
    71 
       
    72 void CMsgNameValue::ConstructL(const TDesC& aName, const TDesC& aValue)
       
    73     {
       
    74 	aName.Length()==0 ? iName=KNullDesC().AllocL() : iName = aName.AllocL();
       
    75 	aValue.Length()==0 ? iValue=KNullDesC().AllocL() : iValue = aValue.AllocL();
       
    76     }
       
    77 
       
    78 CMsgNameValue::CMsgNameValue()
       
    79     {
       
    80     }
       
    81 
       
    82 CMsgNameValue::CMsgNameValue( HBufC* aName, HBufC* aValue ) :
       
    83     iName(aName),
       
    84     iValue(aValue)
       
    85     {
       
    86     }
       
    87 
       
    88 // end of file