1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * $Log: BinURLInputStream.hpp,v $
|
---|
59 | * Revision 1.5 2004/01/29 11:51:20 cargilld
|
---|
60 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
61 | *
|
---|
62 | * Revision 1.4 2004/01/15 16:07:16 amassari
|
---|
63 | * Fix for bug#24929; patch by Michael Wuschek
|
---|
64 | *
|
---|
65 | * Revision 1.3 2003/05/17 05:54:18 knoaman
|
---|
66 | * Update NetAccessors to use the memory manager.
|
---|
67 | *
|
---|
68 | * Revision 1.2 2002/11/04 15:11:39 tng
|
---|
69 | * C++ Namespace Support.
|
---|
70 | *
|
---|
71 | * Revision 1.1.1.1 2002/02/01 22:22:22 peiyongz
|
---|
72 | * sane_include
|
---|
73 | *
|
---|
74 | * Revision 1.2 2000/02/26 07:56:36 rahulj
|
---|
75 | * Fixed the license header as pointed out by Bill Schindler <developer@bitranch.com>
|
---|
76 | *
|
---|
77 | * Revision 1.1 2000/02/17 22:06:19 rahulj
|
---|
78 | * Moved the four LibWWW files to its own sub-directory in the
|
---|
79 | * NetAccessor directory.
|
---|
80 | *
|
---|
81 | *
|
---|
82 | * Revision 1.1 2000/01/15 01:08:04 rahulj
|
---|
83 | * Added support for HTTP to the parser.
|
---|
84 | * Error handling is not very good. Also cannot guarantee that
|
---|
85 | * there are no memory leaks.
|
---|
86 | * Only tested under NT 4.0 SP 5 using libWWW 5.2.8.
|
---|
87 | *
|
---|
88 | */
|
---|
89 |
|
---|
90 | #if !defined(BINURLINPUTSTREAM_HPP)
|
---|
91 | #define BINURLINPUTSTREAM_HPP
|
---|
92 |
|
---|
93 |
|
---|
94 | #include <xercesc/util/XMLURL.hpp>
|
---|
95 | #include <xercesc/util/XMLExceptMsgs.hpp>
|
---|
96 | #include <xercesc/util/BinInputStream.hpp>
|
---|
97 |
|
---|
98 | //
|
---|
99 | // Forward reference the libWWW constructs here, so as to avoid including
|
---|
100 | // any of the libWWW headers in this file. Just being careful in isolating
|
---|
101 | // the files that explicitly need to include the libWWW headers.
|
---|
102 | //
|
---|
103 |
|
---|
104 | struct _HTAnchor;
|
---|
105 |
|
---|
106 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
107 |
|
---|
108 | //
|
---|
109 | // This class implements the BinInputStream interface specified by the XML
|
---|
110 | // parser.
|
---|
111 | //
|
---|
112 |
|
---|
113 | class XMLUTIL_EXPORT BinURLInputStream : public BinInputStream
|
---|
114 | {
|
---|
115 | public :
|
---|
116 | BinURLInputStream(const XMLURL& urlSource);
|
---|
117 | ~BinURLInputStream();
|
---|
118 |
|
---|
119 | unsigned int curPos() const;
|
---|
120 | unsigned int readBytes
|
---|
121 | (
|
---|
122 | XMLByte* const toFill
|
---|
123 | , const unsigned int maxToRead
|
---|
124 | );
|
---|
125 | void reset();
|
---|
126 | unsigned int bytesAvail() const;
|
---|
127 |
|
---|
128 |
|
---|
129 | private :
|
---|
130 | // -----------------------------------------------------------------------
|
---|
131 | // Unimplemented constructors and operators
|
---|
132 | // -----------------------------------------------------------------------
|
---|
133 | BinURLInputStream(const BinURLInputStream&);
|
---|
134 | BinURLInputStream& operator=(const BinURLInputStream&);
|
---|
135 |
|
---|
136 | // -----------------------------------------------------------------------
|
---|
137 | // Private data members
|
---|
138 | //
|
---|
139 | // fAnchor
|
---|
140 | // This is the handle that LibWWW returns for the remote file that
|
---|
141 | // is being addressed.
|
---|
142 | // fBuffer
|
---|
143 | // This is the array in which the data is stored after reading it
|
---|
144 | // of the network. The maximum size of this array is decided in the
|
---|
145 | // constructor via a file specific #define.
|
---|
146 | // fBufferIndex
|
---|
147 | // Its the index into fBuffer and points to the next unprocessed
|
---|
148 | // character. When the parser asks for more data to be read of the
|
---|
149 | // stream, then fBuffer[fBufferIndex] is the first byte returned,
|
---|
150 | // unless fBufferIndex equals fBufferSize indicating that all
|
---|
151 | // data in the fBuffer has been processed.
|
---|
152 | // fBufferSize
|
---|
153 | // This represents the extent of valid data in the fBuffer array.
|
---|
154 | // fRemoteFileSize
|
---|
155 | // This stores the size in bytes of the remote file addressed by
|
---|
156 | // this URL input stream.
|
---|
157 | // fBytesProcessed
|
---|
158 | // Its a rolling count of the number of bytes processed off this
|
---|
159 | // input stream. Its only reset back to zero, if the stream is
|
---|
160 | // reset. The maximum value this can have is fRemoteFileSize.
|
---|
161 | // -----------------------------------------------------------------------
|
---|
162 |
|
---|
163 | struct _HTAnchor* fAnchor;
|
---|
164 | XMLByte* fBuffer;
|
---|
165 | unsigned int fBufferIndex;
|
---|
166 | unsigned int fBufferSize;
|
---|
167 | unsigned int fRemoteFileSize;
|
---|
168 | unsigned int fBytesProcessed;
|
---|
169 | MemoryManager* fMemoryManager;
|
---|
170 | };
|
---|
171 |
|
---|
172 | XERCES_CPP_NAMESPACE_END
|
---|
173 |
|
---|
174 | #endif // BINURLINPUTSTREAM_HPP
|
---|