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