|
1 /* |
|
2 * Copyright (c) 2005-2009 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 #include "mdepropertydef.h" |
|
19 |
|
20 #include "mdcdef.h" |
|
21 #include "mdeobjectdef.h" |
|
22 #include "mdenamespacedef.h" |
|
23 #include "mdscommoninternal.h" |
|
24 #include "mdcserializationbuffer.h" |
|
25 |
|
26 |
|
27 CMdEPropertyDef::CMdEPropertyDef( const TMdCPropertyDef& aPropertyDef, CMdEObjectDef& aObjectDef ) |
|
28 : iPropertyDef(aPropertyDef), iObjectDef(aObjectDef) |
|
29 { |
|
30 } |
|
31 |
|
32 CMdEPropertyDef* CMdEPropertyDef::NewL( const TMdCPropertyDef& aPropertyDef, |
|
33 CMdCSerializationBuffer& aSchemaBuffer, CMdEObjectDef& aObjectDef ) |
|
34 { |
|
35 CMdEPropertyDef* def = CMdEPropertyDef::NewLC( aPropertyDef, aSchemaBuffer, aObjectDef ); |
|
36 CleanupStack::Pop( def ); |
|
37 return def; |
|
38 } |
|
39 |
|
40 CMdEPropertyDef* CMdEPropertyDef::NewLC( const TMdCPropertyDef& aPropertyDef, |
|
41 CMdCSerializationBuffer& aSchemaBuffer, CMdEObjectDef& aObjectDef ) |
|
42 { |
|
43 CMdEPropertyDef* def = new( ELeave ) CMdEPropertyDef( aPropertyDef, aObjectDef ); |
|
44 CleanupStack::PushL( def ); |
|
45 def->ConstructL( aSchemaBuffer ); |
|
46 return def; |
|
47 } |
|
48 |
|
49 void CMdEPropertyDef::ConstructL( CMdCSerializationBuffer& aSchemaBuffer ) |
|
50 { |
|
51 aSchemaBuffer.PositionL( iPropertyDef.iName.iPtr.iOffset ); |
|
52 iName.Set( aSchemaBuffer.ReceivePtr16L() ); |
|
53 } |
|
54 |
|
55 CMdEPropertyDef::~CMdEPropertyDef() |
|
56 { |
|
57 } |
|
58 |
|
59 TDefId CMdEPropertyDef::Id() const |
|
60 { |
|
61 return iPropertyDef.iDefId; |
|
62 } |
|
63 |
|
64 TDefId CMdEPropertyDef::ObjectDefId() const |
|
65 { |
|
66 return iObjectDef.Id(); |
|
67 } |
|
68 |
|
69 EXPORT_C CMdEObjectDef& CMdEPropertyDef::ObjectDef() const |
|
70 { |
|
71 return iObjectDef; |
|
72 } |
|
73 |
|
74 EXPORT_C const TDesC& CMdEPropertyDef::Name() const |
|
75 { |
|
76 return iName; |
|
77 } |
|
78 |
|
79 EXPORT_C TInt CMdEPropertyDef::Compare( const CMdEPropertyDef& aPropertyDef ) const |
|
80 { |
|
81 TInt result = iObjectDef.NamespaceDef().Compare( aPropertyDef.iObjectDef.NamespaceDef() ); |
|
82 if ( result == 0 ) |
|
83 { |
|
84 result = iPropertyDef.iDefId - aPropertyDef.Id(); |
|
85 } |
|
86 return result; |
|
87 } |
|
88 |
|
89 EXPORT_C TPropertyType CMdEPropertyDef::PropertyType() const |
|
90 { |
|
91 return (TPropertyType)iPropertyDef.iValueType; |
|
92 } |
|
93 |
|
94 EXPORT_C TBool CMdEPropertyDef::ReadOnly() const |
|
95 { |
|
96 return iPropertyDef.iFlags & EPropertyReadOnly ? ETrue : EFalse; |
|
97 } |
|
98 |
|
99 EXPORT_C TBool CMdEPropertyDef::Mandatory() const |
|
100 { |
|
101 return iPropertyDef.iFlags & EPropertyMandatory ? ETrue : EFalse; |
|
102 } |
|
103 |
|
104 EXPORT_C TInt32 CMdEPropertyDef::MinInt32ValueL() const |
|
105 { |
|
106 const TPropertyType type = PropertyType(); |
|
107 if ( type != EPropertyInt8 && |
|
108 type != EPropertyInt16 && |
|
109 type != EPropertyInt32 ) |
|
110 { |
|
111 User::Leave( KErrNotSupported ); |
|
112 } |
|
113 return iPropertyDef.iMinValue.iInt32; |
|
114 } |
|
115 |
|
116 EXPORT_C TInt32 CMdEPropertyDef::MaxInt32ValueL() const |
|
117 { |
|
118 const TPropertyType type = PropertyType(); |
|
119 if ( type != EPropertyInt8 && |
|
120 type != EPropertyInt16 && |
|
121 type != EPropertyInt32 ) |
|
122 { |
|
123 User::Leave( KErrNotSupported ); |
|
124 } |
|
125 return iPropertyDef.iMaxValue.iInt32; |
|
126 } |
|
127 |
|
128 EXPORT_C TUint32 CMdEPropertyDef::MinUint32ValueL() const |
|
129 { |
|
130 const TPropertyType type = PropertyType(); |
|
131 if ( type != EPropertyUint8 && |
|
132 type != EPropertyUint16 && |
|
133 type != EPropertyUint32 ) |
|
134 { |
|
135 User::Leave( KErrNotSupported ); |
|
136 } |
|
137 return iPropertyDef.iMinValue.iUint32; |
|
138 } |
|
139 |
|
140 EXPORT_C TUint32 CMdEPropertyDef::MaxUint32ValueL() const |
|
141 { |
|
142 const TPropertyType type = PropertyType(); |
|
143 if ( type != EPropertyUint8 && |
|
144 type != EPropertyUint16 && |
|
145 type != EPropertyUint32 ) |
|
146 { |
|
147 User::Leave( KErrNotSupported ); |
|
148 } |
|
149 return iPropertyDef.iMaxValue.iUint32; |
|
150 } |
|
151 |
|
152 EXPORT_C TInt64 CMdEPropertyDef::MinInt64ValueL() const |
|
153 { |
|
154 const TPropertyType type = PropertyType(); |
|
155 if ( type != EPropertyInt64 ) |
|
156 { |
|
157 User::Leave( KErrNotSupported ); |
|
158 } |
|
159 return iPropertyDef.iMinValue.iInt64; |
|
160 } |
|
161 |
|
162 EXPORT_C TInt64 CMdEPropertyDef::MaxInt64ValueL() const |
|
163 { |
|
164 const TPropertyType type = PropertyType(); |
|
165 if ( type != EPropertyInt64 ) |
|
166 { |
|
167 User::Leave( KErrNotSupported ); |
|
168 } |
|
169 return iPropertyDef.iMaxValue.iInt64; |
|
170 } |
|
171 |
|
172 EXPORT_C TReal CMdEPropertyDef::MinRealValueL() const |
|
173 { |
|
174 const TPropertyType type = PropertyType(); |
|
175 if ( type != EPropertyReal32 && type != EPropertyReal64 ) |
|
176 { |
|
177 User::Leave( KErrNotSupported ); |
|
178 } |
|
179 return iPropertyDef.iMinValue.iReal; |
|
180 } |
|
181 |
|
182 EXPORT_C TReal CMdEPropertyDef::MaxRealValueL() const |
|
183 { |
|
184 const TPropertyType type = PropertyType(); |
|
185 if ( type != EPropertyReal32 && type != EPropertyReal64 ) |
|
186 { |
|
187 User::Leave( KErrNotSupported ); |
|
188 } |
|
189 return iPropertyDef.iMaxValue.iReal; |
|
190 } |
|
191 |
|
192 EXPORT_C TTime CMdEPropertyDef::MinTimeValueL() const |
|
193 { |
|
194 const TPropertyType type = PropertyType(); |
|
195 if ( type != EPropertyTime ) |
|
196 { |
|
197 User::Leave( KErrNotSupported ); |
|
198 } |
|
199 return TTime(iPropertyDef.iMinValue.iInt64); |
|
200 } |
|
201 |
|
202 EXPORT_C TTime CMdEPropertyDef::MaxTimeValueL() const |
|
203 { |
|
204 const TPropertyType type = PropertyType(); |
|
205 if ( type != EPropertyTime ) |
|
206 { |
|
207 User::Leave( KErrNotSupported ); |
|
208 } |
|
209 return TTime(iPropertyDef.iMaxValue.iInt64); |
|
210 } |
|
211 |
|
212 EXPORT_C TInt CMdEPropertyDef::MinTextLengthL() const |
|
213 { |
|
214 const TPropertyType type = PropertyType(); |
|
215 if ( type != EPropertyText ) |
|
216 { |
|
217 User::Leave( KErrNotSupported ); |
|
218 } |
|
219 return iPropertyDef.iMinValue.iInt32; |
|
220 } |
|
221 |
|
222 EXPORT_C TInt CMdEPropertyDef::MaxTextLengthL() const |
|
223 { |
|
224 const TPropertyType type = PropertyType(); |
|
225 if ( type != EPropertyText ) |
|
226 { |
|
227 User::Leave( KErrNotSupported ); |
|
228 } |
|
229 return iPropertyDef.iMaxValue.iInt32; |
|
230 } |
|
231 |
|
232 EXPORT_C CMdENamespaceDef& CMdEPropertyDef::NamespaceDef() const |
|
233 { |
|
234 return iObjectDef.NamespaceDef(); |
|
235 } |