|
1 /* |
|
2 * Copyright (c) 2006-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: CCFKeyValuePair class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cfkeyvaluepair.h" |
|
20 #include "cftrace.h" |
|
21 |
|
22 // MEMBER FUNCTIONS |
|
23 |
|
24 EXPORT_C CCFKeyValuePair* CCFKeyValuePair::NewL( const TDesC& aKey, |
|
25 const TDesC& aValue ) |
|
26 { |
|
27 FUNC_LOG; |
|
28 |
|
29 CCFKeyValuePair* self = CCFKeyValuePair::NewLC( aKey, aValue ); |
|
30 CleanupStack::Pop( self ); |
|
31 |
|
32 return self; |
|
33 } |
|
34 |
|
35 EXPORT_C CCFKeyValuePair* CCFKeyValuePair::NewLC( const TDesC& aKey, |
|
36 const TDesC& aValue ) |
|
37 { |
|
38 FUNC_LOG; |
|
39 |
|
40 CCFKeyValuePair* self = new( ELeave ) CCFKeyValuePair; |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL( aKey, aValue ); |
|
43 |
|
44 return self; |
|
45 } |
|
46 |
|
47 EXPORT_C CCFKeyValuePair* CCFKeyValuePair::NewL( HBufC* aKey, HBufC* aValue ) |
|
48 { |
|
49 FUNC_LOG; |
|
50 |
|
51 CCFKeyValuePair* self = CCFKeyValuePair::NewLC( aKey, aValue ); |
|
52 CleanupStack::Pop( self ); |
|
53 |
|
54 return self; |
|
55 } |
|
56 |
|
57 EXPORT_C CCFKeyValuePair* CCFKeyValuePair::NewLC( HBufC* aKey, HBufC* aValue ) |
|
58 { |
|
59 FUNC_LOG; |
|
60 |
|
61 CCFKeyValuePair* self = new( ELeave ) CCFKeyValuePair( aKey, aValue ); |
|
62 CleanupStack::PushL( self ); |
|
63 |
|
64 return self; |
|
65 } |
|
66 |
|
67 EXPORT_C CCFKeyValuePair::~CCFKeyValuePair() |
|
68 { |
|
69 FUNC_LOG; |
|
70 |
|
71 delete iKey; |
|
72 delete iValue; |
|
73 } |
|
74 |
|
75 CCFKeyValuePair::CCFKeyValuePair() |
|
76 { |
|
77 FUNC_LOG; |
|
78 } |
|
79 |
|
80 CCFKeyValuePair::CCFKeyValuePair( HBufC* aKey, HBufC* aValue ): |
|
81 iKey( aKey ), |
|
82 iValue( aValue ) |
|
83 { |
|
84 FUNC_LOG; |
|
85 } |
|
86 |
|
87 void CCFKeyValuePair::ConstructL( const TDesC& aKey, |
|
88 const TDesC& aValue ) |
|
89 { |
|
90 FUNC_LOG; |
|
91 |
|
92 iKey = aKey.AllocL(); |
|
93 iValue = aValue.AllocL(); |
|
94 } |
|
95 |
|
96 // METHODS |
|
97 |
|
98 //----------------------------------------------------------------------------- |
|
99 // CCFKeyValuePair::Key |
|
100 //----------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C const TDesC& CCFKeyValuePair::Key() const |
|
103 { |
|
104 FUNC_LOG; |
|
105 |
|
106 if( !iKey ) |
|
107 { |
|
108 return KNullDesC; |
|
109 } |
|
110 else |
|
111 { |
|
112 return *iKey; |
|
113 } |
|
114 } |
|
115 |
|
116 //----------------------------------------------------------------------------- |
|
117 // CCFKeyValuePair::Value |
|
118 //----------------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C const TDesC& CCFKeyValuePair::Value() const |
|
121 { |
|
122 FUNC_LOG; |
|
123 |
|
124 if( !iValue ) |
|
125 { |
|
126 return KNullDesC; |
|
127 } |
|
128 else |
|
129 { |
|
130 return *iValue; |
|
131 } |
|
132 } |