Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

plfilesink.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plfilesink.h,v 1.5 2003/08/03 12:36:56 uzadow 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_PLFILESNK
00013 #define INCL_PLFILESNK
00014 
00015 #ifndef INCL_PLDATASNK
00016 #include "pldatasink.h"
00017 #endif
00018 
00019 #ifdef _WINDOWS
00020 #define PL_FILE_MAPPING
00021 #endif
00022 
00023 #include <stdio.h>
00024 
00025 //! This is a data sink class which takes a file as a destination of picture data.
00026 //!
00027 //! If PL_FILE_MAPPING is defined (this is the case under windows), the data is
00028 //! written directly to the mapped file. If not, the class allocates a buffer 
00029 //! large enough to hold a complete
00030 //! image file. But we don't know its size before it's actually encoded, so
00031 //! we have to be generous or "accidents will happen"
00032 //! TODO: Use mapped files for the *nix version as well.
00033 class PLFileSink : public PLDataSink
00034 {
00035 
00036 public:
00037   //! Create an uninitialized file sink.
00038   PLFileSink
00039     ();
00040 
00041   //!
00042   virtual ~PLFileSink
00043     ();
00044 
00045   //! Open a file sink. Allocates MaxFileSize bytes.
00046   virtual int Open
00047     ( const char * pszFName,
00048       int MaxFileSize
00049     );
00050 #ifdef _WINDOWS
00051     //! Same as open, just for windows wide-char types.
00052   virtual int OpenW
00053     ( const wchar_t * pszwFName,
00054       int MaxFileSize
00055     );
00056 #endif
00057 
00058   //! Flushes the data and closes the file.
00059   virtual void Close
00060     ();
00061 
00062 private:
00063 #ifdef _WINDOWS
00064   int getLastPLError();
00065 #endif  
00066 
00067 #ifdef PL_FILE_MAPPING
00068   HANDLE m_hf;    // File handle.
00069   HANDLE m_hm;    // Handle to file-mapping object.
00070 #else
00071   FILE * m_pFile;
00072 #endif
00073   PLBYTE * m_pDataBuf;
00074 };
00075 
00076 #endif
00077 
00078 /*
00079 /--------------------------------------------------------------------
00080 |
00081 |      $Log: plfilesink.h,v $
00082 |      Revision 1.5  2003/08/03 12:36:56  uzadow
00083 |      Added unicode support; fixed some header includes.
00084 |
00085 |      Revision 1.4  2003/08/03 12:03:20  uzadow
00086 |      Added unicode support; fixed some header includes.
00087 |
00088 |      Revision 1.3  2002/03/31 13:36:41  uzadow
00089 |      Updated copyright.
00090 |
00091 |      Revision 1.2  2001/10/06 22:37:08  uzadow
00092 |      Linux compatibility.
00093 |
00094 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00095 |      Added global name prefix PL, changed most filenames.
00096 |
00097 |      Revision 1.5  2001/09/15 21:02:44  uzadow
00098 |      Cleaned up stdpch.h and config.h to make them internal headers.
00099 |
00100 |      Revision 1.4  2000/01/16 20:43:13  anonymous
00101 |      Removed MFC dependencies
00102 |
00103 |      Revision 1.3  2000/01/08 15:56:12  Ulrich von Zadow
00104 |      Made sure change logging works in every file.
00105 |
00106 |
00107 \--------------------------------------------------------------------
00108 */

Generated on Sun Jun 6 13:42:22 2004 for paintlib by doxygen 1.3.2