Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

HttpCharStream.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    HttpCharStream.h
00006  *
00007  *  $Id: HttpCharStream.h,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Krishnakumar B <kitty@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef _ACEXML_HTTPCHARSTREAM_H_
00014 #define _ACEXML_HTTPCHARSTREAM_H_
00015 
00016 #include "ace/pre.h"
00017 #include "ACEXML/common/ACEXML_Export.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 #pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ACEXML/common/CharStream.h"
00024 #include "ACEXML/common/URL_Addr.h"
00025 #include "ACEXML/common/Mem_Map_Stream.h"
00026 #include "ace/streams.h"
00027 
00028 /**
00029  * @class ACEXML_HttpCharStream HttpCharStream.h "ACEXML/common/HttpCharStream.h"
00030  *
00031  * An implementation of ACEXML_CharStream for reading input from a URL.
00032  */
00033 class ACEXML_Export ACEXML_HttpCharStream : public ACEXML_CharStream
00034 {
00035 public:
00036   /// Default constructor.
00037   ACEXML_HttpCharStream (void);
00038 
00039   /// Destructor
00040   virtual ~ACEXML_HttpCharStream (void);
00041 
00042   /// Open an URL.
00043   int open (const ACEXML_Char *url);
00044 
00045   /**
00046    *  Returns the available ACEXML_Char in the buffer.  -1
00047    *  if the object is not initialized properly.
00048    */
00049   virtual int available (void);
00050 
00051   /**
00052    *  Close this stream and release all resources used by it.
00053    */
00054   virtual int close (void);
00055 
00056   /**
00057    *  Read the next ACEXML_Char.  Return -1 if we are not able to
00058    *  return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
00059    */
00060   virtual int get (ACEXML_Char& ch);
00061 
00062   /**
00063    *  Read the next batch of ACEXML_Char strings
00064    */
00065   virtual int read (ACEXML_Char *str,
00066                     size_t len);
00067 
00068   /**
00069    *  Peek the next ACEXML_Char in the CharStream.  Return the
00070    *  character if succeess, -1 if EOS is reached.
00071    */
00072   virtual int peek (void);
00073 
00074   /**
00075    *  Resets the file pointer to the beginning of the stream.
00076    */
00077   virtual void rewind (void);
00078 
00079   /**
00080    * Get the encoding of the file
00081    */
00082   virtual const ACEXML_Char* getEncoding (void);
00083 
00084 private:
00085 
00086   /**
00087    *  Send a HTTP/1.1 request to fetch the contents of the URL.
00088    */
00089   int send_request (void);
00090 
00091   /**
00092    *  Fetch the URL and save it in backing store.
00093    */
00094   int get_url (size_t& len);
00095 
00096   ACEXML_Char *url_;
00097 
00098   ACEXML_URL_Addr* url_addr_;
00099 
00100   ACEXML_Mem_Map_Stream* stream_;
00101 
00102   Connector* connector_;
00103 
00104   off_t size_;
00105 
00106   ACEXML_Char* encoding_;
00107 
00108 };
00109 
00110 
00111 #include "ace/post.h"
00112 
00113 #endif /* _ACEXML_HTTPCHARSTREAM_H_ */

Generated on Mon Jun 16 13:23:22 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002