|
1 /* |
|
2 * Copyright (c) 2004-2007 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: A class for managing field type parameters. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TVPBKFIELDTYPEPARAMETERS_H |
|
20 #define TVPBKFIELDTYPEPARAMETERS_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <VPbkFieldType.hrh> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class TResourceReader; |
|
29 |
|
30 // CLASS DECLARATIONS |
|
31 |
|
32 /** |
|
33 * A class for managing field type parameters. |
|
34 * |
|
35 * Parameters are based on the Versit 2.1 standard and they can be |
|
36 * found from TVPbkFieldTypeParameter in VPbkFieldType.hrh. |
|
37 * |
|
38 * @see VBK_FIELD_VERSIT_PROPERTY in VPbkFieldType.rh |
|
39 * @see TVPbkFieldVersitProperty |
|
40 * @lib VPbkEng.lib |
|
41 */ |
|
42 class TVPbkFieldTypeParameters |
|
43 { |
|
44 public: // Constructors |
|
45 /** |
|
46 * Default constructor. Initializes this parameter set to empty. |
|
47 */ |
|
48 inline TVPbkFieldTypeParameters(); |
|
49 |
|
50 /** |
|
51 * Constructs this parameter set from a resource. |
|
52 * The resource must have LEN BYTE BYTE[] layout. |
|
53 * |
|
54 * @param aResReader A reader to resource LEN BYTE BYTE[] that |
|
55 * contains the parameters. |
|
56 * @exception VPbkError::Panic( |
|
57 * VPbkError::EInvalidTypeParameterResource) |
|
58 * if the resource is invalid. |
|
59 */ |
|
60 inline TVPbkFieldTypeParameters(TResourceReader& aResReader); |
|
61 |
|
62 public: // New functions |
|
63 /** |
|
64 * Initializes this parameter set from a resource. |
|
65 * The resource must have LEN BYTE BYTE[] layout. |
|
66 * |
|
67 * @param aResReader A reader to resource LEN BYTE BYTE[] that |
|
68 * contains the parameters. |
|
69 * @exception VPbkError::Panic( |
|
70 * VPbkError::EInvalidTypeParameterResource) |
|
71 * if the resource is invalid. |
|
72 */ |
|
73 IMPORT_C void ReadFromResource(TResourceReader& aResReader); |
|
74 |
|
75 /** |
|
76 * Adds parameter set from a resource. |
|
77 * The resource must have LEN BYTE BYTE[] layout. |
|
78 * |
|
79 * @param aResReader A reader to resource LEN BYTE BYTE[] that |
|
80 * contains the parameters. |
|
81 * @exception VPbkError::Panic( |
|
82 * VPbkError::EInvalidTypeParameterResource) |
|
83 * if the resource is invalid. |
|
84 */ |
|
85 void AddFromResource(TResourceReader& aResReader); |
|
86 |
|
87 /** |
|
88 * Adds aParam to this parameter set. |
|
89 * |
|
90 * @param aParam A new parameter to this set. |
|
91 * @precond aParam >= 0 && aParam < KVPbkMaxVersitParams. |
|
92 * VPbkError::Panic(VPbkError::EInvalidTypeParameter) |
|
93 * is raised if the precondition does not hold. |
|
94 * @return This object for easy chaining of calls. |
|
95 * @postcond Contains(aParam) |
|
96 */ |
|
97 inline TVPbkFieldTypeParameters& Add(TVPbkFieldTypeParameter aParam); |
|
98 |
|
99 /** |
|
100 * Adds all parameters of another parameter set to this set. |
|
101 * |
|
102 * @param aParams A set of paramters that are added to this set. |
|
103 * @return This object for easy chaining of calls. |
|
104 * @postcond ContainsAll(aParams) |
|
105 */ |
|
106 inline TVPbkFieldTypeParameters& AddAll( |
|
107 const TVPbkFieldTypeParameters& aParams); |
|
108 |
|
109 /** |
|
110 * Removes aParam from this parameter set. |
|
111 * |
|
112 * @param aParam A parameter that is removed from this set. |
|
113 * @precond aParam >= 0 && aParam < KVPbkMaxVersitParams. |
|
114 * VPbkError::Panic(VPbkError::EInvalidTypeParameter) |
|
115 * is raised if the precondition does not hold. |
|
116 * @return This object for easy chaining of calls. |
|
117 * @postcond !Contains(aParam) |
|
118 */ |
|
119 inline TVPbkFieldTypeParameters& Remove( |
|
120 TVPbkFieldTypeParameter aParam); |
|
121 |
|
122 /** |
|
123 * Removes all parameters of another parameter set from this set. |
|
124 * |
|
125 * @param aParams Parameters that are removed from this set. |
|
126 * @return This object for easy chaining of calls. |
|
127 * @postcond ContainsAll(aParams) |
|
128 */ |
|
129 inline TVPbkFieldTypeParameters& RemoveAll( |
|
130 const TVPbkFieldTypeParameters& aParams); |
|
131 |
|
132 /** |
|
133 * Removes all parameters from this set. |
|
134 */ |
|
135 IMPORT_C void Reset(); |
|
136 |
|
137 /** |
|
138 * Returns true if aParam is included in this parameter set. |
|
139 * |
|
140 * @param aParam A parameter that is looked for. |
|
141 * @precond aParam >= 0 && aParam < KVPbkMaxVersitParams |
|
142 * @return ETrue if aParam was found from this set. |
|
143 */ |
|
144 IMPORT_C TBool Contains(TVPbkFieldTypeParameter aParam) const; |
|
145 |
|
146 /** |
|
147 * Returns true if this parameter set contains all the parameters in |
|
148 * aOtherParams. |
|
149 * |
|
150 * This function is more efficient than calling |
|
151 * Contains(TVPbkFieldTypeParameter) in a loop when multiple |
|
152 * parameters are checked. |
|
153 * |
|
154 * @param aOtherParams A set of parameters that are looked for. |
|
155 * @return ETrue if all the aOtherParams were found from this set. |
|
156 */ |
|
157 IMPORT_C TBool ContainsAll( |
|
158 const TVPbkFieldTypeParameters& aOtherParams) const; |
|
159 |
|
160 /** |
|
161 * Returns true if this parameter set contains none of the parameters |
|
162 * in aOtherParams. |
|
163 * |
|
164 * This function is more efficient than calling |
|
165 * Contains(TVPbkFieldTypeParameter) in a loop when multiple |
|
166 * parameters are checked. |
|
167 * |
|
168 * @param aOtherParams A set of parameters that are looked for. |
|
169 * @return ETrue if none of the aOtherParams were found from this set. |
|
170 */ |
|
171 IMPORT_C TBool ContainsNone( |
|
172 const TVPbkFieldTypeParameters& aOtherParams) const; |
|
173 |
|
174 /** |
|
175 * Returns field type params configuration. |
|
176 */ |
|
177 TUint32* FieldTypeParameters(); |
|
178 |
|
179 /** |
|
180 * Size of field type params configuration. |
|
181 */ |
|
182 TInt Size(); |
|
183 |
|
184 private: // Implementation |
|
185 IMPORT_C void DoAdd(TVPbkFieldTypeParameter aParam); |
|
186 IMPORT_C void DoAddAll(const TVPbkFieldTypeParameters& aParams); |
|
187 IMPORT_C void DoRemove(TVPbkFieldTypeParameter aParam); |
|
188 IMPORT_C void DoRemoveAll(const TVPbkFieldTypeParameters& aParams); |
|
189 |
|
190 private: // Data |
|
191 /// A bit field set up for KVPbkMaxVersitParams parameters. |
|
192 enum { KSizeOfTUint32 = 32 }; |
|
193 enum { KBufSize = KVPbkMaxVersitParams / KSizeOfTUint32 }; |
|
194 ///Own: bit field for paramers (Contains spares for future extension) |
|
195 TUint32 iParams[KBufSize]; |
|
196 }; |
|
197 |
|
198 |
|
199 // INLINE FUNCTIONS |
|
200 |
|
201 inline TVPbkFieldTypeParameters::TVPbkFieldTypeParameters() |
|
202 { |
|
203 Reset(); |
|
204 } |
|
205 |
|
206 inline TVPbkFieldTypeParameters::TVPbkFieldTypeParameters(TResourceReader& aResReader) |
|
207 { |
|
208 ReadFromResource(aResReader); |
|
209 } |
|
210 |
|
211 inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::Add |
|
212 (TVPbkFieldTypeParameter aParam) |
|
213 { |
|
214 DoAdd(aParam); |
|
215 return *this; |
|
216 } |
|
217 |
|
218 inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::AddAll |
|
219 (const TVPbkFieldTypeParameters& aParams) |
|
220 { |
|
221 DoAddAll(aParams); |
|
222 return *this; |
|
223 } |
|
224 |
|
225 inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::Remove |
|
226 (TVPbkFieldTypeParameter aParam) |
|
227 { |
|
228 DoRemove(aParam); |
|
229 return *this; |
|
230 } |
|
231 |
|
232 inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::RemoveAll |
|
233 (const TVPbkFieldTypeParameters& aParams) |
|
234 { |
|
235 DoRemoveAll(aParams); |
|
236 return *this; |
|
237 } |
|
238 |
|
239 #endif // TVPBKFIELDTYPEPARAMETERS_H |
|
240 |
|
241 //End of file |