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

plfilesink.h

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

Generated on Mon Sep 13 16:16:40 2004 for paintlib by doxygen 1.3.2