00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XALAN_OUTPUTCONTEXTSTACK_HEADER_GUARD) 00019 #define XALAN_OUTPUTCONTEXTSTACK_HEADER_GUARD 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XSLT/XSLTDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/Include/XalanDeque.hpp> 00029 00030 00031 00032 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00033 00034 00035 00036 #include <xalanc/PlatformSupport/AttributeListImpl.hpp> 00037 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00038 00039 00040 00041 XALAN_CPP_NAMESPACE_BEGIN 00042 00043 00044 00045 class FormatterListener; 00046 00047 00048 00049 class XALAN_XSLT_EXPORT OutputContextStack 00050 { 00051 public: 00052 00053 struct OutputContext 00054 { 00055 OutputContext(MemoryManager& theManager, 00056 FormatterListener* theListener = 0) : 00057 m_flistener(theListener), 00058 m_pendingAttributes(theManager), 00059 m_pendingElementName(theManager), 00060 m_hasPendingStartDocument(false), 00061 m_mustFlushPendingStartDocument(false) 00062 { 00063 } 00064 00065 OutputContext( const OutputContext& other, 00066 MemoryManager& theManager) : 00067 m_flistener(other.m_flistener), 00068 m_pendingAttributes(other.m_pendingAttributes , theManager), 00069 m_pendingElementName(other.m_pendingElementName , theManager), 00070 m_hasPendingStartDocument(other.m_hasPendingStartDocument), 00071 m_mustFlushPendingStartDocument(other.m_mustFlushPendingStartDocument) 00072 { 00073 } 00074 00075 ~OutputContext() 00076 { 00077 } 00078 00079 void 00080 reset() 00081 { 00082 m_flistener = 0; 00083 00084 m_pendingAttributes.clear(); 00085 00086 m_pendingElementName.clear(); 00087 00088 m_hasPendingStartDocument = false; 00089 00090 m_mustFlushPendingStartDocument = false; 00091 } 00092 00093 FormatterListener* m_flistener; 00094 00095 AttributeListImpl m_pendingAttributes; 00096 00097 XalanDOMString m_pendingElementName; 00098 00099 bool m_hasPendingStartDocument; 00100 00101 bool m_mustFlushPendingStartDocument; 00102 }; 00103 00104 typedef XalanDeque<OutputContext, ConstructWithMemoryManagerTraits<OutputContext> > OutputContextStackType; 00105 00106 typedef OutputContextStackType::size_type size_type; 00107 00108 explicit 00109 OutputContextStack(MemoryManager& theManager); 00110 00111 ~OutputContextStack(); 00112 00113 void 00114 pushContext(FormatterListener* theListener = 0); 00115 00116 void 00117 popContext(); 00118 00119 FormatterListener* 00120 getFormatterListener() const 00121 { 00122 return (*m_stackPosition).m_flistener; 00123 } 00124 00125 FormatterListener*& 00126 getFormatterListener() 00127 { 00128 return (*m_stackPosition).m_flistener; 00129 } 00130 00131 const AttributeListImpl& 00132 getPendingAttributes() const 00133 { 00134 return (*m_stackPosition).m_pendingAttributes; 00135 } 00136 00137 AttributeListImpl& 00138 getPendingAttributes() 00139 { 00140 return (*m_stackPosition).m_pendingAttributes; 00141 } 00142 00143 const XalanDOMString& 00144 getPendingElementName() const 00145 { 00146 return (*m_stackPosition).m_pendingElementName; 00147 } 00148 00149 XalanDOMString& 00150 getPendingElementName() 00151 { 00152 return (*m_stackPosition).m_pendingElementName; 00153 } 00154 00155 const bool& 00156 getHasPendingStartDocument() const 00157 { 00158 return (*m_stackPosition).m_hasPendingStartDocument; 00159 } 00160 00161 bool& 00162 getHasPendingStartDocument() 00163 { 00164 return (*m_stackPosition).m_hasPendingStartDocument; 00165 } 00166 00167 const bool& 00168 getMustFlushPendingStartDocument() const 00169 { 00170 return (*m_stackPosition).m_mustFlushPendingStartDocument; 00171 } 00172 00173 bool& 00174 getMustFlushPendingStartDocument() 00175 { 00176 return (*m_stackPosition).m_mustFlushPendingStartDocument; 00177 } 00178 00179 size_type 00180 size() const 00181 { 00182 // Since we always keep one dummy entry at the beginning, 00183 // subtract one from the size 00184 assert(m_stackSize == size_type(OutputContextStackType::const_iterator(m_stackPosition) - m_stack.begin())); 00185 00186 return m_stackSize; 00187 } 00188 00189 bool 00190 empty() const 00191 { 00192 return size() == 0 ? true : false; 00193 } 00194 00195 void 00196 clear(); 00197 00198 void 00199 reset(); 00200 00201 private: 00202 00203 // not implemented 00204 OutputContextStack(const OutputContextStack&); 00205 00206 bool 00207 operator==(const OutputContextStack&) const; 00208 00209 OutputContextStack& 00210 operator=(const OutputContextStack&); 00211 00212 /** 00213 * A stack to hold the output contexts... 00214 */ 00215 OutputContextStackType m_stack; 00216 00217 OutputContextStackType::iterator m_stackPosition; 00218 00219 size_type m_stackSize; 00220 }; 00221 00222 00223 00224 XALAN_CPP_NAMESPACE_END 00225 00226 00227 00228 #endif // XALAN_RESULTNAMESPACESSTACK_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|