Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XalanIndentWriter.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2005 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #if !defined(XALANIDENTWRITER_HEADER_GUARD_1357924680)
00017 #define XALANIDENTWRITER_HEADER_GUARD_1357924680
00018 
00019 
00020 // Base include file.  Must be first.
00021 #include <xalanc/XMLSupport/XMLSupportDefinitions.hpp>
00022 
00023 #include <xalanc/Include/XalanVector.hpp>
00024 
00025 #include <xalanc/PlatformSupport/Writer.hpp>
00026 
00027 
00028 XALAN_CPP_NAMESPACE_BEGIN
00029 
00030 
00031 template<class WhiteSpaceWriter,
00032          class NewLineWriter>
00033 class XalanIndentWriter
00034 {
00035 public:
00036     typedef typename XalanDOMString::size_type       size_type;
00037     typedef XalanVector<bool>               BoolStackType;
00038     typedef typename WhiteSpaceWriter::writer_type   writer_type;
00039 
00040     XalanIndentWriter(
00041             writer_type&    writer,
00042             size_type       ident) :
00043         m_whiteSpaceWriter(writer),
00044         m_newLineWriter(writer),
00045         m_indent(ident),
00046         m_currentIndent(0),
00047         m_startNewLine(false),
00048         m_ispreserve(false),
00049         m_isprevtext(false),
00050         m_preserves(writer.getMemoryManager(), 5)
00051     {
00052         assert( m_indent != -1);
00053     }
00054 
00055     ~XalanIndentWriter()
00056     {
00057     }
00058         
00059         
00060     void
00061     setIndent(size_type value)
00062     {
00063         m_indent = value;
00064     }
00065     
00066     size_type
00067     getIndent()const
00068     {
00069         return m_indent;
00070     }
00071     
00072     void
00073     indent()
00074     {
00075         if( shouldIndent() )
00076         {
00077             if(m_startNewLine == true)
00078             {
00079                 m_newLineWriter();
00080             }
00081 
00082             m_whiteSpaceWriter(m_currentIndent);
00083 
00084         }
00085     }
00086     
00087     void
00088     increaseIndent()
00089     {
00090         m_currentIndent += m_indent;
00091     }
00092     
00093     void
00094     decreaseIndent()
00095     {
00096         assert( m_currentIndent >= m_indent);
00097 
00098         m_currentIndent -= m_indent;
00099     }       
00100     
00101     void
00102     setStartNewLine(bool value)
00103     {
00104         m_startNewLine = value;
00105     }
00106 
00110     void
00111     outputLineSep()
00112     {
00113         m_newLineWriter();
00114     }
00115 
00116     void
00117     setPrevText(bool value)
00118     {
00119         m_isprevtext = value;
00120     }
00121 
00122     void
00123     setPreserve(bool value)
00124     {
00125         m_ispreserve = value;
00126     }
00127 
00128     void
00129     pop_preserve()
00130     {
00131         if ( m_preserves.empty() )
00132         {
00133             m_ispreserve = false;
00134         }
00135         else
00136         {
00137             m_ispreserve = m_preserves.back();
00138 
00139             m_preserves.pop_back();
00140         }
00141     }
00142 
00143     void
00144     push_preserve()
00145     {
00146         m_preserves.push_back(m_ispreserve);
00147     }
00148 
00149 private:
00150     bool
00151     shouldIndent() const
00152     {
00153        return (!m_ispreserve && !m_isprevtext);
00154        // return true;
00155     }
00156 
00157 private:
00158 
00159      //data members
00160      
00161     WhiteSpaceWriter m_whiteSpaceWriter;
00162 
00163     NewLineWriter    m_newLineWriter;
00164 
00168      size_type      m_indent;
00169 
00173      size_type      m_currentIndent;
00174 
00178      bool        m_startNewLine;
00179 
00184     bool        m_ispreserve; 
00185 
00190     bool        m_isprevtext; 
00191 
00196     BoolStackType   m_preserves;
00197 };
00198 
00199 XALAN_CPP_NAMESPACE_END
00200 
00201 
00202 
00203 #endif  // XALANIDENTWRITER_HEADER_GUARD_1357924680

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