00001 /*00002 * Licensed to the Apache Software Foundation (ASF) under one or more00003 * contributor license agreements. See the NOTICE file distributed with00004 * this work for additional information regarding copyright ownership.00005 * The ASF licenses this file to You under the Apache License, Version 2.000006 * (the "License"); you may not use this file except in compliance with00007 * the License. You may obtain a copy of the License at00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.000010 * 00011 * Unless required by applicable law or agreed to in writing, software00012 * 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 and00015 * limitations under the License.00016 */00017
00018 /*00019 *00020 * Revision 1.5 2004/09/08 13:56:21 peiyongz00021 * Apache License Version 2.000022 *00023 * Revision 1.4 2004/01/29 11:48:46 cargilld00024 * Code cleanup changes to get rid of various compiler diagnostic messages.00025 *00026 * Revision 1.3 2003/05/16 03:11:22 knoaman00027 * Partial implementation of the configurable memory manager.00028 *00029 * Revision 1.2 2002/11/04 15:22:03 tng00030 * C++ Namespace Support.00031 *00032 * Revision 1.1.1.1 2002/02/01 22:22:10 peiyongz00033 * sane_include00034 *00035 * Revision 1.3 2000/02/24 20:05:24 abagchi00036 * Swat for removing Log from API docs00037 *00038 * Revision 1.2 2000/02/06 07:48:01 rahulj00039 * Year 2K copyright swat.00040 *00041 * Revision 1.1.1.1 1999/11/09 01:04:07 twl00042 * Initial checkin00043 *00044 * Revision 1.3 1999/11/08 20:45:04 rahul00045 * Swat for adding in Product name and CVS comment log variable.00046 *00047 */00048
00049 #if !defined(BINMEMINPUTSTREAM_HPP)00050#define BINMEMINPUTSTREAM_HPP00051
00052 #include <xercesc/util/BinInputStream.hpp>00053 #include <xercesc/util/PlatformUtils.hpp>00054
00055 XERCES_CPP_NAMESPACE_BEGIN00056
00057class BinMemInputStream : publicBinInputStream00058 {
00059 public :
00060 // -----------------------------------------------------------------------00061 // Class specific types00062 // -----------------------------------------------------------------------00063enumBufOpts00064 {
00065 BufOpt_Adopt
00066 , BufOpt_Copy
00067 , BufOpt_Reference
00068 };
00069
00070
00071 // -----------------------------------------------------------------------00072 // Constructors and Destructor00073 // -----------------------------------------------------------------------00074 BinMemInputStream00075 (
00076 constXMLByte* const initData
00077 , constunsignedint capacity
00078 , const BufOpts bufOpt = BufOpt_Copy
00079 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager00080 );
00081 virtual ~BinMemInputStream();
00082
00083
00084 // -----------------------------------------------------------------------00085 // Stream management methods00086 // -----------------------------------------------------------------------00087 void reset();
00088
00089
00090 // -----------------------------------------------------------------------00091 // Implementation of the input stream interface00092 // -----------------------------------------------------------------------00093 virtualunsignedintcurPos() const;
00094
00095 virtualunsignedintreadBytes00096 (
00097 XMLByte* const toFill
00098 , constunsignedint maxToRead
00099 );
00100
00101 inlineunsignedint getSize() const;
00102
00103 private :
00104 // -----------------------------------------------------------------------00105 // Unimplemented constructors and operators00106 // -----------------------------------------------------------------------00107 BinMemInputStream(constBinMemInputStream&);
00108 BinMemInputStream& operator=(constBinMemInputStream&);
00109 // -----------------------------------------------------------------------00110 // Private data members00111 //00112 // fBuffer00113 // The buffer of bytes that we are streaming.00114 //00115 // fBufOpt00116 // Indicates the ownership status of the buffer. The caller can have00117 // us adopt it (we delete it), reference it, or just make our own00118 // copy of it.00119 //00120 // fCapacity00121 // The size of the buffer being streamed.00122 //00123 // fCurIndex00124 // The current index where the next byte will be read from. When it00125 // hits fCapacity, we are done.00126 // -----------------------------------------------------------------------00127 constXMLByte* fBuffer;
00128 BufOpts fBufOpt;
00129 unsignedint fCapacity;
00130 unsignedint fCurIndex;
00131 MemoryManager* fMemoryManager;
00132 };
00133
00134
00135 // ---------------------------------------------------------------------------00136 // BinMemInputStream: Stream management methods00137 // ---------------------------------------------------------------------------00138inlinevoidBinMemInputStream::reset()
00139 {
00140 fCurIndex = 0;
00141 }
00142
00143
00144 // ---------------------------------------------------------------------------00145 // BinMemInputStream: Implementation of the input stream interface00146 // ---------------------------------------------------------------------------00147inlineunsignedintBinMemInputStream::curPos() const00148 {
00149 return fCurIndex;
00150 }
00151
00152inlineunsignedintBinMemInputStream::getSize() const00153 {
00154 return fCapacity;
00155 }
00156
00157 XERCES_CPP_NAMESPACE_END00158
00159 #endif