Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / FeatureDefDictionary.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: FeatureDefDictionary.h /main/4 1996/08/21 15:50:25 drk $ */
24
25 #ifndef _featureNameDictionary_h
26 #define _featureNameDictionary_h
27
28 #ifndef CDE_NEXT
29
30
31
32 #else
33 //#include "StyleSheet/cde_next.h"
34 #include "dti_cc/CC_Slist.h"
35 #include "dti_cc/cc_hdict.h"
36 #include "dti_cc/CC_String.h"
37 #endif
38
39 #include "StyleSheet/Types.h"
40 #include "StyleSheet/SymTab.h"
41 #include "StyleSheet/FeatureValue.h"
42 #include "StyleSheet/Feature.h"
43 #include "StyleSheet/StyleSheetExceptions.h"
44
45 typedef CC_TPtrSlist<FeatureValue> defv_t; 
46 typedef CC_TPtrSlistIterator<FeatureValue> defv_iterator_t; 
47
48 class TypeValues : public Destructable
49 {
50 public:
51
52    enum feature_t {real, integer, string, featureset, unit} ;
53    enum unit_t { INCH=0, PICA=1, POINT=2, CM=3, PIXEL=4, NONE=5 };
54
55    TypeValues(char* type, defv_t*);
56    ~TypeValues();
57
58    unsigned int operator==(const TypeValues&);
59
60    unsigned check(const FeatureValue*);
61
62    friend ostream& operator <<(ostream&, TypeValues&);
63    ostream& print(ostream&, int tabs) const;
64
65 protected:
66    CC_String f_type;
67    defv_t* f_default_values;
68
69 protected:
70 };
71
72 class FeatureDef;
73
74 typedef CC_TPtrSlist<FeatureDef> def_list_t; 
75 typedef CC_TPtrSlistIterator<FeatureDef> def_list_iterator_t; 
76
77 typedef CC_TPtrSlist<TypeValues> type_values_list_t; 
78 typedef CC_TPtrSlistIterator<TypeValues> type_values_list_iterator_t; 
79         
80
81 class FeatureDef  : public Destructable
82 {
83 public:
84
85    FeatureDef(const char* name);
86    virtual ~FeatureDef();
87
88    unsigned int operator==(const FeatureDef&);
89
90    friend ostream& operator <<(ostream&, FeatureDef&) ;
91
92    enum def_type_t { PRIMITIVE, COMPOSITE, REFERENCE, WILDCARD };
93    virtual unsigned type() const = 0;
94    virtual const CC_String* name() const { return &f_name; };
95
96    virtual ostream& print(ostream&, int tabs)  const= 0;
97    virtual unsigned checkContent(const Feature*) const = 0;
98
99 protected:
100    CC_String f_name;
101
102 protected:
103 };
104
105 class FeatureDefComposite : public FeatureDef
106 {
107 public:
108    FeatureDefComposite(const char* name, def_list_t*);
109    ~FeatureDefComposite();
110
111    unsigned checkContent(const Feature*)const ;
112
113    const FeatureDef* getComponentDef(const char*) const;
114
115    unsigned type() const { return COMPOSITE; };
116
117 protected:
118    def_list_t* f_components;
119
120 protected:
121    virtual ostream& print(ostream&, int tabs) const;
122 }
123 ;
124
125 class FeatureDefPrimitive: public FeatureDef
126 {
127 public:
128    FeatureDefPrimitive(const char* name, type_values_list_t* tvslist);
129    ~FeatureDefPrimitive();
130
131    unsigned type() const { return PRIMITIVE; };
132
133    unsigned checkContent(const Feature*)const ;
134
135 protected:
136    type_values_list_t* f_typeValuesList;
137
138 protected:
139    virtual ostream& print(ostream&, int tabs) const;
140 }
141 ;
142
143 class FeatureDefReference : public FeatureDef
144 {
145 public:
146    FeatureDefReference(const char* name) : FeatureDef(name) {};
147    ~FeatureDefReference() {};
148
149    unsigned type() const { return REFERENCE; };
150    unsigned checkContent(const Feature*)const ;
151
152 protected:
153
154 protected:
155    virtual ostream& print(ostream&, int tabs) const;
156 }
157 ;
158
159 class FeatureDefWildCard : public FeatureDef
160 {
161 public:
162    FeatureDefWildCard(const char* name) : FeatureDef(name) {};
163    ~FeatureDefWildCard() {};
164
165    unsigned type() const { return WILDCARD; };
166    unsigned checkContent(const Feature*)const ;
167
168 protected:
169
170 protected:
171    virtual ostream& print(ostream&, int tabs) const;
172 }
173 ;
174
175 //typedef hashTable<FeatureDef, FeatureDef> featureDefDictionary_t;
176 //typedef hashTableIterator<FeatureDef, FeatureDef> featureDefDictionary_iterator_t;
177
178 class featureDefDictionary  : public Destructable
179 {
180 protected:
181         def_list_t* f_def_list;
182
183 protected:
184         const FeatureDef* getDef(const char*);
185         const FeatureDef* getDef(const Feature*);
186         //const FeatureDef* getDef(const Feature*, const Feature*);
187         unsigned _checkSemantics(const Feature* f, const FeatureDef*);
188
189 public:
190         featureDefDictionary();
191         ~featureDefDictionary();
192         
193         void addFeatureDefs(def_list_t*);
194
195         unsigned checkSemantics(const FeatureSet*);
196
197 //format:
198 //
199 //   featureName
200 //      ComponentName : Type [: Default Values (',' separated)]
201 //      ComponentName : Type [: Default Values (',' separated)]
202 //   featureName
203 //      ComponentName : Type [: Default Values (',' separated)]
204 //      ComponentName : Type [: Default Values (',' separated)]
205 //
206 //   Example:
207 //   font
208 //      size : Unit 
209 //      weight : String : "medium", "bold"
210 //
211         friend istream& operator >>(istream&, featureDefDictionary&);
212         friend ostream& operator <<(ostream&, featureDefDictionary&);
213 };
214
215 #endif