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