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

plurlsrc.h

00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plurlsrc_8h-source.html,v 1.4 2004/09/15 15:26:32 uzadow Exp $
00005 |
00006 |      Copyright (c) 1996-2002 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_PLURLSRC
00012 #define INCL_PLURLSRC
00013 
00014 #ifndef INCL_PLDATASRC
00015 #include "pldatasrc.h"
00016 #endif
00017 
00018 #include <string>
00019 #include <curl/curl.h>
00020 
00021 // Internal singleton class that initializes and deinitializes curl
00022 class PLCurlInitializer
00023 {
00024 public:
00025   CURL * getHandle();
00026   void finalize();
00027 
00028 private:
00029   friend class PLURLSource;
00030   PLCurlInitializer();
00031   ~PLCurlInitializer();
00032 
00033   CURL * m_CurlHandle;
00034 
00035 };
00036 
00037 // This is a class which takes a URL as a source of
00038 // picture data.
00039 class PLURLSource : public PLDataSource
00040 {
00041 public:
00042   //!
00043   PLURLSource
00044     ();
00045 
00046   //!
00047   virtual ~PLURLSource
00048     ();
00049 
00050   //!
00051   virtual int Open(const char *pURL);
00052 
00053   //!
00054   virtual void Close
00055     ();
00056 
00057   virtual PLBYTE * ReadNBytes
00058     ( int n
00059     );
00060 
00061   //! Read but don't advance file pointer.
00062   virtual PLBYTE * GetBufferPtr
00063     ( int MinBytesInBuffer
00064     );
00065 
00066   //! This is a legacy routine that interferes with progress notifications.
00067   //! Don't call it!
00068   virtual PLBYTE * ReadEverything
00069     ();
00070 
00071   virtual void Seek
00072     ( int n
00073     );
00074 
00075   const char * GetCurlErrStr ();
00076   int GetCurlErrCode ();
00077 
00078 private:
00079   static size_t WriteCurlData(void *ptr, size_t size, size_t nmemb, void *stream);
00080   const std::string httpErr2Str(int HTTPCode);
00081   // So curl gets initialized once only.
00082   static PLCurlInitializer s_CurlInitializer;
00083   std::string m_RawData;
00084   int m_CurPos;
00085 
00086   std::string m_sErrStr;
00087   int m_ErrCode;
00088 };
00089 
00090 #endif
00091 /*
00092 /--------------------------------------------------------------------
00093 |
00094 |      $Log: plurlsrc_8h-source.html,v $
00094 |      Revision 1.4  2004/09/15 15:26:32  uzadow
00094 |      Linux compatibility changes, doc update.
00094 |
00095 |      Revision 1.4  2004/08/20 14:39:38  uzadow
00096 |      Added rle format to sgi decoder. Doesn't work yet, though.
00097 |
00098 |      Revision 1.3  2003/04/20 12:44:47  uzadow
00099 |      Added EXIF documentation.
00100 |
00101 |      Revision 1.2  2003/04/14 10:48:19  uzadow
00102 |      Added connection reuse capability to PLURLSource.
00103 |
00104 |      Revision 1.1  2003/02/15 21:26:58  uzadow
00105 |      Added win32 version of url data source.
00106 |
00107 |
00108 \--------------------------------------------------------------------
00109 */

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