diff -r 000000000000 -r 5d03bc08d59c graphicstools/bitmapfonttools/inc/LST.H --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphicstools/bitmapfonttools/inc/LST.H Tue Feb 02 01:47:50 2010 +0200 @@ -0,0 +1,160 @@ +/* +* Copyright (c) 1997-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: +* Header LST.H +* +*/ + + +#ifndef __LST_H__ +#define __LST_H__ + +template +class Link +/** +@publishedAll +WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. +*/ + { +public: + inline Link(); + inline Link(T aT); +public: + Link* iNext; + T iT; + }; + +template +class List +/** +@publishedAll +WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. +*/ + { +public: + inline List(); + inline int Size() const; + inline T& operator [] (const int aNum) const; + inline void Add(T aT); + virtual void Externalize(ostream& out) = 0; + inline void Destroy(); + inline ~List(); +private: + Link *iFirst; + }; + +template +class ObjectList : public List +/** +List of object pointers +@publishedAll +WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. +*/ + { +public: + inline virtual void Externalize(ostream& out); + inline void Destroy(); + }; + +template inline Link::Link() + { + iNext = NULL; + } + +template inline Link::Link(T aT) + { + iT = aT; + iNext = NULL; + } + +template inline List::List() + { + iFirst = NULL; + } + +template inline int List::Size() const + { + int size = 0; + Link* link = iFirst; + while (link != NULL) + { + link = link->iNext; + size++; + } + return size; + } + +template inline T& List::operator [] (const int aNum) const + { + int num = 0; + Link* link = iFirst; + while (num != aNum) + { + link = link->iNext; + num++; + } + return link->iT; + } + +template inline void List::Add(T aT) + { + Link* link; + if (iFirst == NULL) + iFirst = new Link(aT); + else + { + link = iFirst; + while (link->iNext != NULL) + link = link->iNext; + link->iNext = new Link(aT); + } + } + +template inline void List::Destroy() + { + Link* link = iFirst; + Link* next; + while (link != NULL) + { + next = link->iNext; + delete link; + link = next; + } + iFirst = NULL; + } + +template inline List::~List (void) + { + Destroy(); + } + +template inline void ObjectList::Externalize(ostream& out) + { + int32 size = List::Size(); + int32 i; + out.write ((char*) &size, sizeof(size)); + for (i = 0; i < size; i++) + (*this)[i]->Externalize(out); + } + +template inline void ObjectList::Destroy() + { + int size = List::Size(); + int i; + for (i = 0; i < size; i++) + delete (*this)[i]; + List::Destroy(); + } + +#endif