2 * Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: A class for managing field type parameters.
19 #ifndef TVPBKFIELDTYPEPARAMETERS_H
20 #define TVPBKFIELDTYPEPARAMETERS_H
25 #include <vpbkfieldtype.hrh>
27 // FORWARD DECLARATIONS
28 class TResourceReader;
33 * A class for managing field type parameters.
35 * Parameters are based on the Versit 2.1 standard and they can be
36 * found from TVPbkFieldTypeParameter in VPbkFieldType.hrh.
38 * @see VBK_FIELD_VERSIT_PROPERTY in VPbkFieldType.rh
39 * @see TVPbkFieldVersitProperty
42 class TVPbkFieldTypeParameters
44 public: // Constructors
46 * Default constructor. Initializes this parameter set to empty.
48 inline TVPbkFieldTypeParameters();
51 * Constructs this parameter set from a resource.
52 * The resource must have LEN BYTE BYTE[] layout.
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.
60 inline TVPbkFieldTypeParameters(TResourceReader& aResReader);
62 public: // New functions
64 * Initializes this parameter set from a resource.
65 * The resource must have LEN BYTE BYTE[] layout.
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.
73 IMPORT_C void ReadFromResource(TResourceReader& aResReader);
76 * Adds parameter set from a resource.
77 * The resource must have LEN BYTE BYTE[] layout.
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.
85 void AddFromResource(TResourceReader& aResReader);
88 * Adds aParam to this parameter set.
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)
97 inline TVPbkFieldTypeParameters& Add(TVPbkFieldTypeParameter aParam);
100 * Adds all parameters of another parameter set to this set.
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)
106 inline TVPbkFieldTypeParameters& AddAll(
107 const TVPbkFieldTypeParameters& aParams);
110 * Removes aParam from this parameter set.
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)
119 inline TVPbkFieldTypeParameters& Remove(
120 TVPbkFieldTypeParameter aParam);
123 * Removes all parameters of another parameter set from this set.
125 * @param aParams Parameters that are removed from this set.
126 * @return This object for easy chaining of calls.
127 * @postcond ContainsAll(aParams)
129 inline TVPbkFieldTypeParameters& RemoveAll(
130 const TVPbkFieldTypeParameters& aParams);
133 * Removes all parameters from this set.
135 IMPORT_C void Reset();
138 * Returns true if aParam is included in this parameter set.
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.
144 IMPORT_C TBool Contains(TVPbkFieldTypeParameter aParam) const;
147 * Returns true if this parameter set contains all the parameters in
150 * This function is more efficient than calling
151 * Contains(TVPbkFieldTypeParameter) in a loop when multiple
152 * parameters are checked.
154 * @param aOtherParams A set of parameters that are looked for.
155 * @return ETrue if all the aOtherParams were found from this set.
157 IMPORT_C TBool ContainsAll(
158 const TVPbkFieldTypeParameters& aOtherParams) const;
161 * Returns true if this parameter set contains none of the parameters
164 * This function is more efficient than calling
165 * Contains(TVPbkFieldTypeParameter) in a loop when multiple
166 * parameters are checked.
168 * @param aOtherParams A set of parameters that are looked for.
169 * @return ETrue if none of the aOtherParams were found from this set.
171 IMPORT_C TBool ContainsNone(
172 const TVPbkFieldTypeParameters& aOtherParams) const;
175 * Returns field type params configuration.
177 TUint32* FieldTypeParameters();
180 * Size of field type params configuration.
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);
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];
201 inline TVPbkFieldTypeParameters::TVPbkFieldTypeParameters()
206 inline TVPbkFieldTypeParameters::TVPbkFieldTypeParameters(TResourceReader& aResReader)
208 ReadFromResource(aResReader);
211 inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::Add
212 (TVPbkFieldTypeParameter aParam)
218 inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::AddAll
219 (const TVPbkFieldTypeParameters& aParams)
225 inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::Remove
226 (TVPbkFieldTypeParameter aParam)
232 inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::RemoveAll
233 (const TVPbkFieldTypeParameters& aParams)
235 DoRemoveAll(aParams);
239 #endif // TVPBKFIELDTYPEPARAMETERS_H