Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XalanIndentWriter.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2005 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(XALANIDENTWRITER_HEADER_GUARD_1357924680)
17 #define XALANIDENTWRITER_HEADER_GUARD_1357924680
18 
19 
20 // Base include file. Must be first.
22 
24 
26 
27 
28 XALAN_CPP_NAMESPACE_BEGIN
29 
30 
31 template<class WhiteSpaceWriter,
32  class NewLineWriter>
34 {
35 public:
38  typedef typename WhiteSpaceWriter::writer_type writer_type;
39 
41  writer_type& writer,
42  size_type ident) :
43  m_whiteSpaceWriter(writer),
44  m_newLineWriter(writer),
45  m_indent(ident),
46  m_currentIndent(0),
47  m_startNewLine(false),
48  m_ispreserve(false),
49  m_isprevtext(false),
50  m_preserves(writer.getMemoryManager(), 5)
51  {
52  assert( m_indent != -1);
53  }
54 
56  {
57  }
58 
59 
60  void
62  {
63  m_indent = value;
64  }
65 
66  size_type
67  getIndent()const
68  {
69  return m_indent;
70  }
71 
72  void
74  {
75  if( shouldIndent() )
76  {
77  if(m_startNewLine == true)
78  {
79  m_newLineWriter();
80  }
81 
82  m_whiteSpaceWriter(m_currentIndent);
83 
84  }
85  }
86 
87  void
89  {
90  m_currentIndent += m_indent;
91  }
92 
93  void
95  {
96  assert( m_currentIndent >= m_indent);
97 
98  m_currentIndent -= m_indent;
99  }
100 
101  void
102  setStartNewLine(bool value)
103  {
104  m_startNewLine = value;
105  }
106 
110  void
112  {
113  m_newLineWriter();
114  }
115 
116  void
117  setPrevText(bool value)
118  {
119  m_isprevtext = value;
120  }
121 
122  void
123  setPreserve(bool value)
124  {
125  m_ispreserve = value;
126  }
127 
128  void
130  {
131  if ( m_preserves.empty() )
132  {
133  m_ispreserve = false;
134  }
135  else
136  {
137  m_ispreserve = m_preserves.back();
138 
139  m_preserves.pop_back();
140  }
141  }
142 
143  void
145  {
146  m_preserves.push_back(m_ispreserve);
147  }
148 
149 private:
150  bool
151  shouldIndent() const
152  {
153  return (!m_ispreserve && !m_isprevtext);
154  // return true;
155  }
156 
157 private:
158 
159  //data members
160 
161  WhiteSpaceWriter m_whiteSpaceWriter;
162 
163  NewLineWriter m_newLineWriter;
164 
168  size_type m_indent;
169 
173  size_type m_currentIndent;
174 
178  bool m_startNewLine;
179 
184  bool m_ispreserve;
185 
190  bool m_isprevtext;
191 
196  BoolStackType m_preserves;
197 };
198 
199 XALAN_CPP_NAMESPACE_END
200 
201 
202 
203 #endif // XALANIDENTWRITER_HEADER_GUARD_1357924680
XalanDOMString::size_type size_type
Definition: XalanIndentWriter.hpp:36
void push_preserve()
Definition: XalanIndentWriter.hpp:144
void setIndent(size_type value)
Definition: XalanIndentWriter.hpp:61
~XalanIndentWriter()
Definition: XalanIndentWriter.hpp:55
void pop_preserve()
Definition: XalanIndentWriter.hpp:129
void decreaseIndent()
Definition: XalanIndentWriter.hpp:94
reference back()
Definition: XalanVector.hpp:673
void pop_back()
Definition: XalanVector.hpp:256
bool empty() const
Definition: XalanVector.hpp:636
size_type getIndent() const
Definition: XalanIndentWriter.hpp:67
void push_back(const value_type &data)
Definition: XalanVector.hpp:246
XalanIndentWriter(writer_type &writer, size_type ident)
Definition: XalanIndentWriter.hpp:40
void setPreserve(bool value)
Definition: XalanIndentWriter.hpp:123
XalanVector< bool > BoolStackType
Definition: XalanIndentWriter.hpp:37
Definition: XalanIndentWriter.hpp:33
void increaseIndent()
Definition: XalanIndentWriter.hpp:88
void setStartNewLine(bool value)
Definition: XalanIndentWriter.hpp:102
void indent()
Definition: XalanIndentWriter.hpp:73
void outputLineSep()
Output a line break.
Definition: XalanIndentWriter.hpp:111
WhiteSpaceWriter::writer_type writer_type
Definition: XalanIndentWriter.hpp:38
unsigned int size_type
Definition: XalanDOMString.hpp:53
void setPrevText(bool value)
Definition: XalanIndentWriter.hpp:117

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