|
|
|||
File indexing completed on 2025-12-17 10:31:16
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_CMNODE_HPP) 0023 #define XERCESC_INCLUDE_GUARD_CMNODE_HPP 0024 0025 #include <limits.h> 0026 0027 #include <xercesc/validators/common/ContentSpecNode.hpp> 0028 #include <xercesc/validators/common/CMStateSet.hpp> 0029 0030 XERCES_CPP_NAMESPACE_BEGIN 0031 0032 class CMNode : public XMemory 0033 { 0034 public : 0035 enum { 0036 // Special value to indicate a nullable node 0037 epsilonNode = UINT_MAX - 1 0038 }; 0039 0040 // ----------------------------------------------------------------------- 0041 // Constructors and Destructors 0042 // ----------------------------------------------------------------------- 0043 CMNode 0044 ( 0045 const ContentSpecNode::NodeTypes type 0046 , unsigned int maxStates 0047 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0048 ); 0049 virtual ~CMNode(); 0050 0051 0052 // ----------------------------------------------------------------------- 0053 // Virtual methods to be provided derived node classes 0054 // ----------------------------------------------------------------------- 0055 virtual void orphanChild() = 0; 0056 0057 // ----------------------------------------------------------------------- 0058 // Getter methods 0059 // ----------------------------------------------------------------------- 0060 ContentSpecNode::NodeTypes getType() const; 0061 const CMStateSet& getFirstPos(); 0062 const CMStateSet& getLastPos(); 0063 bool isNullable() const; 0064 0065 protected : 0066 // ----------------------------------------------------------------------- 0067 // Protected, abstract methods 0068 // ----------------------------------------------------------------------- 0069 virtual void calcFirstPos(CMStateSet& toUpdate) const = 0; 0070 virtual void calcLastPos(CMStateSet& toUpdate) const = 0; 0071 0072 // ----------------------------------------------------------------------- 0073 // Protected data members 0074 // 0075 // fMemoryManager 0076 // Pluggable memory manager for dynamic allocation/deallocation. 0077 // ----------------------------------------------------------------------- 0078 MemoryManager* fMemoryManager; 0079 0080 0081 private : 0082 // ----------------------------------------------------------------------- 0083 // Unimplemented constructors and operators 0084 // ----------------------------------------------------------------------- 0085 CMNode(); 0086 CMNode(const CMNode&); 0087 CMNode& operator=(const CMNode&); 0088 0089 0090 // ----------------------------------------------------------------------- 0091 // Private data members 0092 // 0093 // fType 0094 // The type of node. This indicates whether its a leaf or an 0095 // operation. 0096 // 0097 // fFirstPos 0098 // The set of NFA states that represent the entry states of this 0099 // node in the DFA. 0100 // 0101 // fLastPos 0102 // The set of NFA states that represent the final states of this 0103 // node in the DFA. 0104 // 0105 // fMaxStates 0106 // The maximum number of states that the NFA has, which means the 0107 // max number of NFA states that have to be traced in the state 0108 // sets during the building of the DFA. Its unfortunate that it 0109 // has to be stored redundantly, but we need to fault in the 0110 // state set members and they have to be sized to this size. 0111 // 0112 // fIsNullable 0113 // Whether the node can be empty 0114 // ----------------------------------------------------------------------- 0115 ContentSpecNode::NodeTypes fType; 0116 CMStateSet* fFirstPos; 0117 CMStateSet* fLastPos; 0118 unsigned int fMaxStates; 0119 0120 protected: 0121 bool fIsNullable; 0122 }; 0123 0124 0125 0126 // --------------------------------------------------------------------------- 0127 // CMNode: Constructors and Destructors 0128 // --------------------------------------------------------------------------- 0129 inline CMNode::CMNode(const ContentSpecNode::NodeTypes type 0130 , unsigned int maxStates 0131 , MemoryManager* const manager) : 0132 0133 fMemoryManager(manager) 0134 , fType(type) 0135 , fFirstPos(0) 0136 , fLastPos(0) 0137 , fMaxStates(maxStates) 0138 , fIsNullable(false) 0139 { 0140 } 0141 0142 inline CMNode::~CMNode() 0143 { 0144 // Clean up any position sets that got created 0145 delete fFirstPos; 0146 delete fLastPos; 0147 } 0148 0149 0150 // --------------------------------------------------------------------------- 0151 // CMNode: Getter methods 0152 // --------------------------------------------------------------------------- 0153 inline ContentSpecNode::NodeTypes CMNode::getType() const 0154 { 0155 return fType; 0156 } 0157 0158 inline const CMStateSet& CMNode::getFirstPos() 0159 { 0160 // 0161 // Fault in the state set if needed. Since we can't use mutable members 0162 // cast off the const'ness. 0163 // 0164 if (!fFirstPos) 0165 { 0166 fFirstPos = new (fMemoryManager) CMStateSet(fMaxStates, fMemoryManager); 0167 calcFirstPos(*fFirstPos); 0168 } 0169 return *fFirstPos; 0170 } 0171 0172 inline const CMStateSet& CMNode::getLastPos() 0173 { 0174 // 0175 // Fault in the state set if needed. Since we can't use mutable members 0176 // cast off the const'ness. 0177 // 0178 if (!fLastPos) 0179 { 0180 fLastPos = new (fMemoryManager) CMStateSet(fMaxStates, fMemoryManager); 0181 calcLastPos(*fLastPos); 0182 } 0183 return *fLastPos; 0184 } 0185 0186 inline bool CMNode::isNullable() const 0187 { 0188 return fIsNullable; 0189 } 0190 0191 XERCES_CPP_NAMESPACE_END 0192 0193 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|