00001 /* 00002 * Copyright 2002-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 00017 /* 00018 * XSEC 00019 * 00020 * XSECXPathNodeList := A structure to hold node lists from XPath 00021 * evaluations 00022 * 00023 * Author(s): Berin Lautenbach 00024 * 00025 * $Id: XSECXPathNodeList.hpp 394807 2006-04-17 23:15:38Z blautenb $ 00026 * 00027 */ 00028 00029 #ifndef XSECXPATHNODELIST_INCLUDE 00030 #define XSECXPATHNODELIST_INCLUDE 00031 00032 // XSEC 00033 #include <xsec/framework/XSECDefs.hpp> 00034 00035 // Xerces 00036 00037 XSEC_DECLARE_XERCES_CLASS(DOMNode) 00038 00039 #define _XSEC_NODELIST_DEFAULT_SIZE 100 00040 00058 class DSIG_EXPORT XSECXPathNodeList { 00059 00060 public: 00061 00064 00065 XSECXPathNodeList(unsigned int initialSize = _XSEC_NODELIST_DEFAULT_SIZE); 00066 00075 XSECXPathNodeList(const XSECXPathNodeList &other); 00076 00077 ~XSECXPathNodeList(); 00078 00091 XSECXPathNodeList & operator= (const XSECXPathNodeList & toCopy); 00092 00093 00095 00096 00099 00109 void addNode(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n); 00110 00119 void removeNode(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n); 00120 00126 void clear(void); 00127 00129 00132 00139 bool hasNode(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n) const; 00140 00149 const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * getFirstNode(void) const; 00150 00159 const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *getNextNode(void) const; 00160 00162 00165 00174 void intersect(const XSECXPathNodeList &toIntersect); 00175 00177 00178 private: 00179 00180 /* Implement an unbalanced binary search tree */ 00181 typedef struct s_btn { 00182 struct s_btn * l; // Left 00183 struct s_btn * r; // Right 00184 struct s_btn * p; // Parent 00185 const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode 00186 * v; // Value 00187 long h; // Height 00188 } btn; 00189 00190 // Internal functions 00191 btn * findNodeIndex(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * n) const; 00192 void delete_tree(btn * t); 00193 btn * copy_tree(btn * t) const ; 00194 long balance_count(btn * t) const; 00195 void rotate_left(btn * t); 00196 void rotate_right(btn * t); 00197 long calc_height(btn * t); 00198 00199 btn * mp_tree; // The tree 00200 unsigned int m_num; // Number of elements in the tree 00201 00202 mutable btn * mp_current; // current point in list for getNextNode 00203 }; 00204 00205 00206 00207 #endif /* XSECXPATHNODELIST_INCLUDE */ 00208