convert line ends
[canaan.git] / prj / tech / libsrc / cpptools / dlisttem.h
blob780848e184081a11e0ae3ced5d168cb917cb0fdb
1 ///////////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/cpptools/RCS/dlisttem.h $
3 // $Author: TOML $
4 // $Date: 1997/06/24 18:07:07 $
5 // $Revision: 1.3 $
6 //
7 // (c) Copyright 1993-1996 Tom Leonard. All Rights Reserved. Unlimited license granted to Looking Glass Technologies Inc.
8 //
10 #ifndef __DLISTTEM_H
11 #define __DLISTTEM_H
13 //include "storintr.h"
15 #ifdef DEBUG_DLIST_TEM
16 #pragma message "DEBUG_DLIST_TEM enabled"
17 #define DListTemDebugStr(s) DebugStr(s)
18 #else
19 #define DListTemDebugStr(s)
20 #endif
22 ///////////////////////////////////////////////////////////////////////////////
24 template <class NODE, int ID>
25 void cDList<NODE, ID>::DestroyAll()
27 while (GetFirst())
28 delete Remove(GetFirst());
31 #if 0
32 ///////////////////////////////////////
34 // Write a list to a stream
36 template <class NODE, int ID>
37 BOOL cSerialDList<NODE, ID>::ToStream(cOStore &OStore) const
39 typedef cDListNode<NODE, ID> cNode;
41 NODE *p = GetFirst();
43 if (!OStore.WriteHeader("DLIST"))
44 return FALSE;
46 long i = 0;
47 while (p)
49 if (!OStore.To(i++))
50 return FALSE;
52 if (!p->ToStream(OStore))
53 return FALSE;
55 p = p->cNode::GetNext();
58 if (!OStore.To(-1L))
59 return FALSE;
61 return OStore.WriteTrailer();
65 ///////////////////////////////////////
67 // Fill a list from a stream
69 template <class NODE, int ID>
70 BOOL cSerialDList<NODE, ID>::FromStream(cIStore &IStore)
72 if (!IStore.ReadHeader("DLIST"))
73 return FALSE;
75 long i = 0;
76 long j;
77 for (;;)
79 if (!IStore.From(j))
81 DListTemDebugStr("cSerialDList<NODE, ID>::FromStream() -> FALSE: no/empty list");
82 return FALSE;
85 if (j != i++)
86 break;
88 NODE *p = new NODE;
89 p->FromStream(IStore);
90 Append(*p);
93 if (j != -1L)
95 DListTemDebugStr(cFmtStr("cSerialDList<NODE, ID>::FromStream() failed: %ld != -1L, i==%ld", j, i));
96 return IStore.Fail();
99 return IStore.ReadTrailer();
101 #endif
103 ///////////////////////////////////////////////////////////////////////////////
105 #endif /* !__DLISTTEM_H */