1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/app/TVPbkFieldTypeParameters.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,241 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: A class for managing field type parameters.
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef TVPBKFIELDTYPEPARAMETERS_H
1.23 +#define TVPBKFIELDTYPEPARAMETERS_H
1.24 +
1.25 +
1.26 +// INCLUDES
1.27 +#include <e32std.h>
1.28 +#include <vpbkfieldtype.hrh>
1.29 +
1.30 +// FORWARD DECLARATIONS
1.31 +class TResourceReader;
1.32 +
1.33 +// CLASS DECLARATIONS
1.34 +
1.35 +/**
1.36 + * A class for managing field type parameters.
1.37 + *
1.38 + * Parameters are based on the Versit 2.1 standard and they can be
1.39 + * found from TVPbkFieldTypeParameter in VPbkFieldType.hrh.
1.40 + *
1.41 + * @see VBK_FIELD_VERSIT_PROPERTY in VPbkFieldType.rh
1.42 + * @see TVPbkFieldVersitProperty
1.43 + * @lib VPbkEng.lib
1.44 + */
1.45 +class TVPbkFieldTypeParameters
1.46 + {
1.47 + public: // Constructors
1.48 + /**
1.49 + * Default constructor. Initializes this parameter set to empty.
1.50 + */
1.51 + inline TVPbkFieldTypeParameters();
1.52 +
1.53 + /**
1.54 + * Constructs this parameter set from a resource.
1.55 + * The resource must have LEN BYTE BYTE[] layout.
1.56 + *
1.57 + * @param aResReader A reader to resource LEN BYTE BYTE[] that
1.58 + * contains the parameters.
1.59 + * @exception VPbkError::Panic(
1.60 + * VPbkError::EInvalidTypeParameterResource)
1.61 + * if the resource is invalid.
1.62 + */
1.63 + inline TVPbkFieldTypeParameters(TResourceReader& aResReader);
1.64 +
1.65 + public: // New functions
1.66 + /**
1.67 + * Initializes this parameter set from a resource.
1.68 + * The resource must have LEN BYTE BYTE[] layout.
1.69 + *
1.70 + * @param aResReader A reader to resource LEN BYTE BYTE[] that
1.71 + * contains the parameters.
1.72 + * @exception VPbkError::Panic(
1.73 + * VPbkError::EInvalidTypeParameterResource)
1.74 + * if the resource is invalid.
1.75 + */
1.76 + IMPORT_C void ReadFromResource(TResourceReader& aResReader);
1.77 +
1.78 + /**
1.79 + * Adds parameter set from a resource.
1.80 + * The resource must have LEN BYTE BYTE[] layout.
1.81 + *
1.82 + * @param aResReader A reader to resource LEN BYTE BYTE[] that
1.83 + * contains the parameters.
1.84 + * @exception VPbkError::Panic(
1.85 + * VPbkError::EInvalidTypeParameterResource)
1.86 + * if the resource is invalid.
1.87 + */
1.88 + void AddFromResource(TResourceReader& aResReader);
1.89 +
1.90 + /**
1.91 + * Adds aParam to this parameter set.
1.92 + *
1.93 + * @param aParam A new parameter to this set.
1.94 + * @precond aParam >= 0 && aParam < KVPbkMaxVersitParams.
1.95 + * VPbkError::Panic(VPbkError::EInvalidTypeParameter)
1.96 + * is raised if the precondition does not hold.
1.97 + * @return This object for easy chaining of calls.
1.98 + * @postcond Contains(aParam)
1.99 + */
1.100 + inline TVPbkFieldTypeParameters& Add(TVPbkFieldTypeParameter aParam);
1.101 +
1.102 + /**
1.103 + * Adds all parameters of another parameter set to this set.
1.104 + *
1.105 + * @param aParams A set of paramters that are added to this set.
1.106 + * @return This object for easy chaining of calls.
1.107 + * @postcond ContainsAll(aParams)
1.108 + */
1.109 + inline TVPbkFieldTypeParameters& AddAll(
1.110 + const TVPbkFieldTypeParameters& aParams);
1.111 +
1.112 + /**
1.113 + * Removes aParam from this parameter set.
1.114 + *
1.115 + * @param aParam A parameter that is removed from this set.
1.116 + * @precond aParam >= 0 && aParam < KVPbkMaxVersitParams.
1.117 + * VPbkError::Panic(VPbkError::EInvalidTypeParameter)
1.118 + * is raised if the precondition does not hold.
1.119 + * @return This object for easy chaining of calls.
1.120 + * @postcond !Contains(aParam)
1.121 + */
1.122 + inline TVPbkFieldTypeParameters& Remove(
1.123 + TVPbkFieldTypeParameter aParam);
1.124 +
1.125 + /**
1.126 + * Removes all parameters of another parameter set from this set.
1.127 + *
1.128 + * @param aParams Parameters that are removed from this set.
1.129 + * @return This object for easy chaining of calls.
1.130 + * @postcond ContainsAll(aParams)
1.131 + */
1.132 + inline TVPbkFieldTypeParameters& RemoveAll(
1.133 + const TVPbkFieldTypeParameters& aParams);
1.134 +
1.135 + /**
1.136 + * Removes all parameters from this set.
1.137 + */
1.138 + IMPORT_C void Reset();
1.139 +
1.140 + /**
1.141 + * Returns true if aParam is included in this parameter set.
1.142 + *
1.143 + * @param aParam A parameter that is looked for.
1.144 + * @precond aParam >= 0 && aParam < KVPbkMaxVersitParams
1.145 + * @return ETrue if aParam was found from this set.
1.146 + */
1.147 + IMPORT_C TBool Contains(TVPbkFieldTypeParameter aParam) const;
1.148 +
1.149 + /**
1.150 + * Returns true if this parameter set contains all the parameters in
1.151 + * aOtherParams.
1.152 + *
1.153 + * This function is more efficient than calling
1.154 + * Contains(TVPbkFieldTypeParameter) in a loop when multiple
1.155 + * parameters are checked.
1.156 + *
1.157 + * @param aOtherParams A set of parameters that are looked for.
1.158 + * @return ETrue if all the aOtherParams were found from this set.
1.159 + */
1.160 + IMPORT_C TBool ContainsAll(
1.161 + const TVPbkFieldTypeParameters& aOtherParams) const;
1.162 +
1.163 + /**
1.164 + * Returns true if this parameter set contains none of the parameters
1.165 + * in aOtherParams.
1.166 + *
1.167 + * This function is more efficient than calling
1.168 + * Contains(TVPbkFieldTypeParameter) in a loop when multiple
1.169 + * parameters are checked.
1.170 + *
1.171 + * @param aOtherParams A set of parameters that are looked for.
1.172 + * @return ETrue if none of the aOtherParams were found from this set.
1.173 + */
1.174 + IMPORT_C TBool ContainsNone(
1.175 + const TVPbkFieldTypeParameters& aOtherParams) const;
1.176 +
1.177 + /**
1.178 + * Returns field type params configuration.
1.179 + */
1.180 + TUint32* FieldTypeParameters();
1.181 +
1.182 + /**
1.183 + * Size of field type params configuration.
1.184 + */
1.185 + TInt Size();
1.186 +
1.187 + private: // Implementation
1.188 + IMPORT_C void DoAdd(TVPbkFieldTypeParameter aParam);
1.189 + IMPORT_C void DoAddAll(const TVPbkFieldTypeParameters& aParams);
1.190 + IMPORT_C void DoRemove(TVPbkFieldTypeParameter aParam);
1.191 + IMPORT_C void DoRemoveAll(const TVPbkFieldTypeParameters& aParams);
1.192 +
1.193 + private: // Data
1.194 + /// A bit field set up for KVPbkMaxVersitParams parameters.
1.195 + enum { KSizeOfTUint32 = 32 };
1.196 + enum { KBufSize = KVPbkMaxVersitParams / KSizeOfTUint32 };
1.197 + ///Own: bit field for paramers (Contains spares for future extension)
1.198 + TUint32 iParams[KBufSize];
1.199 + };
1.200 +
1.201 +
1.202 +// INLINE FUNCTIONS
1.203 +
1.204 +inline TVPbkFieldTypeParameters::TVPbkFieldTypeParameters()
1.205 + {
1.206 + Reset();
1.207 + }
1.208 +
1.209 +inline TVPbkFieldTypeParameters::TVPbkFieldTypeParameters(TResourceReader& aResReader)
1.210 + {
1.211 + ReadFromResource(aResReader);
1.212 + }
1.213 +
1.214 +inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::Add
1.215 + (TVPbkFieldTypeParameter aParam)
1.216 + {
1.217 + DoAdd(aParam);
1.218 + return *this;
1.219 + }
1.220 +
1.221 +inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::AddAll
1.222 + (const TVPbkFieldTypeParameters& aParams)
1.223 + {
1.224 + DoAddAll(aParams);
1.225 + return *this;
1.226 + }
1.227 +
1.228 +inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::Remove
1.229 + (TVPbkFieldTypeParameter aParam)
1.230 + {
1.231 + DoRemove(aParam);
1.232 + return *this;
1.233 + }
1.234 +
1.235 +inline TVPbkFieldTypeParameters& TVPbkFieldTypeParameters::RemoveAll
1.236 + (const TVPbkFieldTypeParameters& aParams)
1.237 + {
1.238 + DoRemoveAll(aParams);
1.239 + return *this;
1.240 + }
1.241 +
1.242 +#endif // TVPBKFIELDTYPEPARAMETERS_H
1.243 +
1.244 +//End of file