Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / Feature.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: Feature.h /main/4 1996/08/21 15:50:21 drk $ */
24 #ifndef _Feature_h
25 #define _Feature_h
26
27 #include <sstream>
28
29 #ifndef CDE_NEXT
30
31
32 #else
33 #include "dti_cc/CC_Slist.h"
34 #include "dti_cc/cc_povec.h"
35 #endif
36
37 #include "SymTab.h"
38
39 class Element;
40 class Expression;
41 class FeatureValue;
42 class VariableTable;
43 class ResolverStackElement ;
44 class Symbol;
45
46 /*
47 #ifndef CDE_NEXT
48 class dlist_array<Symbol> ;
49 #else
50 class dlist_array<Symbol> ;
51 #endif
52 */
53
54
55 /* **************************************************************
56  * class Feature
57
58  a symbol, value pairing where symbol is the feature name
59  * ************************************************************** */
60
61
62 class Feature
63 {
64 public:
65   Feature(const Symbol &, FeatureValue *);
66   Feature(const Feature &);
67   ~Feature();
68
69
70   const Symbol       &name()    const   { return f_name ; }
71   const FeatureValue *value()   const   { return f_value ; }    
72
73   FeatureValue *evaluate() const;
74
75   // destructively modifies f_value 
76   void merge(const Feature &);
77
78   ostream &print(ostream &) const ;
79
80   unsigned int operator==(const Feature&);
81
82 private:
83   void assembleChainFeatures(FeatureValue* x);
84
85 private:
86   Symbol        f_name ;
87   FeatureValue *f_value;
88
89 };
90
91 /* **************************************************************
92  * class FeatureSet
93
94  FeatureSet is is a list of features and their values. Features are
95  represented by symbols. Values can be strings, numbers (int or real)
96  or FeatureSet
97  * ************************************************************** */
98
99 #ifndef CDE_NEXT
100 class FeatureSet : public CC_TPtrSlist<Feature>
101 #else
102 class FeatureSet : public CC_TPtrSlist<Feature>
103 #endif
104 {
105 public:
106   FeatureSet();
107   FeatureSet(const FeatureSet &); /* copy */
108   FeatureSet(const FeatureSet &,
109              const FeatureSet &); /* merge */
110   virtual ~FeatureSet();
111
112   void                  add(Feature *);
113   const Feature        *lookup(const Symbol *) const ;
114   const Feature        *lookup(const Symbol &) const;
115   const Feature        *lookup(const char *) const;
116
117   // find a chain, eg for "prefix.font.size" use */
118   // deep_lookup("prefix","font","size", 0); 
119   // returns 0 if not found 
120   const Feature        *deep_lookup(const char * ...) const ;
121   const Feature        *deep_lookup(const Symbol * ...) const ;
122
123
124 #ifndef CDE_NEXT
125   const Feature        *deep_lookup(const dlist_array<Symbol> &) const ;
126 #else
127   const Feature        *deep_lookup(const dlist_array<Symbol> &) const ;
128 #endif
129
130 // remve a feature that is specified by a chain
131   void removeFeature(const char * ...) ;
132
133   // returns new feature set with all unresolved expressions resolved
134   FeatureSet *evaluate() const; 
135   // evaluate self and place answers into result_set, returns result set
136   FeatureSet *evaluate(FeatureSet *result_set) const ;
137
138   unsigned int operator == (const FeatureSet &) const ;
139
140   ostream &print(ostream &) const ;
141
142 private:
143
144   static unsigned int   f_print_indent_level ;
145   
146 };
147
148 /* **************************************************************
149  * Printing
150  * ************************************************************** */
151
152 ostream &operator << (ostream &o, const Feature &f);
153 ostream &operator << (ostream &o, const FeatureSet &f);
154
155
156 #endif /* _Feature_h */
157 /* DO NOT ADD ANY LINES AFTER THIS #endif */