home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / classsrc.pak / GEOMSTRM.CPP < prev    next >
C/C++ Source or Header  |  1997-07-23  |  2KB  |  86 lines

  1. //----------------------------------------------------------------------------
  2. // (C) Copyright 1993, 1994 by Borland International, All Rights Reserved
  3. //   Implementation of geometry streaming support
  4. //----------------------------------------------------------------------------
  5.  
  6. #if !defined(_Windows)
  7. # define _Windows      // pretend we are in windows to get the headers we need
  8. #endif
  9.  
  10. #include <osl/defs.h>
  11. #include <osl/geometry.h>
  12.  
  13. ostream& _BIDSFUNC
  14. operator <<(ostream& os, const TRect& r)
  15. {
  16.   return os << '(' << r.left << ',' << r.top << '-'
  17.             << r.right << ',' << r.bottom << ')';
  18. }
  19.  
  20. //
  21. // streaming operators for resource Ids
  22. //
  23. ostream& _BIDSFUNC
  24. operator <<(ostream& os, const TResId& id)
  25. {
  26.   bool  isNumeric = static_cast<bool>(!id.IsString());
  27.  
  28.   if (isNumeric)
  29.     os << (long)id.Id;
  30.  
  31.   else
  32. #if defined(BI_DATA_NEAR)
  33.     os << string(id.Id);
  34. #else
  35.     os << id.Id;
  36. #endif
  37.   return os;
  38. }
  39.  
  40. //! Could break this file in half here...
  41.  
  42. ipstream& _BIDSFUNC
  43. operator >>(ipstream& is, TRect& r)
  44. {
  45.   return is >> r.left >> r.top >> r.right >> r.bottom;
  46. }
  47.  
  48. opstream& _BIDSFUNC
  49. operator <<(opstream& os, const TRect& r)
  50. {
  51.   return os << r.left << r.top << r.right << r.bottom;
  52. }
  53.  
  54. //
  55. // streaming operators for resource Ids
  56. //
  57. ipstream& _BIDSFUNC
  58. operator >>(ipstream& is, TResId& id)
  59. {
  60.   bool  isNumeric;
  61.   is >> isNumeric;
  62.  
  63.   if (isNumeric) {
  64.     long  nid;
  65.     is >> nid;
  66.     id = int(nid);
  67.  
  68.   } else
  69.     id = (const char far *)is.freadString();
  70.   return is;
  71. }
  72.  
  73. opstream& _BIDSFUNC
  74. operator <<(opstream& os, const TResId& id)
  75. {
  76.   bool  isNumeric = static_cast<bool>(!id.IsString());
  77.   os << isNumeric;
  78.  
  79.   if (isNumeric)
  80.     os << (long)id.Id;
  81.  
  82.   else
  83.     os.fwriteString(id.Id);
  84.   return os;
  85. }
  86.