|
1 /* |
|
2 * Copyright (c) 2008-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: central repository database property class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cenrepdatabaseproperty.h" |
|
20 |
|
21 const TInt KMaxIntLen = 15; |
|
22 |
|
23 // ======== MEMBER FUNCTIONS ======== |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Constructor |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CCenRepDatabaseProperty::CCenRepDatabaseProperty() |
|
30 { |
|
31 } |
|
32 |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // Constructor |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 void CCenRepDatabaseProperty::ConstructL() |
|
39 { |
|
40 } |
|
41 |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Constructor |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C CCenRepDatabaseProperty* CCenRepDatabaseProperty::NewL() |
|
48 { |
|
49 CCenRepDatabaseProperty* self = CCenRepDatabaseProperty::NewLC(); |
|
50 CleanupStack::Pop( self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Constructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CCenRepDatabaseProperty* CCenRepDatabaseProperty::NewLC() |
|
60 { |
|
61 CCenRepDatabaseProperty* self = new( ELeave ) CCenRepDatabaseProperty(); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // Destructor |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 EXPORT_C CCenRepDatabaseProperty::~CCenRepDatabaseProperty() |
|
73 { |
|
74 iPropertyValue.Close(); |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // Returns name of property |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C TUint32 CCenRepDatabaseProperty::GetName() const |
|
83 { |
|
84 return iPropertyName; |
|
85 } |
|
86 |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // Sets the name of property |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C void CCenRepDatabaseProperty::SetName( TUint32 aPropertyName ) |
|
93 { |
|
94 iPropertyName = aPropertyName; |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // Returns value of property |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C TInt CCenRepDatabaseProperty::GetValue( TInt& aValue ) const |
|
103 { |
|
104 TLex convert( iPropertyValue ); |
|
105 TInt err = convert.Val( aValue ); |
|
106 return err; |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Sets value of property. |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 EXPORT_C TInt CCenRepDatabaseProperty::SetValue( TInt aValue ) |
|
115 { |
|
116 TBuf<KMaxIntLen> val; |
|
117 val.AppendNum( aValue ); |
|
118 iPropertyValue.Close(); |
|
119 TInt ret = iPropertyValue.Create( val ); |
|
120 |
|
121 return ret; |
|
122 } |
|
123 |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // Returns value of property |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C const TDesC& CCenRepDatabaseProperty::GetDesValue() const |
|
130 { |
|
131 return iPropertyValue; |
|
132 } |
|
133 |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Sets value of property. |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C TInt CCenRepDatabaseProperty::SetValue( const TDesC& aValue ) |
|
140 { |
|
141 TInt ret( 0 ); |
|
142 if ( aValue.Length() > KCenRepMaxDesLength ) |
|
143 { |
|
144 ret = KErrOverflow; |
|
145 } |
|
146 else |
|
147 { |
|
148 iPropertyValue.Close(); |
|
149 ret = iPropertyValue.Create( aValue ); |
|
150 } |
|
151 |
|
152 return ret; |
|
153 } |
|
154 |
|
155 |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // Compare operator |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C TBool CCenRepDatabaseProperty::operator==( const CCenRepDatabaseProperty& aProperty ) const |
|
162 { |
|
163 TBool result( EFalse ); |
|
164 |
|
165 result = ( iPropertyName == aProperty.GetName() && |
|
166 0 == iPropertyValue.Compare( aProperty.GetDesValue() ) ); |
|
167 |
|
168 return result; |
|
169 } |
|
170 |
|
171 |