Xalan-C++ API Reference 1.12.0
XalanUTF16Writer.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#if !defined(XALANUTF16WRITER_HEADER_GUARD_1357924680)
19#define XALANUTF16WRITER_HEADER_GUARD_1357924680
20
21
23
24
25namespace XALAN_CPP_NAMESPACE {
26
27
29{
30public:
31
33
34
37 MemoryManager& theMemoryManager);
38
39 virtual
41 {
42 }
43
44 /**
45 * Output a line break.
46 */
47 void
49 {
50 assert(m_newlineString != 0);
51 assert(length(m_newlineString) == m_newlineStringLength);
52
53 write(
54 m_newlineString,
55 m_newlineStringLength);
56 }
57
58
61 const XalanDOMChar chars[],
62 size_type start,
63 size_type /*length*/,
64 bool& /* outsideCDATA */)
65 {
66 assert( chars != 0 );
67
68 write(chars[start]);
69
70 return start;
71 }
72
73 /**
74 * Writes name chars, if not representable, throws
75 */
76 void
78 const XalanDOMChar* data,
80 {
81 write(data, theLength);
82 }
83
84 /**
85 * Writes name chars, if not representable, throws
86 */
87 void
89 const XalanDOMChar* data,
91 {
92 write(data, theLength);
93 }
94
95 /**
96 * Writes name chars, if not representable, throws
97 */
98 void
100 const XalanDOMChar* data,
102 {
103 write(data, theLength);
104 }
105
106 void
108 const XalanDOMChar* theChars,
110 {
111 write(theChars, theLength);
112 }
113
114 void
116 const value_type* theChars,
118 {
119 if (theLength > kBufferSize)
120 {
121 flushBuffer();
122
123 m_writer.write(theChars, 0, theLength);
124 }
125 else
126 {
127 if (m_bufferRemaining < theLength)
128 {
129 flushBuffer();
130 }
131
132 for(size_type i = 0; i < theLength; ++i)
133 {
134 *m_bufferPosition = theChars[i];
135
136 ++m_bufferPosition;
137 }
138
139 m_bufferRemaining -= theLength;
140 }
141
142 }
143
144 void
146 {
147 write(theChars.c_str(), theChars.length());
148 }
149
150 void
152 {
153
154 if (m_bufferRemaining == 0)
155 {
156 flushBuffer();
157 }
158
159 *m_bufferPosition = theChar;
160
161 ++m_bufferPosition;
162 --m_bufferRemaining;
163 }
164
165
168 const value_type chars[],
169 size_type start,
170 size_type /*length*/)
171 {
172 write(chars[start]);
173
174 return start;
175 }
176
177 void
179 const XalanDOMChar* theChars,
181 {
182 write(theChars, theLength);
183 }
184
185 void
187 {
188 write(theChars, XalanDOMString::length(theChars));
189 }
190
191 void
193 {
194 m_writer.write(
195 m_buffer,
196 0,
197 m_bufferPosition - m_buffer);
198
199
200 m_bufferPosition = m_buffer;
201 m_bufferRemaining = kBufferSize;
202 }
203
204
205private:
206
207 enum
208 {
209 kBufferSize = 512 // The size of the buffer
210 };
211
212
213 // Data members...
214 value_type m_buffer[kBufferSize];
215
216 value_type* m_bufferPosition;
217
218 size_type m_bufferRemaining;
219};
220
221
222
223}
224
225
226
227#endif // XALANUTF16WRITER_HEADER_GUARD_1357924680
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
void writePIChars(const XalanDOMChar *data, size_type theLength)
Writes name chars, if not representable, throws.
size_type write(const value_type chars[], size_type start, size_type)
void write(const value_type *theChars)
void writeNameChar(const XalanDOMChar *data, size_type theLength)
Writes name chars, if not representable, throws.
void writeCommentChars(const XalanDOMChar *data, size_type theLength)
Writes name chars, if not representable, throws.
void write(const XalanDOMString &theChars)
void safeWriteContent(const XalanDOMChar *theChars, size_type theLength)
void write(const value_type *theChars, size_type theLength)
size_type writeCDATAChar(const XalanDOMChar chars[], size_type start, size_type, bool &)
void outputNewline()
Output a line break.
void write(value_type theChar)
XalanUTF16Writer(Writer &writer, MemoryManager &theMemoryManager)
void writeSafe(const XalanDOMChar *theChars, size_type theLength)
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
size_t size_type
Definition XalanMap.hpp:46