Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

pldatasink.h

Go to the documentation of this file.
00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: pldatasink.h,v 1.1 2004/05/21 21:02:52 maxx Exp $
00005 |
00006 |      Copyright (c) 1996-2002 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 // not quite ready for prime-time; bdelmee; 2/99
00011 
00012 #ifndef INCL_PLDATASNK
00013 #define INCL_PLDATASNK
00014 
00015 #include "plexcept.h"
00016 #include "plpaintlibdefs.h"
00017 
00018 #include <stdio.h>
00019 
00025 class PLDataSink : public PLObject
00026 {
00027   // I'd like to get rid of this, but now it is needed so the encoders
00028   // can maintain the actually useful length of the buffer
00029   friend class PLTIFFEncoder;
00030   friend class PLTIFFEncoderEx;
00031 
00032 public:
00034   void Open
00035     ( const char* pszName,
00036       PLBYTE*   pData,
00037       size_t  MaxDataSize
00038     );
00039 
00041   virtual void Close
00042     ();
00043 
00045   char* GetName
00046     ();
00047 
00049   PLBYTE* GetBufferPtr
00050     ();
00051 
00053   size_t GetDataSize
00054     ();
00055 
00057   size_t GetMaxDataSize
00058     ();
00059 
00061   size_t WriteNBytes
00062     ( size_t   n,
00063           PLBYTE* pData
00064     );
00065 
00066   void WriteByte
00067     ( PLBYTE Data
00068     );
00069 
00071   void Skip
00072     ( size_t n );
00073 
00075   void CheckEOF
00076     ();
00077 
00078 protected:
00079   PLBYTE* m_pStartData;
00080   int   m_nCurPos;   // this SHOULD be an unsigned int (size_t), but TIFFLib wants an int
00081 
00083   PLDataSink
00084     ();
00085 
00087   virtual ~PLDataSink
00088    ();
00089 
00090 private:
00091   char*  m_pszName;    // Name of the data source for diagnostic purposes
00092   size_t m_nMaxFileSize;
00093 };
00094 
00095 
00096 inline PLBYTE * PLDataSink::GetBufferPtr
00097     ()
00098 {
00099         return m_pStartData + m_nCurPos;
00100 }
00101 
00102 inline size_t PLDataSink::GetMaxDataSize
00103     ()
00104 {
00105   return  m_nMaxFileSize;
00106 }
00107 
00108 inline size_t PLDataSink::GetDataSize
00109     ()
00110 {
00111   // return currently used buffer size
00112   return m_nCurPos;
00113 }
00114 
00115 inline void PLDataSink::CheckEOF
00116     ()
00117 {
00118   //if (GetFileSize() > GetMaxFileSize())
00119   if (m_nCurPos > (int)m_nMaxFileSize)
00120   {
00121     throw PLTextException (PL_ERREND_OF_FILE,
00122           "Buffer overflow while encoding.\n");
00123   }
00124 }
00125 
00126 inline void PLDataSink::Skip
00127     ( size_t n )
00128 {
00129         // maybe we should fill the gap with nulls
00130   m_nCurPos += n;
00131   CheckEOF ();
00132 }
00133 
00134 #endif  // INCL_PLDATASNK
00135 /*
00136 /--------------------------------------------------------------------
00137 |
00138 |      $Log: pldatasink.h,v $
00139 |      Revision 1.1  2004/05/21 21:02:52  maxx
00140 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00141 |
00142 |      Revision 1.1  2002/11/13 01:58:21  mspindle
00143 |      *** empty log message ***
00144 |
00145 |      Revision 1.4  2002/02/24 13:00:20  uzadow
00146 |      Documentation update; removed buggy PLFilterRotate.
00147 |
00148 |      Revision 1.3  2001/10/06 22:03:26  uzadow
00149 |      Added PL prefix to basic data types.
00150 |
00151 |      Revision 1.2  2001/10/06 20:44:45  uzadow
00152 |      Linux compatibility
00153 |
00154 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00155 |      Added global name prefix PL, changed most filenames.
00156 |
00157 |      Revision 1.5  2000/01/16 20:43:13  anonymous
00158 |      Removed MFC dependencies
00159 |
00160 |      Revision 1.4  2000/01/08 15:56:12  Ulrich von Zadow
00161 |      Made sure change logging works in every file.
00162 |
00163 |
00164 \--------------------------------------------------------------------
00165 */

Generated on Wed Dec 15 21:20:30 2004 for vuVolume by  doxygen 1.3.9.1