Xalan-C++ API Reference  1.12.0
FormatterToText.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(FORMATTERTOTEXT_HEADER_GUARD_1357924680)
19 #define FORMATTERTOTEXT_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
32 // Base class header file.
34 
35 
36 
37 namespace XALAN_CPP_NAMESPACE {
38 
39 
40 
41 class Writer;
42 
43 
44 
45 /**
46  * This class takes SAX events (in addition to some extra events
47  * that SAX doesn't handle yet) and produces simple text only.
48  */
50 {
51 public:
52 
53  /**
54  * FormatterToText instance constructor.
55  */
56  FormatterToText(MemoryManager& theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR);
57 
58  /**
59  * FormatterToText instance constructor.
60  *
61  * @param writer writer for output
62  * @param normalizeLindefeed Normalize \n or \r\n (on certain platforms).
63  * @param handleIgnorableWhitespace If true ignorableWhitespace() will write data to the Writer
64  */
66  Writer& writer,
67  bool normalizeLinefeed = true,
68  bool handleIgnorableWhitespace = true,
69  MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
70 
71  /**
72  * FormatterToText instance constructor.
73  *
74  * @param writer writer for output
75  * @param encoding character encoding for the writer
76  * @param normalizeLindefeed Normalize \n or \r\n on certain platforms.
77  * @param handleIgnorableWhitespace If true ignorableWhitespace() will write data to the Writer
78  */
80  Writer& writer,
81  const XalanDOMString& encoding,
82  bool normalizeLinefeed = true,
83  bool handleIgnorableWhitespace = true,
84  MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
85 
86  static FormatterToText*
87  create(
88  MemoryManager& theManager,
89  Writer& writer,
90  const XalanDOMString& encoding,
91  bool normalizeLinefeed = true,
92  bool handleIgnorableWhitespace = true);
93 
94  virtual
95  ~FormatterToText();
96 
97  MemoryManager&
99  {
100  return m_encoding.getMemoryManager();
101  }
102 
103  Writer*
104  getWriter() const
105  {
106  return m_writer;
107  }
108 
109  void
110  setWriter(Writer* theWriter)
111  {
112  m_writer = theWriter;
113 
114  update(false);
115  }
116 
117  void
118  clearEncoding();
119 
120  const XalanDOMString&
121  getEncoding() const
122  {
123  return m_encoding;
124  }
125 
126  void
127  setEncoding(const XalanDOMString& theEncoding)
128  {
129  m_encoding = theEncoding;
130 
131  update(false);
132  }
133 
134  XalanDOMChar
136  {
137  return m_maxCharacter;
138  }
139 
140  void
141  setMaxCharacter(XalanDOMChar theMaxChar)
142  {
143  m_maxCharacter = theMaxChar;
144  }
145 
146  bool
148  {
149  return m_normalize;
150  }
151 
152  void
153  setNormalizeLinefeed(bool fNormalize)
154  {
155  m_normalize = fNormalize;
156  }
157 
158  bool
160  {
161  return m_handleIgnorableWhitespace;
162  }
163 
164  void
166  {
167  m_handleIgnorableWhitespace = fHandle;
168  }
169 
170  // These methods are inherited from FormatterListener ...
171 
172  virtual void
173  setDocumentLocator(const Locator* const locator);
174 
175  virtual void
176  startDocument();
177 
178  virtual void
179  endDocument();
180 
181  virtual void
182  startElement(
183  const XMLCh* const name,
184  AttributeListType& attrs);
185 
186  virtual void
187  endElement(const XMLCh* const name);
188 
189  virtual void
190  characters(
191  const XMLCh* const chars,
192  const size_type length);
193 
194  virtual void
195  charactersRaw(
196  const XMLCh* const chars,
197  const size_type length);
198 
199  virtual void
200  entityReference(const XMLCh* const name);
201 
202  virtual void
203  ignorableWhitespace(
204  const XMLCh* const chars,
205  const size_type length);
206 
207  virtual void
208  processingInstruction(
209  const XMLCh* const target,
210  const XMLCh* const data);
211 
212  virtual void
213  resetDocument();
214 
215  virtual void
216  comment(const XMLCh* const data);
217 
218  virtual void
219  cdata(
220  const XMLCh* const ch,
221  const size_type length);
222 
223 private:
224 
225  // These are not implemented.
227 
229  operator=(const FormatterToText&);
230 
231  bool
232  operator==(const FormatterToText&) const;
233 
234  // Utility function to update various member variables
235  // when data changes.
236  void
237  update(bool fNormalizationOnly);
238 
239  // Data members...
240  Writer* m_writer;
241 
242  XalanDOMChar m_maxCharacter;
243 
244  XalanDOMString m_encoding;
245 
246  bool m_haveEncoding;
247 
248  bool m_normalize;
249 
250  bool m_handleIgnorableWhitespace;
251 
252  const XalanDOMChar* m_newlineString;
253 
254  XalanDOMString::size_type m_newlineStringLength;
255 };
256 
257 
258 
259 }
260 
261 
262 
263 #endif // FORMATTERTOTEXT_HEADER_GUARD_1357924680
xalanc::FormatterToText::setHandleIgnorableWhitespace
void setHandleIgnorableWhitespace(bool fHandle)
Definition: FormatterToText.hpp:165
xalanc::FormatterToText::getEncoding
const XalanDOMString & getEncoding() const
Definition: FormatterToText.hpp:121
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::AttributeListType
xercesc::AttributeList AttributeListType
Definition: AttributeListImpl.hpp:41
XalanDOMString.hpp
xalanc::FormatterToText::setNormalizeLinefeed
void setNormalizeLinefeed(bool fNormalize)
Definition: FormatterToText.hpp:153
xalanc::FormatterToText
This class takes SAX events (in addition to some extra events that SAX doesn't handle yet) and produc...
Definition: FormatterToText.hpp:49
xalanc::FormatterToText::getMaxCharacter
XalanDOMChar getMaxCharacter() const
Definition: FormatterToText.hpp:135
xalanc::FormatterToText::getWriter
Writer * getWriter() const
Definition: FormatterToText.hpp:104
FormatterListener.hpp
xalanc::FormatterToText::setEncoding
void setEncoding(const XalanDOMString &theEncoding)
Definition: FormatterToText.hpp:127
xalanc::size_type
size_t size_type
Definition: XalanMap.hpp:46
XALAN_DEFAULT_MEMMGR
#define XALAN_DEFAULT_MEMMGR
Definition: XalanMemoryManagement.hpp:516
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
xalanc::length
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:235
xalanc::FormatterToText::getNormalizeLinefeed
bool getNormalizeLinefeed() const
Definition: FormatterToText.hpp:147
xalanc::FormatterToText::getMemoryManager
MemoryManager & getMemoryManager()
Definition: FormatterToText.hpp:98
xalanc::FormatterToText::setWriter
void setWriter(Writer *theWriter)
Definition: FormatterToText.hpp:110
xalanc::FormatterToText::getHandleIgnorableWhitespace
bool getHandleIgnorableWhitespace() const
Definition: FormatterToText.hpp:159
xalanc::FormatterToText::setMaxCharacter
void setMaxCharacter(XalanDOMChar theMaxChar)
Definition: FormatterToText.hpp:141
xalanc::FormatterListener
A SAX-based formatter interface for the XSL processor.
Definition: FormatterListener.hpp:56
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
XMLSupportDefinitions.hpp
XALAN_XMLSUPPORT_EXPORT
#define XALAN_XMLSUPPORT_EXPORT
Definition: XMLSupportDefinitions.hpp:35
XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
#define XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
Definition: XalanMemoryManagement.hpp:515
xalanc::Writer
Definition: Writer.hpp:44