xref: /aoo41x/main/rsc/inc/rsctree.hxx (revision f7c60c9c)
1*f7c60c9cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f7c60c9cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f7c60c9cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f7c60c9cSAndrew Rist  * distributed with this work for additional information
6*f7c60c9cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f7c60c9cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f7c60c9cSAndrew Rist  * "License"); you may not use this file except in compliance
9*f7c60c9cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f7c60c9cSAndrew Rist  *
11*f7c60c9cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f7c60c9cSAndrew Rist  *
13*f7c60c9cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f7c60c9cSAndrew Rist  * software distributed under the License is distributed on an
15*f7c60c9cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f7c60c9cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*f7c60c9cSAndrew Rist  * specific language governing permissions and limitations
18*f7c60c9cSAndrew Rist  * under the License.
19*f7c60c9cSAndrew Rist  *
20*f7c60c9cSAndrew Rist  *************************************************************/
21*f7c60c9cSAndrew Rist 
22*f7c60c9cSAndrew Rist 
23cdf0e10cSrcweir #ifndef _RSCTREE_HXX
24cdf0e10cSrcweir #define _RSCTREE_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <tools/link.hxx>
27cdf0e10cSrcweir #include <rsctools.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir /****************** C L A S S E S ****************************************/
30cdf0e10cSrcweir class BiNode
31cdf0e10cSrcweir {
32cdf0e10cSrcweir protected:
33cdf0e10cSrcweir 	BiNode* 	pLeft;	  // left subtree
34cdf0e10cSrcweir 	BiNode* 	pRight;   // right subtree
35cdf0e10cSrcweir 
36cdf0e10cSrcweir public:
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 						 // Wandelt eine doppelt verkettete Liste in
39cdf0e10cSrcweir 						 // einen binaeren Baum um
40cdf0e10cSrcweir 			BiNode *	ChangeDLListBTree( BiNode * pList );
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 						BiNode();
43cdf0e10cSrcweir 	virtual 			~BiNode();
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 						// Wandelt einen binaeren Baum in eine doppelt
47cdf0e10cSrcweir 						// verkettete Liste um
48cdf0e10cSrcweir 						BiNode* ChangeBTreeDLList();
49cdf0e10cSrcweir 
Left() const50cdf0e10cSrcweir 			BiNode *	Left() const { return pLeft  ; };
Right() const51cdf0e10cSrcweir 			BiNode *	Right() const{ return pRight ; };
52cdf0e10cSrcweir 			void		EnumNodes( Link aLink ) const;
53cdf0e10cSrcweir };
54cdf0e10cSrcweir 
55cdf0e10cSrcweir /*************************************************************************/
56cdf0e10cSrcweir class NameNode : public BiNode
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	void				SubOrderTree( NameNode * pOrderNode );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir protected:
61cdf0e10cSrcweir 						// pCmp ist Zeiger auf Namen
62cdf0e10cSrcweir 			NameNode*	Search( const void * pCmp ) const;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir public:
Left() const65cdf0e10cSrcweir 			NameNode*	Left() const { return (NameNode *)pLeft  ; };
Right() const66cdf0e10cSrcweir 			NameNode*	Right() const{ return (NameNode *)pRight ; };
67cdf0e10cSrcweir 			NameNode*	Search( const NameNode * pName ) const;
68cdf0e10cSrcweir 						// insert a new node in the b-tree
69cdf0e10cSrcweir 			sal_Bool		Insert( NameNode * pTN, sal_uInt32 * nDepth );
70cdf0e10cSrcweir 			sal_Bool		Insert( NameNode* pTN );
71cdf0e10cSrcweir 	virtual COMPARE 	Compare( const NameNode * ) const;
72cdf0e10cSrcweir 	virtual COMPARE 	Compare( const void * ) const;
73cdf0e10cSrcweir 			NameNode*	SearchParent( const NameNode * ) const;
74cdf0e10cSrcweir 						// return ist neue Root
75cdf0e10cSrcweir 			NameNode*	Remove( NameNode * );
76cdf0e10cSrcweir 			void		OrderTree();
77cdf0e10cSrcweir 			sal_Bool		IsOrderTree() const;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir };
80cdf0e10cSrcweir 
81cdf0e10cSrcweir /*************************************************************************/
82cdf0e10cSrcweir class IdNode : public NameNode
83cdf0e10cSrcweir {
84cdf0e10cSrcweir 	virtual COMPARE Compare( const NameNode * ) const;
85cdf0e10cSrcweir 	virtual COMPARE Compare( const void * ) const;
86cdf0e10cSrcweir protected:
87cdf0e10cSrcweir     using NameNode::Search;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir public:
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	IdNode* 		Search( sal_uInt32 nTypName ) const;
92cdf0e10cSrcweir 	virtual sal_uInt32	GetId() const;
93cdf0e10cSrcweir };
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /*************************************************************************/
96cdf0e10cSrcweir class StringNode : public NameNode
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	virtual COMPARE Compare( const NameNode * ) const;
99cdf0e10cSrcweir 	virtual COMPARE Compare( const void * ) const;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir protected:
102cdf0e10cSrcweir     using NameNode::Search;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	ByteString		aName;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir public:
StringNode()107cdf0e10cSrcweir 					StringNode(){};
StringNode(const ByteString & rStr)108cdf0e10cSrcweir 					StringNode( const ByteString & rStr ) { aName = rStr; }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	StringNode* 	Search( const char * ) const;
GetName() const111cdf0e10cSrcweir 	ByteString		GetName() const { return aName; }
112cdf0e10cSrcweir };
113cdf0e10cSrcweir 
114cdf0e10cSrcweir #endif // _RSCTREE_HXX
115