home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / ibasstrm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  2.6 KB  |  71 lines

  1. /*******************************************************************************
  2. * FILE NAME: ibasstrm.c                                                        *
  3. *                                                                              *
  4. * DESCRIPTION:                                                                 *
  5. *   Definition of the template functions declared in ibasstrm.hpp              *
  6. *     IObjectToNumberElem                                                      *
  7. *                                                                              *
  8. * COPYRIGHT:                                                                   *
  9. *   IBM Open Class Library                                                     *
  10. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  11. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  12. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  13. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  14. * ADDITONAL COPYRIGHTS:                                                        *
  15. *  Copyright (C) 1996, Taligent, Inc. All rights reserved.                     *
  16. *  Copyright (C) 1996, Lotus Development Corporation. All Rights Reserved.     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #include <ibasstrm.hpp>
  20.  
  21. template <class AType>
  22. IBaseStream& operator<<=(IACollection<AType>& c, IBaseStream& s)
  23. {
  24.     unsigned long num;
  25.     num <<= s;
  26.     while ( num-- != 0 ) {
  27.         AType tmp;
  28.         tmp <<= s;
  29.         c.add(tmp);
  30.     }
  31.     return s;
  32. }
  33.  
  34. template <class AType>
  35. IBaseStream& operator>>=(const IACollection<AType>& c, IBaseStream& s)
  36. {
  37.     unsigned long num = c.numberOfElements();
  38.     num >>= s;
  39.     if ( num != 0 ) {
  40.         ICursor& cursor = *c.newCursor();
  41.         for (cursor.setToFirst(); cursor.isValid(); cursor.setToNext()) {
  42.             c.elementAt(cursor) >>= s;
  43.         }
  44.         delete &cursor;
  45.     }
  46.     return s;
  47. }
  48.  
  49.  
  50.  
  51. template <class AType>
  52. IBaseStream& operator<<=( IElemPointer<AType>& source, IBaseStream&  baseStream)
  53. {
  54.     ::resurrect((AType*&)source, baseStream );
  55.     return  baseStream;
  56. }
  57.  
  58. template <class AType>
  59. IBaseStream& operator>>=(const IElemPointer<AType>&target, IBaseStream& baseStream)
  60. {
  61.     ::flatten((AType*)target, baseStream);         // This should probably use a const casting operator, but I don't see one in iptr.h.
  62.     return baseStream;
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.