Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XalanOutputStream.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-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 #if !defined(XALANOUTPUTSTREAM_HEADER_GUARD_1357924680)
17 #define XALANOUTPUTSTREAM_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
27 
28 
29 
31 
32 
33 
36 
37 
38 
39 XALAN_CPP_NAMESPACE_BEGIN
40 
41 
42 
44 
45 
46 
48 {
49 public :
50 
51  enum { eDefaultBufferSize = 512u, eDefaultTranscoderBlockSize = 1024u };
52 
57 
65  explicit
67  MemoryManagerType& theManager,
68  size_type theBufferSize = eDefaultBufferSize,
69  size_type theTranscoderBlockSize = eDefaultTranscoderBlockSize,
70  bool fThrowTranscodeException = true);
71 
72  virtual
74 
77  {
78  return m_buffer.getMemoryManager();
79  }
80 
81  static const XalanDOMChar*
83  {
84 #if defined(XALAN_NEWLINE_IS_CRLF)
85  return s_nlCRString;
86 #else
87  return s_nlString;
88 #endif
89  }
90 
94  virtual void
95  newline();
96 
100  virtual const XalanDOMChar*
101  getNewlineString() const;
102 
108  void
109  flushBuffer();
110 
114  void
116  {
117  flushBuffer();
118 
119  doFlush();
120  }
121 
128  void
129  write(char theChar)
130  {
131  write(&theChar, 1);
132  }
133 
140  void
141  write(XalanDOMChar theChar)
142  {
143  assert(m_bufferSize > 0);
144 
145  if (m_buffer.size() == m_bufferSize)
146  {
147  flushBuffer();
148  }
149 
150  m_buffer.push_back(theChar);
151  }
152 
160  void
161  write(const char* theBuffer)
162  {
163  assert(theBuffer != 0);
164  assert(m_buffer.empty() == true);
165 
166  write(theBuffer, length(theBuffer));
167  }
168 
175  void
176  write(const XalanDOMChar* theBuffer)
177  {
178  write(theBuffer, length(theBuffer));
179  }
180 
189  void
191  const char* theBuffer,
192  size_type theBufferLength)
193  {
194  assert(theBuffer != 0);
195  assert(m_buffer.empty() == true);
196 
197  writeData(theBuffer,
198  theBufferLength);
199  }
200 
208  void
209  write(
210  const XalanDOMChar* theBuffer,
211  size_type theBufferLength);
212 
218  const XalanDOMString&
220  {
221  return m_encoding;
222  }
223 
229  void
230  setOutputEncoding(const XalanDOMString& theEncoding);
231 
238  bool
239  canTranscodeTo(UnicodeCharType theChar) const;
240 
241 
242  const XalanOutputTranscoder*
244  {
245  return m_transcoder;
246  }
247 
257  bool
259  {
260  return m_throwTranscodeException;
261  }
262 
272  void
274  {
275  m_throwTranscodeException = flag;
276  }
277 
283  void
284  setBufferSize(size_type theBufferSize);
285 
286 
288  {
289  public:
290 
292  const XalanDOMString& theMessage,
293  MemoryManagerType& theManager);
294 
296  XSLException(other)
297  {
298  }
299 
300  virtual
302 
303  virtual const XalanDOMChar*
304  getType() const
305  {
306  return m_type;
307  }
308 
309  private:
310  static const XalanDOMChar m_type[];
311 
312  };
313 
315  {
316  public:
317 
318  explicit
320 
321  virtual
323 
324  virtual const XalanDOMChar*
325  getType() const
326  {
327  return m_type;
328  }
329 
330  private:
331  static const XalanDOMChar m_type[];
332 
333  };
334 
336  {
337  public:
338 
339  UnsupportedEncodingException(const XalanDOMString& theEncoding,
340  XalanDOMString& theBuffer);
341 
344  m_encoding(other.getEncoding(),(const_cast<XalanDOMString*>(&(other.m_encoding)))->getMemoryManager())
345  {
346  }
347 
348  virtual
350 
351  const XalanDOMString&
352  getEncoding() const
353  {
354  return m_encoding;
355  }
356 
357 
358  virtual const XalanDOMChar*
359  getType() const
360  {
361  return m_type;
362  }
363  private:
364 
365  static const XalanDOMChar m_type[];
366 
367  const XalanDOMString m_encoding;
368  };
369 
371  {
372  public:
373 
375  XalanDOMString& theBuffer);
376 
379  m_encoding(other.getEncoding(),(const_cast<XalanDOMString*>(&(other.m_encoding)))->getMemoryManager())
380  {
381  }
382 
383  virtual
385 
386  const XalanDOMString&
387  getEncoding() const
388  {
389  return m_encoding;
390  }
391 
392  private:
393 
394  const XalanDOMString m_encoding;
395  };
396 
398  {
399  public:
400 
401  explicit
403 
406  {
407  }
408 
409  virtual
411  };
412 
413 protected:
414 
422  void
423  transcode(
424  const XalanDOMChar* theBuffer,
425  size_type theBufferLength,
426  TranscodeVectorType& theDestination);
427 
434  virtual void
435  writeData(
436  const char* theBuffer,
437  size_type theBufferLength) = 0;
438 
442  virtual void
443  doFlush() = 0;
444 
445  static const XalanDOMChar s_nlString[];
446  static const XalanDOMChar s_nlCRString[];
447 
450 
451 private:
452 
453  // These are not implemented...
455 
457  operator=(const XalanOutputStream&);
458 
459  bool
460  operator==(const XalanOutputStream&) const;
461 
462  void
463  doWrite(
464  const XalanDOMChar* theBuffer,
465  size_type theBufferLength);
466 
467 
468  const size_type m_transcoderBlockSize;
469 
470  XalanOutputTranscoder* m_transcoder;
471 
472  size_type m_bufferSize;
473 
474  BufferType m_buffer;
475 
476  XalanDOMString m_encoding;
477 
478  bool m_writeAsUTF16;
479 
480  bool m_throwTranscodeException;
481 
482  TranscodeVectorType m_transcodingBuffer;
483 };
484 
485 
486 
487 XALAN_CPP_NAMESPACE_END
488 
489 
490 
491 #endif // XALANOUTPUTSTREAM_HEADER_GUARD_1357924680
void flush()
Flush the stream's buffer.
Definition: XalanOutputStream.hpp:115
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1111
MemoryManagerType & getMemoryManager()
Definition: XalanOutputStream.hpp:76
virtual const XalanDOMChar * getType() const
Retrieve type of exception.
Definition: XalanOutputStream.hpp:325
void transcode(const XalanDOMChar *theBuffer, size_type theBufferLength, TranscodeVectorType &theDestination)
Transcode a wide string.
const XalanDOMString & getEncoding() const
Definition: XalanOutputStream.hpp:387
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
Definition: XSLException.hpp:39
static const XalanDOMChar * defaultNewlineString()
Definition: XalanOutputStream.hpp:82
TranscodingException(const TranscodingException &other)
Definition: XalanOutputStream.hpp:404
void write(XalanDOMChar theChar)
Write a wide character to the output stream.
Definition: XalanOutputStream.hpp:141
unsigned int UnicodeCharType
Definition: XalanTranscodingServices.hpp:61
XalanOutputStream(MemoryManagerType &theManager, size_type theBufferSize=eDefaultBufferSize, size_type theTranscoderBlockSize=eDefaultTranscoderBlockSize, bool fThrowTranscodeException=true)
Constructor.
const XalanDOMString & getOutputEncoding() const
Get the output encoding for the stream.
Definition: XalanOutputStream.hpp:219
unsigned int size_type
Definition: XalanTranscodingServices.hpp:60
Definition: XalanOutputStream.hpp:397
XalanTranscodingServices::UnicodeCharType UnicodeCharType
Definition: XalanOutputStream.hpp:56
void write(char theChar)
Write a character to the output stream.
Definition: XalanOutputStream.hpp:129
Definition: XalanOutputStream.hpp:335
Definition: XalanOutputStream.hpp:314
XalanVector< char > TranscodeVectorType
Definition: XalanOutputStream.hpp:54
Definition: XalanOutputStream.hpp:370
XalanVector< XalanDOMChar > BufferType
Definition: XalanOutputStream.hpp:53
void write(const char *theBuffer)
Write a null-terminated string to the output file.
Definition: XalanOutputStream.hpp:161
Definition: XalanTranscodingServices.hpp:287
XalanTranscodingServices::size_type size_type
Definition: XalanOutputStream.hpp:55
const XalanDOMString & getEncoding() const
Definition: XalanOutputStream.hpp:352
virtual void doFlush()=0
Flush the stream.
void write(const XalanDOMChar *theBuffer)
Write a null-terminated wide string to the output file.
Definition: XalanOutputStream.hpp:176
XALAN_CPP_NAMESPACE_BEGIN typedef size_t size_type
Definition: XalanMap.hpp:44
virtual const XalanDOMChar * getType() const
Retrieve type of exception.
Definition: XalanOutputStream.hpp:359
XalanOutputStreamException(const XalanOutputStreamException &other)
Definition: XalanOutputStream.hpp:295
const XalanOutputTranscoder * getTranscoder() const
Definition: XalanOutputStream.hpp:243
Definition: XalanOutputStream.hpp:47
TranscoderInternalFailureException(const TranscoderInternalFailureException &other)
Definition: XalanOutputStream.hpp:377
void setThrowTranscodeException(bool flag)
Set the flag that indicates whether a transcoding error should throw an exception.
Definition: XalanOutputStream.hpp:273
static const XalanDOMString::size_type s_nlStringLength
Definition: XalanOutputStream.hpp:448
Definition: XalanDOMString.hpp:42
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:277
#define XALAN_PLATFORMSUPPORT_EXPORT
Definition: PlatformSupportDefinitions.hpp:33
static const XalanDOMString::size_type s_nlCRStringLength
Definition: XalanOutputStream.hpp:449
Definition: XalanOutputStream.hpp:287
unsigned int size_type
Definition: XalanDOMString.hpp:53
virtual const XalanDOMChar * getType() const
Retrieve type of exception.
Definition: XalanOutputStream.hpp:304
UnsupportedEncodingException(const UnsupportedEncodingException &other)
Definition: XalanOutputStream.hpp:342
void write(const char *theBuffer, size_type theBufferLength)
Write a specified number of characters to the output stream.
Definition: XalanOutputStream.hpp:190
virtual void writeData(const char *theBuffer, size_type theBufferLength)=0
Write the data in the buffer.
bool getThrowTranscodeException() const
Set the flag that indicates whether a transcoding error should throw an exception.
Definition: XalanOutputStream.hpp:258

Interpreting class diagrams

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

dot

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

Apache Logo