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