|
1 /* |
|
2 * Copyright (c) 2007-2008 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <liwservicehandler.h> |
|
20 |
|
21 #include "hnmdintegerkey.h" |
|
22 #include "hnglobals.h" |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CHnMdIntegerKey* CHnMdIntegerKey::NewL() |
|
31 { |
|
32 CHnMdIntegerKey* self = NewLC(); |
|
33 CleanupStack::Pop( self ); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CHnMdIntegerKey* CHnMdIntegerKey::NewLC() |
|
42 { |
|
43 CHnMdIntegerKey* self = new ( ELeave ) CHnMdIntegerKey(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CHnMdIntegerKey* CHnMdIntegerKey::NewL( const CHnMdIntegerKey* aKey ) |
|
54 { |
|
55 CHnMdIntegerKey* self = NewLC( aKey ); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CHnMdIntegerKey* CHnMdIntegerKey::NewLC( const CHnMdIntegerKey* aKey ) |
|
65 { |
|
66 CHnMdIntegerKey* self = new ( ELeave ) CHnMdIntegerKey(); |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL( aKey ); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CHnMdBaseKey* CHnMdIntegerKey::CopyLC() |
|
77 { |
|
78 CHnMdIntegerKey* self = CHnMdIntegerKey::NewL( this ); |
|
79 CleanupStack::PushL( self ); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CHnMdIntegerKey::~CHnMdIntegerKey() |
|
88 { |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // converts decimal or hexadecimal string into integer |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void CHnMdIntegerKey::GetKeyContent( TInt& aKeyContent ) const |
|
96 { |
|
97 TLex lex( iContent ); |
|
98 TInt err( KErrNone ); |
|
99 if ( !iContent.Find( KHexPrefix16 ) ) |
|
100 { |
|
101 // hexadecimal |
|
102 TUint hex; |
|
103 lex.Inc( KHexPrefix16().Length() ); |
|
104 lex.Mark(); |
|
105 err = lex.Val( hex, EHex ); |
|
106 aKeyContent = hex; |
|
107 } |
|
108 else |
|
109 { |
|
110 // decimal |
|
111 err = lex.Val( aKeyContent ); |
|
112 } |
|
113 |
|
114 if ( err != KErrNone ) |
|
115 { |
|
116 aKeyContent = err; |
|
117 } |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 CHnMdIntegerKey::CHnMdIntegerKey() |
|
125 { |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void CHnMdIntegerKey::ConstructL() |
|
133 { |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CHnMdIntegerKey::ConstructL( const CHnMdIntegerKey* aKey ) |
|
141 { |
|
142 BaseConstructL( aKey ); |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CHnMdIntegerKey::ToVariantL( TLiwVariant& aRet ) const |
|
150 { |
|
151 TInt decimalValue( KErrNotFound ); |
|
152 GetKeyContent( decimalValue ); |
|
153 aRet.SetL( TLiwVariant( ( TInt32 ) decimalValue ) ); |
|
154 } |
|
155 |