[2674] | 1 | /* |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 4 | * this work for additional information regarding copyright ownership. |
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 6 | * (the "License"); you may not use this file except in compliance with |
---|
| 7 | * the License. You may obtain a copy of the License at |
---|
| 8 | * |
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 10 | * |
---|
| 11 | * Unless required by applicable law or agreed to in writing, software |
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 14 | * See the License for the specific language governing permissions and |
---|
| 15 | * limitations under the License. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | /* |
---|
| 19 | * $Id: BinURLInputStream.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(BINURLINPUTSTREAM_HPP) |
---|
| 23 | #define BINURLINPUTSTREAM_HPP |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | #include <xercesc/util/XMLURL.hpp> |
---|
| 27 | #include <xercesc/util/XMLExceptMsgs.hpp> |
---|
| 28 | #include <xercesc/util/BinInputStream.hpp> |
---|
| 29 | |
---|
| 30 | // |
---|
| 31 | // Forward reference the libWWW constructs here, so as to avoid including |
---|
| 32 | // any of the libWWW headers in this file. Just being careful in isolating |
---|
| 33 | // the files that explicitly need to include the libWWW headers. |
---|
| 34 | // |
---|
| 35 | |
---|
| 36 | struct _HTAnchor; |
---|
| 37 | |
---|
| 38 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 39 | |
---|
| 40 | // |
---|
| 41 | // This class implements the BinInputStream interface specified by the XML |
---|
| 42 | // parser. |
---|
| 43 | // |
---|
| 44 | |
---|
| 45 | class XMLUTIL_EXPORT BinURLInputStream : public BinInputStream |
---|
| 46 | { |
---|
| 47 | public : |
---|
| 48 | BinURLInputStream(const XMLURL& urlSource); |
---|
| 49 | ~BinURLInputStream(); |
---|
| 50 | |
---|
| 51 | unsigned int curPos() const; |
---|
| 52 | unsigned int readBytes |
---|
| 53 | ( |
---|
| 54 | XMLByte* const toFill |
---|
| 55 | , const unsigned int maxToRead |
---|
| 56 | ); |
---|
| 57 | void reset(); |
---|
| 58 | unsigned int bytesAvail() const; |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | private : |
---|
| 62 | // ----------------------------------------------------------------------- |
---|
| 63 | // Unimplemented constructors and operators |
---|
| 64 | // ----------------------------------------------------------------------- |
---|
| 65 | BinURLInputStream(const BinURLInputStream&); |
---|
| 66 | BinURLInputStream& operator=(const BinURLInputStream&); |
---|
| 67 | |
---|
| 68 | // ----------------------------------------------------------------------- |
---|
| 69 | // Private data members |
---|
| 70 | // |
---|
| 71 | // fAnchor |
---|
| 72 | // This is the handle that LibWWW returns for the remote file that |
---|
| 73 | // is being addressed. |
---|
| 74 | // fBuffer |
---|
| 75 | // This is the array in which the data is stored after reading it |
---|
| 76 | // of the network. The maximum size of this array is decided in the |
---|
| 77 | // constructor via a file specific #define. |
---|
| 78 | // fBufferIndex |
---|
| 79 | // Its the index into fBuffer and points to the next unprocessed |
---|
| 80 | // character. When the parser asks for more data to be read of the |
---|
| 81 | // stream, then fBuffer[fBufferIndex] is the first byte returned, |
---|
| 82 | // unless fBufferIndex equals fBufferSize indicating that all |
---|
| 83 | // data in the fBuffer has been processed. |
---|
| 84 | // fBufferSize |
---|
| 85 | // This represents the extent of valid data in the fBuffer array. |
---|
| 86 | // fRemoteFileSize |
---|
| 87 | // This stores the size in bytes of the remote file addressed by |
---|
| 88 | // this URL input stream. |
---|
| 89 | // fBytesProcessed |
---|
| 90 | // Its a rolling count of the number of bytes processed off this |
---|
| 91 | // input stream. Its only reset back to zero, if the stream is |
---|
| 92 | // reset. The maximum value this can have is fRemoteFileSize. |
---|
| 93 | // ----------------------------------------------------------------------- |
---|
| 94 | |
---|
| 95 | struct _HTAnchor* fAnchor; |
---|
| 96 | XMLByte* fBuffer; |
---|
| 97 | unsigned int fBufferIndex; |
---|
| 98 | unsigned int fBufferSize; |
---|
| 99 | int fRemoteFileSize; |
---|
| 100 | unsigned int fBytesProcessed; |
---|
| 101 | MemoryManager* fMemoryManager; |
---|
| 102 | }; |
---|
| 103 | |
---|
| 104 | XERCES_CPP_NAMESPACE_END |
---|
| 105 | |
---|
| 106 | #endif // BINURLINPUTSTREAM_HPP |
---|