Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / PathTable.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: PathTable.h /main/4 1996/08/21 15:50:37 drk $ */
24 #ifndef _PathTable_h
25 #define _PathTable_h
26
27 #ifndef CDE_NEXT
28
29
30 #else
31 #include "dti_cc/CC_Dlist.h"
32 #include "dti_cc/cc_hdict.h"
33 #endif
34
35 #include <sstream>
36 #include "Types.h"
37 #include "SymTab.h"
38 #include "SSPath.h"
39 #include "BitVector.h"
40
41 class Feature;
42 class FeatureSet;
43
44 #define OP_ONE "?"
45 #define OP_MANY "*"
46 typedef unsigned int LetterType;
47
48 class EncodedPath 
49 {
50    int f_size;
51    int f_patternSize;
52    LetterType* f_array;
53
54    hashTable<LetterType, BitVector> f_SVectors;
55
56    LetterType f_wildCard;
57    LetterType f_unlimitedWildCard;
58
59    BitVector* f_copyOfS; // copy of S vector, used in match()
60
61 public:
62    EncodedPath(SSPath* p, unsigned int asPattern = false);
63    ~EncodedPath();
64
65    int length() { return f_size; };
66    int patternLength() { return f_patternSize; };
67
68    unsigned int match(EncodedPath& p, SSPath* Pattern, SSPath* Elements);
69 }
70 ;
71
72 class basePathFeature 
73 {
74
75 protected:
76   SSPath* f_path;
77    FeatureSet* f_featureSet;
78
79 public:
80
81    basePathFeature(SSPath* p=0, FeatureSet* f=0): 
82         f_path(p), f_featureSet(f) {};
83    ~basePathFeature();
84
85    unsigned int operator==(const basePathFeature&) const;
86
87    SSPath* path() { return f_path; };
88    FeatureSet* featureSet() { return f_featureSet; };
89
90    void setPath(SSPath* p) { f_path = p; };
91    void setFeatureSet(FeatureSet* fs) { f_featureSet = fs; };
92 };
93
94 class PathFeature : public basePathFeature
95 {
96    unsigned int f_id;
97    EncodedPath* f_encodedPath;
98
99 public:
100    PathFeature(SSPath* p,FeatureSet* f,EncodedPath* e=0, unsigned int id=0): 
101       basePathFeature(p, f), f_id(id), f_encodedPath(e) {};
102    ~PathFeature();
103
104    EncodedPath* encodedPath() { return f_encodedPath; };
105    unsigned int id() { return f_id; };
106
107    void setEncodedPath(EncodedPath* e) { f_encodedPath = e; };
108    void setID(int x) { f_id = x; };
109
110    unsigned int operator==(const PathFeature&) const;
111
112    unsigned int match(SSPath& p);
113 };
114
115 class PathFeatureList : public CC_TPtrDlist<PathFeature> 
116 {
117
118 public:
119    PathFeatureList() {};
120    virtual ~PathFeatureList();
121
122    void appendList(PathFeatureList&);
123 };
124
125 typedef CC_TPtrDlistIterator<PathFeature> PathFeatureListIterator;
126
127
128 // /////////////////////////////////////////////////////////////////////////
129 // 
130 //      class PathTable
131 //
132 // /////////////////////////////////////////////////////////////////////////
133
134 typedef CC_TPtrDlist<PathFeature>* CC_TPtrDlist_PathFeature_Ptr_T;
135
136 class PathTable
137 {
138 public:
139   PathTable();
140   ~PathTable();
141
142 // add a path and associated raw feature set 
143 // this should only be called by the style sheet parser to build this internal
144 // table  
145 //
146 // Assume that the paths are passed in in left to right order. i.e., 
147 // in the order   
148 //       "TITLE SECTION" 
149 //       "TITLE CHAPTER" 
150 // with the example shown above.
151 //
152   //void addPathFeatureSet(Path*, FeatureSet *rawFeatureSet);
153   void addPathFeatureSet(PathFeature*);
154
155 // returns a NULL value if no feature set is available at this point
156 // this "new"s a new feature set, and the caller is responsible for
157 // deleting the object
158   FeatureSet* getFeatureSet(SSPath&);
159
160   friend ostream& operator<<(ostream&, PathTable&);
161
162 private:
163   CC_TPtrDlist<PathFeature> f_pathFeatureList;
164   CC_TPtrDlist_PathFeature_Ptr_T *f_lastSymIndex;
165   unsigned int              f_lastSymIndexCount ;
166
167 private:
168   void initLastSymIndex();
169   unsigned int findIndex(SSPath&);
170   FeatureSet* getFeatureSet(int bucketIndex, SSPath&, int& pathId);
171 };
172
173 extern PathTable* gPathTab;
174
175 #endif /* _PathTable_h */
176 /* DO NOT ADD ANY LINES AFTER THIS #endif */