1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #ifndef __TLDLISTDEF_H__
22 #define __TLDLISTDEF_H__
25 #include <ineturilistdef.h>
27 using namespace InetUriList;
29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
33 friend class TPolicyQueryArgs;
34 friend class TQueryResults;
46 Bit width of the type.
54 Maximum number of arguments. Currently set as 4.
62 TInt iArgs [KMaxArguments];
66 //-----------------------------------------------------------------
67 class TPolicyQueryArgs:public TBase
83 inline TPolicyQueryArgs ()
88 A templated constructor that constructs the query argument.
89 It takes one argument.
92 explicit inline TPolicyQueryArgs ( T0 a0 )
95 iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType));
99 A templated constructor that constructs the query argument.
100 It takes two arguments.
102 template < class T0, class T1 >
103 inline TPolicyQueryArgs ( T0 a0, T1 a1 )
107 iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType)) |
108 (Type(a1)<<(( Type(a1))*KBitsPerType));
112 A templated constructor that constructs the query argument.
113 It takes three arguments.
115 template < class T0, class T1, class T2 >
116 inline TPolicyQueryArgs ( T0 a0, T1 a1, T2 a2 )
121 iFlags=(Type(a0)<<(Type(a0)*KBitsPerType)) |
122 (Type(a1)<<(Type(a1)*KBitsPerType)) |
123 (Type(a2)<<(Type(a2)*KBitsPerType));
126 Returns the argument if set, otherwise returns KErrNotFound.
128 TInt Get ( TPolicyArgType aType ) const
130 if ( IsSet ( aType ) )
131 return iArgs[aType - 1];
137 Checks whether the flag is set for the given argument type.
139 TBool IsSet ( TPolicyArgType aType ) const
141 TInt val = iFlags & ( aType << ( aType * KBitsPerType ) );
142 return iFlags & ( aType << ( aType * KBitsPerType ) );
145 TPolicyArgType Type ( const TDesC8* )
150 TPolicyArgType Type ( InetUriList::TListType )
155 TPolicyArgType Type ( InetUriList::TTLDQueryType )
157 return ETldQueryType;
160 void Assign ( const TDesC8* aValue )
162 iArgs[Type(aValue)-1] = (TInt)aValue;
165 void Assign ( InetUriList::TListType aValue )
167 iArgs[Type(aValue)-1] = aValue;
170 void Assign ( InetUriList::TTLDQueryType aValue )
172 iArgs[Type(aValue)-1] = aValue;
183 Bit width of the type.
193 Maximum number of arguments. Currently set as 4.
210 TInt iArgs [KMaxArguments];
214 //-----------------------------------------------------------------
215 class TPolicyQueryArgs:public TBase
233 inline TPolicyQueryArgs ()
239 A templated constructor that constructs the query argument.
240 It takes one argument.
242 template < class T0 >
243 explicit inline TPolicyQueryArgs ( T0 a0 )
246 iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType));
250 A templated constructor that constructs the query argument.
251 It takes two arguments.
253 template < class T0, class T1 >
254 inline TPolicyQueryArgs ( T0 a0, T1 a1 )
258 iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType)) |
259 (Type(a1)<<(( Type(a1))*KBitsPerType));
263 A templated constructor that constructs the query argument.
264 It takes three arguments.
266 template < class T0, class T1, class T2 >
267 inline TPolicyQueryArgs ( T0 a0, T1 a1, T2 a2 )
272 iFlags=(Type(a0)<<(Type(a0)*KBitsPerType)) |
273 (Type(a1)<<(Type(a1)*KBitsPerType)) |
274 (Type(a2)<<(Type(a2)*KBitsPerType));
278 Checks whether the flag is set for the given argument type.
282 TBool IsSet ( TPolicyArgType aType ) const
284 TInt val = iFlags & ( aType << ( aType * KBitsPerType ) );
285 return iFlags & ( aType << ( aType * KBitsPerType ) );
289 Returns the argument if set, otherwise returns KErrNotFound.
293 TInt Get ( TPolicyArgType aType ) const
295 if ( IsSet ( aType ) )
296 return iArgs[aType - 1];
306 TPolicyArgType Type ( const TDesC8* )
311 TPolicyArgType Type ( InetUriList::TListType )
316 TPolicyArgType Type ( InetUriList::TTLDQueryType )
318 return ETldQueryType;
321 void Assign ( const TDesC8* aValue )
323 iArgs[Type(aValue)-1] = (TInt)aValue;
326 void Assign ( InetUriList::TListType aValue )
328 iArgs[Type(aValue)-1] = aValue;
331 void Assign ( InetUriList::TTLDQueryType aValue )
333 iArgs[Type(aValue)-1] = aValue;
340 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
343 //------------------------------------------------------------------------
344 class TQueryResults: public TBase
350 inline TQueryResults ()
356 if ( IsSet( TQueryResults::ETldCharSet ) )
358 //Delete memory on Heap.
359 HBufC8* uriBuf = (reinterpret_cast<HBufC8*> ( Get ( TQueryResults::ETldCharSet ) ));
365 returns a pointer to policydata
369 __ASSERT_ALWAYS( IsSet(TQueryResults::ETldCharSet), User::Panic( KTldInvalidRequest, KErrPolicyDataNotPresent ));
370 const TDesC8& uri = *( reinterpret_cast<TDesC8*> (Get ( TQueryResults::ETldCharSet ) ) );
377 InetUriList::TListType ListType()
379 __ASSERT_ALWAYS( IsSet(TQueryResults::ETldListType), User::Panic( KTldInvalidRequest, KErrPolicyListTypeNotPresent ));
380 return (static_cast<InetUriList::TListType> (Get ( TQueryResults::ETldListType ) ));
384 A templated constructor that constructs the query argument.
385 It takes one argument. --Check this
387 template < class T0 >
388 inline void Set ( T0 a0 )
391 iFlags=(Type(a0)<<(( Type(a0))*KBitsPerType));
395 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
405 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
412 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
414 Checks whether the flag is set for the given argument type.
418 Checks whether the flag is set for the given argument type.
422 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
423 TBool IsSet ( TResultsArgType aType ) const
425 TInt val = iFlags & ( aType << ( aType * KBitsPerType ) );
426 return iFlags & ( aType << ( aType * KBitsPerType ) );
429 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
431 Returns the argument if set, otherwise returns KErrNotFound.
435 Returns the argument if set, otherwise returns KErrNotFound.
439 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
440 TInt Get ( TResultsArgType aType ) const
442 if ( IsSet ( aType ) )
443 return iArgs[aType - 1];
448 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
452 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
454 TResultsArgType Type ( const TDesC8* )
459 TResultsArgType Type ( InetUriList::TListType )
464 void Assign ( const TDesC8* aValue )
466 iArgs[Type(aValue)-1] = (TInt)aValue;
469 void Assign ( InetUriList::TListType aValue )
471 iArgs[Type(aValue)-1] = aValue;
475 #endif // __TLDLISTDEF_H__