home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWResour / Sources / FWResSin.cpp < prev   
Encoding:
Text File  |  1995-11-08  |  3.5 KB  |  113 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:        FWResSin.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWRESSIN_H
  13. #include "FWResSin.h"
  14. #endif
  15.  
  16. #if FW_LIB_EXPORT_PRAGMAS
  17. #pragma lib_export on
  18. #endif
  19.  
  20. //========================================================================================
  21. //    CLASS FW_CResourceSink
  22. //========================================================================================
  23.  
  24. #pragma segment FW_ResourceSink
  25.  
  26. //----------------------------------------------------------------------------------------
  27. // FW_CResourceSink::FW_CResourceSink
  28. //----------------------------------------------------------------------------------------
  29.  
  30. FW_CResourceSink::FW_CResourceSink(FW_CResource &resource) :
  31.     fResource(resource),
  32.     fMemorySink(resource.GetData(), resource.GetSize(), resource.GetSize())
  33. {
  34.     FW_END_CONSTRUCTOR
  35. }
  36.  
  37. //----------------------------------------------------------------------------------------
  38. // FW_CResourceSink::~FW_CResourceSink
  39. //----------------------------------------------------------------------------------------
  40.  
  41. FW_CResourceSink::~FW_CResourceSink()
  42. {
  43.     FW_START_DESTRUCTOR
  44.     fResource.ReleaseData();
  45. }
  46.  
  47. //----------------------------------------------------------------------------------------
  48. // FW_CResourceSink::Read
  49. //----------------------------------------------------------------------------------------
  50.  
  51. void FW_CResourceSink::Read(void * destination, long count)
  52. {
  53.     fMemorySink.Read(destination, count);
  54. }
  55.     
  56. //----------------------------------------------------------------------------------------
  57. // FW_CResourceSink::GetWritableBytes
  58. //----------------------------------------------------------------------------------------
  59.  
  60. long FW_CResourceSink::GetWritableBytes() const
  61. {
  62.     // Resource sinks are read-only
  63.     return 0;
  64. }
  65.  
  66. //----------------------------------------------------------------------------------------
  67. // FW_CResourceSink::Write
  68. //----------------------------------------------------------------------------------------
  69.  
  70. void FW_CResourceSink::Write(const void* ,
  71.                              long)
  72. {
  73.     // Resource sinks are read-only
  74.     FW_ASSERT(FALSE);
  75. }
  76.  
  77. //----------------------------------------------------------------------------------------
  78. // FW_CResourceSink::GetLength
  79. //----------------------------------------------------------------------------------------
  80.  
  81. long FW_CResourceSink::GetLength() const
  82. {
  83.     return fMemorySink.GetLength();
  84. }
  85.  
  86. //----------------------------------------------------------------------------------------
  87. // FW_CResourceSink::SetLength
  88. //----------------------------------------------------------------------------------------
  89.  
  90. void FW_CResourceSink::SetLength(long length)
  91. {
  92.     fMemorySink.SetLength(length);
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. // FW_CResourceSink::GetPosition
  97. //----------------------------------------------------------------------------------------
  98.  
  99. long FW_CResourceSink::GetPosition() const
  100. {
  101.     return fMemorySink.GetPosition();
  102. }
  103.  
  104. //----------------------------------------------------------------------------------------
  105. // FW_CResourceSink::SetPosition
  106. //----------------------------------------------------------------------------------------
  107.  
  108. void FW_CResourceSink::SetPosition(long position)
  109. {
  110.     fMemorySink.SetPosition(position);
  111. }
  112.     
  113.