BinURLInputStream.hpp
上传用户:zhuqijet
上传日期:2013-06-25
资源大小:10074k
文件大小:6k
源码类别:

词法分析

开发平台:

Visual C++

  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.  * $Log: BinURLInputStream.hpp,v $
  58.  * Revision 1.3  2003/05/17 05:54:18  knoaman
  59.  * Update NetAccessors to use the memory manager.
  60.  *
  61.  * Revision 1.2  2002/11/04 15:11:39  tng
  62.  * C++ Namespace Support.
  63.  *
  64.  * Revision 1.1.1.1  2002/02/01 22:22:22  peiyongz
  65.  * sane_include
  66.  *
  67.  * Revision 1.2  2000/02/26 07:56:36  rahulj
  68.  * Fixed the license header as pointed out by Bill Schindler <developer@bitranch.com>
  69.  *
  70.  * Revision 1.1  2000/02/17 22:06:19  rahulj
  71.  * Moved the four LibWWW files to its own sub-directory in the
  72.  * NetAccessor directory.
  73.  *
  74.  *
  75.  * Revision 1.1  2000/01/15 01:08:04  rahulj
  76.  * Added support for HTTP to the parser.
  77.  * Error handling is not very good. Also cannot guarantee that
  78.  * there are no memory leaks.
  79.  * Only tested under NT 4.0 SP 5 using libWWW 5.2.8.
  80.  *
  81.  */
  82. #if !defined(BINURLINPUTSTREAM_HPP)
  83. #define BINURLINPUTSTREAM_HPP
  84. #include <xercesc/util/XMLURL.hpp>
  85. #include <xercesc/util/XMLExceptMsgs.hpp>
  86. #include <xercesc/util/BinInputStream.hpp>
  87. XERCES_CPP_NAMESPACE_BEGIN
  88. //
  89. // Forward reference the libWWW constructs here, so as to avoid including
  90. // any of the libWWW headers in this file. Just being careful in isolating
  91. // the files that explicitly need to include the libWWW headers.
  92. //
  93. struct _HTAnchor;
  94. //
  95. // This class implements the BinInputStream interface specified by the XML
  96. // parser.
  97. //
  98. class XMLUTIL_EXPORT BinURLInputStream : public BinInputStream
  99. {
  100. public :
  101.     BinURLInputStream(const XMLURL&  urlSource);
  102.     ~BinURLInputStream();
  103.     unsigned int curPos() const;
  104.     unsigned int readBytes
  105.     (
  106.                 XMLByte* const  toFill
  107.         , const unsigned int    maxToRead
  108.     );
  109.     void reset();
  110.     unsigned int bytesAvail() const;
  111. private :
  112.     // -----------------------------------------------------------------------
  113.     //  Private data members
  114.     //
  115.     //  fAnchor
  116.     //      This is the handle that LibWWW returns for the remote file that
  117.     //      is being addressed.
  118.     //  fBuffer
  119.     //      This is the array in which the data is stored after reading it
  120.     //      of the network. The maximum size of this array is decided in the
  121.     //      constructor via a file specific #define.
  122.     //  fBufferIndex
  123.     //      Its the index into fBuffer and points to the next unprocessed
  124.     //      character. When the parser asks for more data to be read of the
  125.     //      stream, then fBuffer[fBufferIndex] is the first byte returned,
  126.     //      unless fBufferIndex equals fBufferSize indicating that all
  127.     //      data in the fBuffer has been processed.
  128.     //  fBufferSize
  129.     //      This represents the extent of valid data in the fBuffer array.
  130.     //  fRemoteFileSize
  131.     //      This stores the size in bytes of the remote file addressed by
  132.     //      this URL input stream.
  133.     //  fBytesProcessed
  134.     //      Its a rolling count of the number of bytes processed off this
  135.     //      input stream. Its only reset back to zero, if the stream is
  136.     //      reset. The maximum value this can have is fRemoteFileSize.
  137.     // -----------------------------------------------------------------------
  138.     struct _HTAnchor*   fAnchor;
  139.     XMLByte*            fBuffer;
  140.     unsigned int        fBufferIndex;
  141.     unsigned int        fBufferSize;
  142.     unsigned int        fRemoteFileSize;
  143.     unsigned int        fBytesProcessed;
  144.     MemoryManager*      fMemoryManager;
  145. };
  146. XERCES_CPP_NAMESPACE_END
  147. #endif // BINURLINPUTSTREAM_HPP