epoc32/include/babitflags.h
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
     1.1 --- a/epoc32/include/babitflags.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/babitflags.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -1,9 +1,9 @@
     1.4  // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5  // All rights reserved.
     1.6  // This component and the accompanying materials are made available
     1.7 -// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     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.symbianfoundation.org/legal/licencesv10.html".
    1.11 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.12  //
    1.13  // Initial Contributors:
    1.14  // Nokia Corporation - initial contribution.
    1.15 @@ -19,9 +19,9 @@
    1.16  // System includes
    1.17  #include <e32std.h>
    1.18  
    1.19 -///////////////////////////////////////////////////////////////////////////////////////
    1.20 +//
    1.21  // ----> TBitFlagsT (header)
    1.22 -///////////////////////////////////////////////////////////////////////////////////////
    1.23 +//
    1.24  template <class T>
    1.25  class TBitFlagsT
    1.26  /**
    1.27 @@ -31,9 +31,9 @@
    1.28  @released
    1.29  */
    1.30  	{
    1.31 -///////////////////////////////////////////////////////////////////////////////////////
    1.32 +//
    1.33  public:										// CONSTRUCT
    1.34 -///////////////////////////////////////////////////////////////////////////////////////
    1.35 +//
    1.36  
    1.37  	/**
    1.38  	 * Default constructor - initialize all flags to zero
    1.39 @@ -51,9 +51,9 @@
    1.40  	 */
    1.41  	inline TBitFlagsT(const TBitFlagsT& aFlags);
    1.42  
    1.43 -///////////////////////////////////////////////////////////////////////////////////////
    1.44 +//
    1.45  public:										// MANIPULATORS
    1.46 -///////////////////////////////////////////////////////////////////////////////////////
    1.47 +//
    1.48  
    1.49  	/**
    1.50  	 * Set all the flags
    1.51 @@ -89,9 +89,9 @@
    1.52  	 */
    1.53  	inline void								Toggle(TInt aFlagIndex);
    1.54  
    1.55 -///////////////////////////////////////////////////////////////////////////////////////
    1.56 +//
    1.57  public:										// OPERATORS
    1.58 -///////////////////////////////////////////////////////////////////////////////////////
    1.59 +//
    1.60  
    1.61  	/**
    1.62  	 * Check if a particular flag is set or not
    1.63 @@ -113,9 +113,9 @@
    1.64  	 */
    1.65  	inline TBool							operator==(const TBitFlagsT& aFlags);
    1.66  
    1.67 -///////////////////////////////////////////////////////////////////////////////////////
    1.68 +//
    1.69  public:										// ACCESS
    1.70 -///////////////////////////////////////////////////////////////////////////////////////
    1.71 +//
    1.72  
    1.73  	/**
    1.74  	 * Check if a particular flag is set
    1.75 @@ -138,18 +138,18 @@
    1.76  	 */
    1.77  	inline void								SetValue(T aFlags) { iFlags = aFlags; }
    1.78  
    1.79 -///////////////////////////////////////////////////////////////////////////////////////
    1.80 +//
    1.81  private:									// INTERNAL
    1.82 -///////////////////////////////////////////////////////////////////////////////////////
    1.83 +//
    1.84  
    1.85  	/**
    1.86  	 * Generate a mask for a particular flag
    1.87  	 */
    1.88  	inline T								FlagMask(TInt aFlagIndex) const;
    1.89  
    1.90 -///////////////////////////////////////////////////////////////////////////////////////
    1.91 +//
    1.92  public:										// MEMBER DATA
    1.93 -///////////////////////////////////////////////////////////////////////////////////////
    1.94 +//
    1.95  	
    1.96  	// The underlying object container which represents the flags.
    1.97  	T										iFlags;
    1.98 @@ -183,9 +183,9 @@
    1.99  typedef TBitFlags32 TBitFlags;
   1.100  
   1.101  
   1.102 -///////////////////////////////////////////////////////////////////////////////////////
   1.103 +//
   1.104  // ----> TBitFlagsT (inlines)
   1.105 -///////////////////////////////////////////////////////////////////////////////////////
   1.106 +//
   1.107  template <class T>
   1.108  inline TBitFlagsT<T>::TBitFlagsT() : iFlags(T(0)) 
   1.109  	{}
   1.110 @@ -204,7 +204,18 @@
   1.111  
   1.112  template <class T>
   1.113  inline TBool TBitFlagsT<T>::IsSet(TInt aFlagIndex) const
   1.114 -	{ return iFlags & FlagMask(aFlagIndex); }
   1.115 +	{ 
   1.116 +	// All out-of-range values should return  false
   1.117 +	if(aFlagIndex <= ((sizeof(T)<<3)-1) )
   1.118 +		{
   1.119 +		return iFlags & FlagMask(aFlagIndex);
   1.120 +		}
   1.121 +	else
   1.122 +		{
   1.123 +		return EFalse;
   1.124 +		}
   1.125 +	 
   1.126 +	}
   1.127  
   1.128  template <class T>
   1.129  inline TBool TBitFlagsT<T>::IsClear(TInt aFlagIndex) const