Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


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 
25 XALAN_CPP_NAMESPACE_BEGIN
26 
27 
29 {
30 public:
31 
32  typedef XalanDOMChar value_type;
33 
34 
36  Writer& writer,
37  MemoryManager& theMemoryManager);
38 
39  virtual
41  {
42  }
43 
44  /**
45  * Output a line break.
46  */
47  void
49  {
50  assert(m_newlineString != 0);
52 
53  write(
56  }
57 
58 
59  size_type
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,
79  size_type theLength)
80  {
81  write(data, theLength);
82  }
83 
84  /**
85  * Writes name chars, if not representable, throws
86  */
87  void
89  const XalanDOMChar* data,
90  size_type theLength)
91  {
92  write(data, theLength);
93  }
94 
95  /**
96  * Writes name chars, if not representable, throws
97  */
98  void
100  const XalanDOMChar* data,
101  size_type theLength)
102  {
103  write(data, theLength);
104  }
105 
106  void
108  const XalanDOMChar* theChars,
109  size_type theLength)
110  {
111  write(theChars, theLength);
112  }
113 
114  void
116  const value_type* theChars,
117  size_type theLength)
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
145  write(const XalanDOMString& theChars)
146  {
147  write(theChars.c_str(), theChars.length());
148  }
149 
150  void
151  write(value_type theChar)
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 
166  size_type
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,
180  size_type theLength)
181  {
182  write(theChars, theLength);
183  }
184 
185  void
186  write(const value_type* theChars)
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 
205 private:
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 XALAN_CPP_NAMESPACE_END
224 
225 
226 
227 #endif // XALANUTF16WRITER_HEADER_GUARD_1357924680
void writeSafe(const XalanDOMChar *theChars, size_type theLength)
virtual void write(const char *s, size_t theOffset=0, size_t theLength=npos)=0
Writes a string.
void safeWriteContent(const XalanDOMChar *theChars, size_type theLength)
void writeNameChar(const XalanDOMChar *data, size_type theLength)
Writes name chars, if not representable, throws.
void outputNewline()
Output a line break.
const XalanDOMChar * c_str() const
Writer & m_writer
The writer.
XalanDOMChar value_type
void write(const value_type *theChars, size_type theLength)
virtual ~XalanUTF16Writer()
size_type length() const
size_type m_newlineStringLength
The length of the the string of characters that represents the newline.
void write(const XalanDOMString &theChars)
XalanUTF16Writer(Writer &writer, MemoryManager &theMemoryManager)
void write(const value_type *theChars)
void writePIChars(const XalanDOMChar *data, size_type theLength)
Writes name chars, if not representable, throws.
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
size_type write(const value_type chars[], size_type start, size_type)
size_type writeCDATAChar(const XalanDOMChar chars[], size_type start, size_type, bool &)
const XalanDOMChar * m_newlineString
The string of characters that represents the newline.
void writeCommentChars(const XalanDOMChar *data, size_type theLength)
Writes name chars, if not representable, throws.
void write(value_type theChar)
FormatterListener::size_type size_type

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.11
Copyright © 1999-2012 The Apache Software Foundation.
All Rights Reserved.

Apache Logo