home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / CLASSSRC.PAK / REGLINK.CPP < prev    next >
C/C++ Source or Header  |  1995-08-29  |  1KB  |  46 lines

  1. //----------------------------------------------------------------------------
  2. // (C) Copyright 1994 by Borland International, All Rights Reserved
  3. //
  4. //----------------------------------------------------------------------------
  5. #if !defined(_Windows)
  6. # define _Windows      // pretend we are in windows to get the headers we need
  7. #endif
  8. #include <osl/locale.h>
  9. #include <string.h>
  10.  
  11. //
  12. // Construct a reglink pointing to a reglist, and add to end of list
  13. //
  14. TRegLink::TRegLink(TRegList& regList, TRegLink*& head)
  15. :
  16.   RegList(®List),
  17.   Next(0)
  18. {
  19.   AddLink(head, *this);
  20. }
  21.  
  22. //
  23. // Add a new link to the end of the link list
  24. //
  25. void TRegLink::AddLink(TRegLink*& head, TRegLink& newLink)
  26. {
  27.   TRegLink** link = &head;
  28.   while (*link)                 // put new link at end of list
  29.     link = &(*link)->Next;
  30.   *link = &newLink;
  31. }
  32.  
  33. //
  34. // Remove a link from the link list. Return true if link found & removed
  35. //
  36. bool TRegLink::RemoveLink(TRegLink*& head, TRegLink& remLink)
  37. {
  38.   for (TRegLink** link = &head; *link; link = &(*link)->Next) {
  39.     if (*link == &remLink) {
  40.       *link = (*link)->Next;     // remove from list
  41.       return true;
  42.     }
  43.   }
  44.   return false;
  45. }
  46.