Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / SSPath.C
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 // $TOG: SSPath.C /main/5 1998/04/17 11:49:33 mgreess $
24
25 #ifndef CDE_NEXT
26
27 #else
28 #include "dti_cc/CC_Tokenizer.h"
29 #endif
30
31 #include "SSPath.h"
32 #include "Debug.h"
33 #include "SymTab.h"
34 #include "StyleSheetExceptions.h"
35
36 unsigned int GI_CASE_SENSITIVE = false;
37
38 PathTerm::PathTerm(const Element& element) :
39         f_element(element), f_PQExpr(0)
40 {
41 }
42
43 PathTerm::PathTerm(const Symbol& symbol, PQExpr* expr) :
44         f_element(symbol), f_PQExpr(expr)
45 {
46 }
47
48 PathTerm::PathTerm(const char* symbol, PQExpr* expr) :
49         f_element(gElemSymTab -> intern(symbol, true)), f_PQExpr(expr)
50 {
51 }
52
53 PathTerm::~PathTerm()
54 {
55    delete f_PQExpr;
56 }
57
58 unsigned int PathTerm::operator ==(const PathTerm&)
59 {
60    MESSAGE(cerr, "PathTerm::operator ==() should not be called");
61    throw(CASTBEEXCEPT badEvaluationException());
62    return 0;
63 }
64
65 ostream& operator <<(ostream& out, PathTerm& pt)
66 {
67    out << pt.symbol() << " (" << size_t(pt.f_PQExpr) << ") ";
68    return out;
69 }
70
71 ////////////////////////////////////////////
72 //
73 ////////////////////////////////////////////
74
75 void SSPath::appendPathTerm(PathTerm* pt)
76 {
77    if ( pt -> pqexpr() )
78       f_containPathQualifier = true;
79
80    append(pt);
81 }
82
83 void SSPath::prependPath(SSPath& p)
84 {
85    if ( p.entries() == 0 )
86       return;
87
88    CC_TPtrDlistIterator<PathTerm> l_Iter(p);
89    l_Iter += p.entries();
90
91    PathTerm* l_pathTerm = 0;
92
93    do {
94       //prepend(new PathTerm(*l_Iter.key()));
95
96       l_pathTerm = l_Iter.key();
97  
98       prepend(l_pathTerm);
99
100       if ( l_pathTerm -> pqexpr() )
101          f_containPathQualifier = true;
102
103       
104    } while ( --l_Iter );
105 }
106
107 SSPath::SSPath()
108 : f_containPathQualifier(false), f_fastGetIndex(0)
109 {
110 }
111
112 SSPath::~SSPath()
113 {
114   // clean up memory 
115   clearAndDestroy();
116   delete f_fastGetIndex;
117 }
118
119 SSPath::SSPath(char* str, unsigned int AssignId) : 
120    f_containPathQualifier(false), f_fastGetIndex(0)
121 {
122    CC_String a(str);
123    CC_Tokenizer next(a);
124    CC_String token;
125  
126 #ifndef CDE_NEXT
127    while ( !(token=next()).isNull() ) {
128      append(new PathTerm(token.data(), 0));
129    }
130 #else
131    while ( next() ) {
132      append(new PathTerm(token.data(), 0));
133    }
134 #endif
135 }
136
137 ostream& operator<<(ostream& out, SSPath& p)
138 {
139    CC_TPtrDlistIterator<PathTerm> l_Iter(p);
140    while ( ++l_Iter ) {
141      out << *l_Iter.key() << ' ';
142    }
143    return out;
144 }
145
146 void SSPath::fastGetIndex()
147 {
148    f_fastGetIndex = new value_vector<PathTermPtr>(entries());
149
150    CC_TPtrDlistIterator<PathTerm> l_Iter(*this);
151    int i=0;
152    while ( ++l_Iter ) {
153      (*f_fastGetIndex)[i++] = l_Iter.key();
154    }
155 }
156