Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / SSPath.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: SSPath.h /main/4 1996/08/21 15:50:49 drk $ */
24 #ifndef _Path_h
25 #define _Path_h
26
27 #include "SymTab.h"
28 #include "Element.h"
29 #include "PathQualifier.h"
30
31 #ifndef CDE_NEXT
32
33
34 #else
35 #include "dti_cc/CC_Dlist.h"
36 #include "dti_cc/cc_vvect.h"
37 #endif
38
39 // path term object class
40 // each term is made up of a SGMLGI and an optional
41 // expression.
42 class PathTerm
43 {
44 public:
45    PathTerm(const Element&);
46    PathTerm(const Symbol&, PQExpr* = 0);
47    PathTerm(const char* symbol, PQExpr* = 0);
48    ~PathTerm();
49
50    unsigned int operator ==(const PathTerm&);
51
52    const Element& element() { return f_element; };
53    const Symbol& symbol() { return f_element.gi(); };
54    PQExpr* pqexpr() { return f_PQExpr; };
55
56    friend ostream& operator <<(ostream&, PathTerm&);
57
58 private:
59    const Element f_element;
60    PQExpr* f_PQExpr;
61 };
62
63 typedef PathTerm* PathTermPtr;
64
65 ////////////////////////////////////////////
66 // path of path terms
67 ////////////////////////////////////////////
68 class SSPath : public CC_TPtrDlist<PathTerm>
69 {
70
71 private:
72    unsigned int f_containPathQualifier;
73    value_vector<PathTermPtr>* f_fastGetIndex; 
74
75 public:
76    SSPath(char*, unsigned int assignId); // for test purpose
77    SSPath();
78    ~SSPath();
79
80 // this call update f_containPathQualifier field
81    void appendPathTerm(PathTerm*);
82
83    unsigned int containSelector() { return f_containPathQualifier; };
84
85 // prepend p to this. Elements in p are added to this.
86    void prependPath(SSPath& p); 
87
88 // Set up an index so that the random access to elements in the list can 
89 // be O(1). No range checking is performed.
90 // Set up the index by calling fastGetIndex() before any fastGetAt() call.
91    void fastGetIndex();
92    PathTerm* fastGetAt(unsigned int i) { return (*f_fastGetIndex)[i]; };
93
94    friend ostream& operator<< (ostream&, SSPath&);
95 };
96
97 typedef CC_TPtrDlist<char> charPtrDlist;
98
99 extern unsigned int gGI_CASE_SENSITIVE;
100
101 #endif /* _Path_h */
102 /* DO NOT ADD ANY LINES AFTER THIS #endif */