2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: FeatureDefDictionary.h /main/4 1996/08/21 15:50:25 drk $ */
25 #ifndef _featureNameDictionary_h
26 #define _featureNameDictionary_h
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"
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"
45 typedef CC_TPtrSlist<FeatureValue> defv_t;
46 typedef CC_TPtrSlistIterator<FeatureValue> defv_iterator_t;
48 class TypeValues : public Destructable
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 };
55 TypeValues(char* type, defv_t*);
58 unsigned int operator==(const TypeValues&);
60 unsigned check(const FeatureValue*);
62 friend ostream& operator <<(ostream&, TypeValues&);
63 ostream& print(ostream&, int tabs) const;
67 defv_t* f_default_values;
74 typedef CC_TPtrSlist<FeatureDef> def_list_t;
75 typedef CC_TPtrSlistIterator<FeatureDef> def_list_iterator_t;
77 typedef CC_TPtrSlist<TypeValues> type_values_list_t;
78 typedef CC_TPtrSlistIterator<TypeValues> type_values_list_iterator_t;
81 class FeatureDef : public Destructable
85 FeatureDef(const char* name);
86 virtual ~FeatureDef();
88 unsigned int operator==(const FeatureDef&);
90 friend ostream& operator <<(ostream&, FeatureDef&) ;
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; };
96 virtual ostream& print(ostream&, int tabs) const= 0;
97 virtual unsigned checkContent(const Feature*) const = 0;
105 class FeatureDefComposite : public FeatureDef
108 FeatureDefComposite(const char* name, def_list_t*);
109 ~FeatureDefComposite();
111 unsigned checkContent(const Feature*)const ;
113 const FeatureDef* getComponentDef(const char*) const;
115 unsigned type() const { return COMPOSITE; };
118 def_list_t* f_components;
121 virtual ostream& print(ostream&, int tabs) const;
125 class FeatureDefPrimitive: public FeatureDef
128 FeatureDefPrimitive(const char* name, type_values_list_t* tvslist);
129 ~FeatureDefPrimitive();
131 unsigned type() const { return PRIMITIVE; };
133 unsigned checkContent(const Feature*)const ;
136 type_values_list_t* f_typeValuesList;
139 virtual ostream& print(ostream&, int tabs) const;
143 class FeatureDefReference : public FeatureDef
146 FeatureDefReference(const char* name) : FeatureDef(name) {};
147 ~FeatureDefReference() {};
149 unsigned type() const { return REFERENCE; };
150 unsigned checkContent(const Feature*)const ;
155 virtual ostream& print(ostream&, int tabs) const;
159 class FeatureDefWildCard : public FeatureDef
162 FeatureDefWildCard(const char* name) : FeatureDef(name) {};
163 ~FeatureDefWildCard() {};
165 unsigned type() const { return WILDCARD; };
166 unsigned checkContent(const Feature*)const ;
171 virtual ostream& print(ostream&, int tabs) const;
175 //typedef hashTable<FeatureDef, FeatureDef> featureDefDictionary_t;
176 //typedef hashTableIterator<FeatureDef, FeatureDef> featureDefDictionary_iterator_t;
178 class featureDefDictionary : public Destructable
181 def_list_t* f_def_list;
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*);
190 featureDefDictionary();
191 ~featureDefDictionary();
193 void addFeatureDefs(def_list_t*);
195 unsigned checkSemantics(const FeatureSet*);
200 // ComponentName : Type [: Default Values (',' separated)]
201 // ComponentName : Type [: Default Values (',' separated)]
203 // ComponentName : Type [: Default Values (',' separated)]
204 // ComponentName : Type [: Default Values (',' separated)]
209 // weight : String : "medium", "bold"
211 friend istream& operator >>(istream&, featureDefDictionary&);
212 friend ostream& operator <<(ostream&, featureDefDictionary&);