Make x.0.10 publicly available
[ACE_TAO.git] / ACE / ACEXML / common / HttpCharStream.h
blobf6d7cd167ad10237a2c0f7b8bea78c847bc7c94b
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file HttpCharStream.h
7 * @author Krishnakumar B <kitty@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef _ACEXML_HTTPCHARSTREAM_H_
12 #define _ACEXML_HTTPCHARSTREAM_H_
14 #include /**/ "ace/pre.h"
15 #include "ACEXML/common/ACEXML_Export.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ACEXML/common/CharStream.h"
22 #include "ACEXML/common/URL_Addr.h"
23 #include "ACEXML/common/Mem_Map_Stream.h"
25 /**
26 * @class ACEXML_HttpCharStream
28 * An implementation of ACEXML_CharStream for reading input from a URL.
30 class ACEXML_Export ACEXML_HttpCharStream : public ACEXML_CharStream
32 public:
33 /// Default constructor.
34 ACEXML_HttpCharStream ();
36 /// Destructor
37 virtual ~ACEXML_HttpCharStream ();
39 /// Open an URL.
40 int open (const ACEXML_Char *url);
42 /**
43 * Returns the available ACEXML_Char in the buffer. -1
44 * if the object is not initialized properly.
46 virtual int available ();
48 /**
49 * Close this stream and release all resources used by it.
51 virtual int close ();
53 /**
54 * Read the next ACEXML_Char. Return -1 if we are not able to
55 * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
57 virtual int get (ACEXML_Char& ch);
59 /**
60 * Read the next batch of ACEXML_Char strings
62 virtual int read (ACEXML_Char *str, size_t len);
64 /**
65 * Peek the next ACEXML_Char in the CharStream. Return the
66 * character if succeess, -1 if EOS is reached.
68 virtual int peek ();
70 /**
71 * Resets the file pointer to the beginning of the stream.
73 virtual void rewind ();
75 /**
76 * Determine the encoding of the file.
78 virtual int determine_encoding ();
80 /**
81 * Get the encoding of the file
83 virtual const ACEXML_Char* getEncoding ();
86 * Get the systemId for the underlying CharStream
88 virtual const ACEXML_Char* getSystemId ();
91 private:
92 #if defined (ACE_USES_WCHAR)
93 /**
94 * Read the next character from the stream taking into account the
95 * encoding of the file.
97 int get_i (ACEXML_Char& ch);
99 /**
100 * Read the next character from the stream taking into account the
101 * encoding of the file. Subsequent call to get() returns this
102 * character.
104 int peek_i ();
106 #endif /* ACE_USES_WCHAR */
109 * Send a HTTP/1.1 request to fetch the contents of the URL.
111 int send_request ();
114 * Fetch the URL and save it in backing store.
116 int get_url (size_t& len);
118 ACEXML_Char *url_;
120 ACEXML_URL_Addr* url_addr_;
122 ACEXML_Mem_Map_Stream* stream_;
124 Connector* connector_;
126 ACE_OFF_T size_;
128 ACE_OFF_T data_offset_;
130 ACEXML_Char* encoding_;
134 #include /**/ "ace/post.h"
136 #endif /* _ACEXML_HTTPCHARSTREAM_H_ */