1 | /*
|
---|
2 | * Copyright 2003,2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Id: BinMemOutputStream.hpp,v 1.3 2004/09/08 13:56:13 peiyongz Exp $
|
---|
19 | * $Log: BinMemOutputStream.hpp,v $
|
---|
20 | * Revision 1.3 2004/09/08 13:56:13 peiyongz
|
---|
21 | * Apache License Version 2.0
|
---|
22 | *
|
---|
23 | * Revision 1.2 2004/02/16 04:02:34 neilg
|
---|
24 | * fix for bug 26936
|
---|
25 | *
|
---|
26 | * Revision 1.1 2003/12/16 16:56:51 peiyongz
|
---|
27 | * BinMemOutputStream
|
---|
28 | *
|
---|
29 | *
|
---|
30 | */
|
---|
31 |
|
---|
32 | #ifndef BINMEMOUTPUTSTREAM_HEADER_GUARD_
|
---|
33 | #define BINMEMOUTPUTSTREAM_HEADER_GUARD_
|
---|
34 |
|
---|
35 | #include <xercesc/framework/BinOutputStream.hpp>
|
---|
36 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
37 |
|
---|
38 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
39 |
|
---|
40 | class XMLUTIL_EXPORT BinMemOutputStream : public BinOutputStream
|
---|
41 | {
|
---|
42 | public :
|
---|
43 | // -----------------------------------------------------------------------
|
---|
44 | // Constructors and Destructor
|
---|
45 | // -----------------------------------------------------------------------
|
---|
46 |
|
---|
47 | ~BinMemOutputStream();
|
---|
48 |
|
---|
49 | BinMemOutputStream
|
---|
50 | (
|
---|
51 | int initCapacity = 1023
|
---|
52 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
53 | );
|
---|
54 |
|
---|
55 | // -----------------------------------------------------------------------
|
---|
56 | // Implementation of the output stream interface
|
---|
57 | // -----------------------------------------------------------------------
|
---|
58 | virtual unsigned int curPos() const;
|
---|
59 |
|
---|
60 | virtual void writeBytes
|
---|
61 | (
|
---|
62 | const XMLByte* const toGo
|
---|
63 | , const unsigned int maxToWrite
|
---|
64 | ) ;
|
---|
65 |
|
---|
66 | // -----------------------------------------------------------------------
|
---|
67 | // Getter methods
|
---|
68 | // -----------------------------------------------------------------------
|
---|
69 | const XMLByte* getRawBuffer() const;
|
---|
70 |
|
---|
71 | unsigned int getSize() const;
|
---|
72 | void reset();
|
---|
73 |
|
---|
74 | private :
|
---|
75 | // -----------------------------------------------------------------------
|
---|
76 | // Unimplemented methods.
|
---|
77 | // -----------------------------------------------------------------------
|
---|
78 | BinMemOutputStream(const BinMemOutputStream&);
|
---|
79 | BinMemOutputStream& operator=(const BinMemOutputStream&);
|
---|
80 |
|
---|
81 | // -----------------------------------------------------------------------
|
---|
82 | // Private helpers
|
---|
83 | // -----------------------------------------------------------------------
|
---|
84 | void insureCapacity(const unsigned int extraNeeded);
|
---|
85 |
|
---|
86 | // -----------------------------------------------------------------------
|
---|
87 | // Private data members
|
---|
88 | //
|
---|
89 | // fDataBuf
|
---|
90 | // The pointer to the buffer data. Its grown as needed. Its always
|
---|
91 | // one larger than fCapacity, to leave room for the null terminator.
|
---|
92 | //
|
---|
93 | // fIndex
|
---|
94 | // The current index into the buffer, as characters are appended
|
---|
95 | // to it. If its zero, then the buffer is empty.
|
---|
96 | //
|
---|
97 | // fCapacity
|
---|
98 | // The current capacity of the buffer. Its actually always one
|
---|
99 | // larger, to leave room for the null terminator.
|
---|
100 | //
|
---|
101 | // -----------------------------------------------------------------------
|
---|
102 | MemoryManager* fMemoryManager;
|
---|
103 | XMLByte* fDataBuf;
|
---|
104 | unsigned int fIndex;
|
---|
105 | unsigned int fCapacity;
|
---|
106 |
|
---|
107 | };
|
---|
108 |
|
---|
109 |
|
---|
110 | XERCES_CPP_NAMESPACE_END
|
---|
111 |
|
---|
112 | #endif
|
---|
113 |
|
---|