http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Charter
Release Info

Installation
Download
Build Instructions

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

Source Repository
User Mail Archive
Devel Mail Archive

API Docs for SAX and DOM
 

BinMemInputStream.hpp

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


Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.