diff -r 000000000000 -r 83f4b4db085c toolsandutils/e32tools/e32image/deflate/farray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolsandutils/e32tools/e32image/deflate/farray.h Tue Feb 02 01:39:43 2010 +0200 @@ -0,0 +1,104 @@ +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32tools\petran\Szip\farray.h +// +// + +#ifndef __FARRAY_H__ +#define __FARRAY_H__ +#include + +template +class TFixedArray +// Range checking wrapper+ class for C++ arrays +// Can be embedded in C-objects, or used on the stack: use Reset() to zero it + { + typedef TFixedArray ThisClass; +public: + inline TFixedArray(); + inline TFixedArray(const T* aList, TInt aLength); + // + inline void Copy(const T* aList, TInt aLength); + inline void Reset(); // zero fill + inline void DeleteAll(); + // + inline TInt Count() const; + inline TInt Length() const; + // Accessors - debug range checking + inline T& operator[](TInt aIndex); + inline const T& operator[] (TInt aIndex) const; + // Accessors - always range checking + inline T& At(TInt aIndex); + inline const T& At(TInt aIndex) const; + // Provides pointers to the beginning and end of the array + inline T* Begin(); + inline T* End(); + inline const T* Begin() const; + inline const T* End() const; + // +protected: + inline static TBool InRange(TInt aIndex); +protected: + T iRep[S]; + }; + +// Template class TFixedArray +IMPORT_C void PanicTFixedArray(); + +template +inline TFixedArray::TFixedArray() + {} +template +inline void TFixedArray::Copy(const T* aList,TInt aLength) + {assert(TUint(aLength)<=TUint(S));HMem::Copy(iRep,aList,aLength*sizeof(T));} +template +inline TFixedArray::TFixedArray(const T* aList,TInt aLength) + {Copy(aList,aLength);} +template +inline void TFixedArray::Reset() + {HMem::FillZ(iRep,sizeof(iRep));} +template +inline TInt TFixedArray::Count() const + {return S;} +template +inline TInt TFixedArray::Length() const + {return sizeof(T);} +template +inline TBool TFixedArray::InRange(TInt aIndex) + {return TUint(aIndex) +inline T& TFixedArray::operator[](TInt aIndex) + {assert(InRange(aIndex));return iRep[aIndex];} +template +inline const T& TFixedArray::operator[](TInt aIndex) const + {return const_cast(*this)[aIndex];} +template +inline T& TFixedArray::At(TInt aIndex) + {verify(InRange(aIndex));return iRep[aIndex];} +template +inline const T& TFixedArray::At(TInt aIndex) const + {return const_cast(*this).At(aIndex);} +template +inline T* TFixedArray::Begin() + {return &iRep[0];} +template +inline T* TFixedArray::End() + {return &iRep[S];} +template +inline const T* TFixedArray::Begin() const + {return &iRep[0];} +template +inline const T* TFixedArray::End() const + {return &iRep[S];} +#endif