Xalan-C++ API Reference  1.12.0
XSLTResultTarget.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 
19 #if !defined(XALAN_XSLTRESULTTARGET_HEADER_GUARD)
20 #define XALAN_XSLTRESULTTARGET_HEADER_GUARD
21 
22 // Base include file. Must be first.
23 #include "XSLTDefinitions.hpp"
24 
25 
26 
27 #include <cstdio>
28 #include <iosfwd>
29 
30 
31 
33 
34 
35 
36 namespace XALAN_CPP_NAMESPACE {
37 
38 
39 
40 class FormatterListener;
41 class Writer;
42 
43 
44 
46 {
47 public:
48 
49  typedef std::ostream StreamType;
50 
51  typedef std::FILE FILE;
52 
53 
54  explicit
55  XSLTResultTarget(MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
56 
57  /**
58  * Create a new output target with a file name.
59  *
60  * @param fileName valid system file name
61  */
62  XSLTResultTarget(const XalanDOMString& fileName,
63  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
64 
65  /**
66  * Create a new output target with a file name.
67  *
68  * @param fileName valid system file name
69  */
70  XSLTResultTarget(const XalanDOMChar* fileName,
71  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
72 
73  /**
74  * Create a new output target with a file name.
75  *
76  * @param fileName valid system file name
77  */
78  XSLTResultTarget(const char* fileName,
79  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
80 
81  /**
82  * Create a new output target with a stream.
83  *
84  * @param byteStream a pointer to a std ostream for the output
85  */
86  XSLTResultTarget(StreamType* theStream,
87  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
88 
89  /**
90  * Create a new output target with a stream.
91  *
92  * @param byteStream a reference to a std ostream for the output
93  */
94  XSLTResultTarget(StreamType& theStream,
95  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
96 
97  /**
98  * Create a new output target with a character stream.
99  *
100  * @param characterStream pointer to character stream where the results
101  * will be written
102  */
103  XSLTResultTarget(Writer* characterStream,
104  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
105 
106  /**
107  * Create a new output target with a stream.
108  *
109  * @param characterStream pointer to character stream where the results
110  * will be written
111  */
112  XSLTResultTarget(FILE* characterStream,
113  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
114 
115  /**
116  * Create a new output target with a FormatterListener.
117  *
118  * @param flistener A FormatterListener instance for result tree events.
119  */
121  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
122 
123  XSLTResultTarget(const XSLTResultTarget& other,
124  MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
125  ~XSLTResultTarget();
126 
127  /**
128  * Set the file name where the results will be written.
129  *
130  * @param fileName system identifier as a string
131  */
132  void
133  setFileName(const char* fileName)
134  {
135  if (fileName == 0)
136  {
137  m_fileName.clear();
138  }
139  else
140  {
141  m_fileName = fileName;
142  }
143  }
144 
145  /**
146  * Set the file name where the results will be written.
147  *
148  * @param fileName system identifier as a string
149  */
150  void
151  setFileName(const XalanDOMString& fileName)
152  {
153  m_fileName = fileName;
154  }
155 
156  /**
157  * Get the file name where the results will be written to.
158  *
159  * @return file name string
160  */
161  const XalanDOMString&
162  getFileName() const
163  {
164  return m_fileName;
165  }
166 
167  /**
168  * Set the byte stream for this output target.
169  *
170  * @param byteStream pointer to byte stream that will contain the result
171  * document
172  */
173  void
175  {
176  m_byteStream = byteStream;
177  }
178 
179  /**
180  * Get the byte stream for this output target.
181  *
182  * @return pointer to byte stream, or null if none was supplied.
183  */
184  StreamType*
186  {
187  return m_byteStream;
188  }
189 
190  /**
191  * Set the character encoding, if known.
192  *
193  * @param encoding new encoding string
194  */
195  void
196  setEncoding(const XalanDOMChar* encoding)
197  {
198  if (encoding == 0)
199  {
200  m_encoding.clear();
201  }
202  else
203  {
204  m_encoding = encoding;
205  }
206  }
207 
208  /**
209  * Set the character encoding, if known.
210  *
211  * @param encoding new encoding string
212  */
213  void
214  setEncoding(const XalanDOMString& encoding)
215  {
216  m_encoding = encoding;
217  }
218 
219  /**
220  * Get the character encoding in use.
221  *
222  * @return encoding string, or empty string if none was supplied.
223  */
224  const XalanDOMString&
225  getEncoding() const
226  {
227  return m_encoding;
228  }
229 
230  /**
231  * Set the character stream for this output target.
232  *
233  * @param characterStream pointer to character stream that will contain
234  * the result document
235  */
236  void
237  setCharacterStream(Writer* characterStream)
238  {
239  m_characterStream = characterStream;
240  }
241 
242  /**
243  * Get the character stream for this output target.
244  *
245  * @return pointer to character stream, or null if none was supplied.
246  */
247  Writer*
249  {
250  return m_characterStream;
251  }
252 
253  /**
254  * Get the stream for this output target.
255  *
256  * @return pointer to stream, or null if none was supplied.
257  */
258  FILE*
259  getStream() const
260  {
261  return m_stream;
262  }
263 
264  /**
265  * Set the stream for this output target.
266  *
267  * @theStream pointer to stream.
268  */
269  void
270  setStream(FILE* theStream)
271  {
272  m_stream = theStream;
273  }
274 
275  /**
276  * Set a FormatterListener to process the result tree events.
277  *
278  * @param handler pointer to new listener
279  */
280  void
282  {
283  m_formatterListener = handler;
284  }
285 
286  /**
287  * Get the FormatterListener that will process the result tree events.
288  *
289  * @return pointer to new listener
290  */
293  {
294  return m_formatterListener;
295  }
296 
297 private:
298 
299 #if defined(XALAN_DEVELOPMENT)
302 #endif
303 
304  XalanDOMString m_fileName;
305 
306  StreamType* m_byteStream;
307 
308  XalanDOMString m_encoding;
309 
310  Writer* m_characterStream;
311 
312  FormatterListener* m_formatterListener;
313 
314  FILE* m_stream;
315 };
316 
317 
318 
319 }
320 
321 
322 
323 #endif // XALAN_XSLTRESULTTARGET_HEADER_GUARD
xalanc::XSLTResultTarget::getFormatterListener
FormatterListener * getFormatterListener() const
Get the FormatterListener that will process the result tree events.
Definition: XSLTResultTarget.hpp:292
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XSLTResultTarget::getFileName
const XalanDOMString & getFileName() const
Get the file name where the results will be written to.
Definition: XSLTResultTarget.hpp:162
xalanc::XSLTResultTarget::setFormatterListener
void setFormatterListener(FormatterListener *handler)
Set a FormatterListener to process the result tree events.
Definition: XSLTResultTarget.hpp:281
XalanDOMString.hpp
XALAN_XSLT_EXPORT
#define XALAN_XSLT_EXPORT
Definition: XSLTDefinitions.hpp:27
xalanc::XSLTResultTarget::getEncoding
const XalanDOMString & getEncoding() const
Get the character encoding in use.
Definition: XSLTResultTarget.hpp:225
xalanc::XSLTResultTarget
Definition: XSLTResultTarget.hpp:45
xalanc::XSLTResultTarget::getCharacterStream
Writer * getCharacterStream() const
Get the character stream for this output target.
Definition: XSLTResultTarget.hpp:248
xalanc::XSLTResultTarget::setFileName
void setFileName(const XalanDOMString &fileName)
Set the file name where the results will be written.
Definition: XSLTResultTarget.hpp:151
xalanc::XSLTResultTarget::FILE
std::FILE FILE
Definition: XSLTResultTarget.hpp:51
xalanc::XSLTResultTarget::setEncoding
void setEncoding(const XalanDOMChar *encoding)
Set the character encoding, if known.
Definition: XSLTResultTarget.hpp:196
xalanc::XSLTResultTarget::StreamType
std::ostream StreamType
Definition: XSLTResultTarget.hpp:49
xalanc::XSLTResultTarget::setFileName
void setFileName(const char *fileName)
Set the file name where the results will be written.
Definition: XSLTResultTarget.hpp:133
xalanc::XSLTResultTarget::setCharacterStream
void setCharacterStream(Writer *characterStream)
Set the character stream for this output target.
Definition: XSLTResultTarget.hpp:237
xalanc::XSLTResultTarget::setStream
void setStream(FILE *theStream)
Set the stream for this output target.
Definition: XSLTResultTarget.hpp:270
XSLTDefinitions.hpp
xalanc::FormatterListener
A SAX-based formatter interface for the XSL processor.
Definition: FormatterListener.hpp:56
xalanc::XSLTResultTarget::getStream
FILE * getStream() const
Get the stream for this output target.
Definition: XSLTResultTarget.hpp:259
xalanc::XSLTResultTarget::setEncoding
void setEncoding(const XalanDOMString &encoding)
Set the character encoding, if known.
Definition: XSLTResultTarget.hpp:214
xalanc::XSLTResultTarget::setByteStream
void setByteStream(StreamType *byteStream)
Set the byte stream for this output target.
Definition: XSLTResultTarget.hpp:174
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XSLTResultTarget::getByteStream
StreamType * getByteStream() const
Get the byte stream for this output target.
Definition: XSLTResultTarget.hpp:185
XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
#define XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
Definition: XalanMemoryManagement.hpp:515
xalanc::Writer
Definition: Writer.hpp:44