1.1 --- a/epoc32/include/cstack.inl Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/cstack.inl Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,102 @@
1.4 -cstack.inl
1.5 +// Copyright (c) 2000-2009 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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef __CSTACK_INL__
1.21 +#define __CSTACK_INL__
1.22 +
1.23 +// constants
1.24 +const TInt KStackGranularity=32;
1.25 +
1.26 +enum TCStackPanic
1.27 + {
1.28 + ECStackErrStackIsEmpty,
1.29 + ECStackDeleteWhenNotOwner,
1.30 + ECStackPopsWhenOwner
1.31 + };
1.32 +
1.33 +_LIT(KCStackPanicName, "CStack");
1.34 +
1.35 +inline void Panic(TCStackPanic aPanic)
1.36 + {
1.37 + User::Panic(KCStackPanicName, aPanic);
1.38 + }
1.39 +
1.40 +//
1.41 +// CStack
1.42 +//
1.43 +
1.44 +template <class T, TBool StackOwnsEntry>
1.45 +inline CStack<T, StackOwnsEntry>::CStack()
1.46 +: CArrayPtrSeg<T>(KStackGranularity)
1.47 + {
1.48 + this->Reset();
1.49 + }
1.50 +
1.51 +template <class T, TBool StackOwnsEntry>
1.52 +inline CStack<T, StackOwnsEntry>::~CStack()
1.53 + {
1.54 + Clear();
1.55 + }
1.56 +
1.57 +template <class T, TBool StackOwnsEntry>
1.58 +inline void CStack<T, StackOwnsEntry>::Clear()
1.59 + {
1.60 + if (StackOwnsEntry)
1.61 + this->ResetAndDestroy();
1.62 + else
1.63 + this->Reset();
1.64 + }
1.65 +
1.66 +template <class T, TBool StackOwnsEntry>
1.67 +inline TBool CStack<T, StackOwnsEntry>::IsEmpty() const
1.68 + {
1.69 + return this->Count()==0;
1.70 + }
1.71 +
1.72 +template <class T, TBool StackOwnsEntry>
1.73 +inline void CStack<T, StackOwnsEntry>::PushL(T* aItem)
1.74 + {
1.75 + if (StackOwnsEntry)
1.76 + CleanupStack::PushL(aItem);
1.77 + this->AppendL(aItem);
1.78 + if (StackOwnsEntry)
1.79 + CleanupStack::Pop();
1.80 + }
1.81 +
1.82 +template <class T, TBool StackOwnsEntry>
1.83 +inline T* CStack<T, StackOwnsEntry>::Pop()
1.84 + {
1.85 + __ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
1.86 + T* item=Head();
1.87 + this->Delete(this->Count()-1);
1.88 + return item;
1.89 + }
1.90 +
1.91 +template <class T, TBool StackOwnsEntry>
1.92 +inline T* CStack<T, StackOwnsEntry>::Head() const
1.93 + {
1.94 + __ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
1.95 + return this->At(this->Count()-1);
1.96 + }
1.97 +
1.98 +template <class T, TBool StackOwnsEntry>
1.99 +inline T* CStack<T, StackOwnsEntry>::Last() const
1.100 + {
1.101 + __ASSERT_DEBUG(!IsEmpty(), Panic(ECStackErrStackIsEmpty));
1.102 + return this->At(0);
1.103 + }
1.104 +
1.105 +
1.106 +#endif // __CSTACK_INL__