|
||||
File indexing completed on 2025-01-18 10:14:52
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_MEMBUFFORMATTARGET_HPP) 0023 #define XERCESC_INCLUDE_GUARD_MEMBUFFORMATTARGET_HPP 0024 0025 #include <xercesc/framework/XMLFormatter.hpp> 0026 0027 XERCES_CPP_NAMESPACE_BEGIN 0028 0029 /* 0030 * The MemBufFormatTarget is a derivative from XMLFormatTarget, which user code 0031 * may plug into DOMLSSerializer to retrieve the serialized XML stream (from DOM Tree) 0032 * in a memory buffer. 0033 * 0034 * The MemBufFormatTarget is initialized to have a memory buffer of 1023 upon 0035 * construction, which grows as needed. The buffer will be deleted when 0036 * MemBufFormatTarget is destructed; or will be reset when the reset() function 0037 * is called. 0038 * 0039 * The MemBufFormatTarget returns a NULL terminated XMLByte stream upon request, 0040 * through the method getRawBuffer(), and user should make its own copy of the 0041 * returned buffer if it intends to keep it independent on the state of the 0042 * MemBufFormatTarget. 0043 */ 0044 0045 class XMLPARSER_EXPORT MemBufFormatTarget : public XMLFormatTarget { 0046 public: 0047 0048 /** @name constructors and destructor */ 0049 //@{ 0050 MemBufFormatTarget 0051 ( 0052 XMLSize_t initCapacity = 1023 0053 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0054 ) ; 0055 ~MemBufFormatTarget(); 0056 //@} 0057 0058 // ----------------------------------------------------------------------- 0059 // Implementations of the format target interface 0060 // ----------------------------------------------------------------------- 0061 virtual void writeChars(const XMLByte* const toWrite 0062 , const XMLSize_t count 0063 , XMLFormatter* const formatter); 0064 0065 // ----------------------------------------------------------------------- 0066 // Getter 0067 // ----------------------------------------------------------------------- 0068 /** @name getRawBuffer */ 0069 //@{ 0070 /** 0071 * Returned the internal raw buffer. 0072 * 0073 */ 0074 //@} 0075 const XMLByte* getRawBuffer() const; 0076 0077 /** @name getLen */ 0078 //@{ 0079 /** 0080 * Returned the length of the raw buffer. 0081 * 0082 */ 0083 //@} 0084 XMLSize_t getLen() const 0085 { 0086 return fIndex; 0087 } 0088 0089 /** @name reset */ 0090 //@{ 0091 /** 0092 * Reset the internal string buffer. 0093 * 0094 */ 0095 void reset(); 0096 //@} 0097 0098 private: 0099 // ----------------------------------------------------------------------- 0100 // Unimplemented methods. 0101 // ----------------------------------------------------------------------- 0102 MemBufFormatTarget(const MemBufFormatTarget&); 0103 MemBufFormatTarget& operator=(const MemBufFormatTarget&); 0104 0105 // ----------------------------------------------------------------------- 0106 // Private helpers 0107 // ----------------------------------------------------------------------- 0108 void ensureCapacity(const XMLSize_t extraNeeded); 0109 0110 // ----------------------------------------------------------------------- 0111 // Private data members 0112 // 0113 // fDataBuf 0114 // The pointer to the buffer data. Its grown as needed. Its always 0115 // one larger than fCapacity, to leave room for the null terminator. 0116 // 0117 // fIndex 0118 // The current index into the buffer, as characters are appended 0119 // to it. If its zero, then the buffer is empty. 0120 // 0121 // fCapacity 0122 // The current capacity of the buffer. Its actually always one 0123 // larger, to leave room for the null terminator. 0124 // 0125 // ----------------------------------------------------------------------- 0126 MemoryManager* fMemoryManager; 0127 XMLByte* fDataBuf; 0128 XMLSize_t fIndex; 0129 XMLSize_t fCapacity; 0130 0131 }; 0132 0133 XERCES_CPP_NAMESPACE_END 0134 0135 #endif 0136
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |