BinMemInputStream.hpp

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  * 
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  *
00020  * Revision 1.5  2004/09/08 13:56:21  peiyongz
00021  * Apache License Version 2.0
00022  *
00023  * Revision 1.4  2004/01/29 11:48:46  cargilld
00024  * Code cleanup changes to get rid of various compiler diagnostic messages.
00025  *
00026  * Revision 1.3  2003/05/16 03:11:22  knoaman
00027  * Partial implementation of the configurable memory manager.
00028  *
00029  * Revision 1.2  2002/11/04 15:22:03  tng
00030  * C++ Namespace Support.
00031  *
00032  * Revision 1.1.1.1  2002/02/01 22:22:10  peiyongz
00033  * sane_include
00034  *
00035  * Revision 1.3  2000/02/24 20:05:24  abagchi
00036  * Swat for removing Log from API docs
00037  *
00038  * Revision 1.2  2000/02/06 07:48:01  rahulj
00039  * Year 2K copyright swat.
00040  *
00041  * Revision 1.1.1.1  1999/11/09 01:04:07  twl
00042  * Initial checkin
00043  *
00044  * Revision 1.3  1999/11/08 20:45:04  rahul
00045  * Swat for adding in Product name and CVS comment log variable.
00046  *
00047  */
00048 
00049 #if !defined(BINMEMINPUTSTREAM_HPP)
00050 #define BINMEMINPUTSTREAM_HPP
00051 
00052 #include <xercesc/util/BinInputStream.hpp>
00053 #include <xercesc/util/PlatformUtils.hpp>
00054 
00055 XERCES_CPP_NAMESPACE_BEGIN
00056 
00057 class XMLUTIL_EXPORT BinMemInputStream : public BinInputStream
00058 {
00059 public :
00060     // -----------------------------------------------------------------------
00061     //  Class specific types
00062     // -----------------------------------------------------------------------
00063     enum BufOpts
00064     {
00065         BufOpt_Adopt
00066         , BufOpt_Copy
00067         , BufOpt_Reference
00068     };
00069 
00070 
00071     // -----------------------------------------------------------------------
00072     //  Constructors and Destructor
00073     // -----------------------------------------------------------------------
00074     BinMemInputStream
00075     (
00076         const   XMLByte* const  initData
00077         , const unsigned int    capacity
00078         , const BufOpts         bufOpt = BufOpt_Copy
00079         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
00080     );
00081     virtual ~BinMemInputStream();
00082 
00083 
00084     // -----------------------------------------------------------------------
00085     //  Stream management methods
00086     // -----------------------------------------------------------------------
00087     void reset();
00088 
00089 
00090     // -----------------------------------------------------------------------
00091     //  Implementation of the input stream interface
00092     // -----------------------------------------------------------------------
00093     virtual unsigned int curPos() const;
00094 
00095     virtual unsigned int readBytes
00096     (
00097                 XMLByte* const  toFill
00098         , const unsigned int    maxToRead
00099     );
00100 
00101     inline unsigned int getSize() const;
00102     
00103 private :
00104     // -----------------------------------------------------------------------
00105     //  Unimplemented constructors and operators
00106     // -----------------------------------------------------------------------
00107     BinMemInputStream(const BinMemInputStream&);
00108     BinMemInputStream& operator=(const BinMemInputStream&); 
00109     // -----------------------------------------------------------------------
00110     //  Private data members
00111     //
00112     //  fBuffer
00113     //      The buffer of bytes that we are streaming.
00114     //
00115     //  fBufOpt
00116     //      Indicates the ownership status of the buffer. The caller can have
00117     //      us adopt it (we delete it), reference it, or just make our own
00118     //      copy of it.
00119     //
00120     //  fCapacity
00121     //      The size of the buffer being streamed.
00122     //
00123     //  fCurIndex
00124     //      The current index where the next byte will be read from. When it
00125     //      hits fCapacity, we are done.
00126     // -----------------------------------------------------------------------
00127     const XMLByte*  fBuffer;
00128     BufOpts         fBufOpt;
00129     unsigned int    fCapacity;
00130     unsigned int    fCurIndex;
00131     MemoryManager*  fMemoryManager;
00132 };
00133 
00134 
00135 // ---------------------------------------------------------------------------
00136 //  BinMemInputStream: Stream management methods
00137 // ---------------------------------------------------------------------------
00138 inline void BinMemInputStream::reset()
00139 {
00140     fCurIndex = 0;
00141 }
00142 
00143 
00144 // ---------------------------------------------------------------------------
00145 //  BinMemInputStream: Implementation of the input stream interface
00146 // ---------------------------------------------------------------------------
00147 inline unsigned int BinMemInputStream::curPos() const
00148 {
00149     return fCurIndex;
00150 }
00151 
00152 inline unsigned int BinMemInputStream::getSize() const
00153 {
00154     return fCapacity;
00155 }
00156 
00157 XERCES_CPP_NAMESPACE_END
00158 
00159 #endif

Generated on Thu Feb 19 11:35:43 2009 for Xerces-C++ by  doxygen 1.5.4