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: feature.cc /main/3 1996/06/11 17:10:23 cde-hal $
24 #include "StyleSheetExceptions.h"
27 #include "FeatureValue.h"
28 #include "StyleSheet.h"
36 styleerror(char *errorstr)
38 cerr << "Parse Error: " << errorstr << endl;
41 main(int argc, char **argv)
45 Stack<FeatureSet*,dlist_array<FeatureSet> > *stack;
46 Stack<FeatureSet*,dlist_array<FeatureSet> > stack1 ;
47 Stack<FeatureSet*,dlist_array<FeatureSet> > stack2 ;
49 stack1.push(new FeatureSet());
50 stack2.push(new FeatureSet());
56 // make sure args are balanced
60 cout << "feature [<name> <value>]+" << endl;
63 for (int i = 1 ; i < argc ; )
68 // start a new feature set
75 FeatureSet *newset = new FeatureSet();
76 stack->top()->add(new Feature(gSymTab->intern(argv[i++]),
77 new FeatureValueFeatureSet(newset)));
89 char c = argv[i+1][0] ;
90 FeatureValue *value = 0;
92 if (c >= '0' && c <= '9')
93 value = new FeatureValueInt(atoi(argv[i+1]));
95 value = new FeatureValueSymbol(gSymTab->intern(argv[i+1]));
97 value = new FeatureValueString(argv[i+1]);
99 stack->top()->add(new Feature(gSymTab->intern(argv[i++]),
107 cout << "************** orig ****************" << endl;
108 cout << *stack1.top() << endl;
109 cout << "************** copy ****************" << endl;
111 FeatureSet *copy = new FeatureSet(*stack1.top());
113 cout << *copy << endl;
118 FeatureSet *merged = new FeatureSet(*stack1.top(), *stack2.top());
120 // delete these and check for memory leaks
124 cout << "************** merged ****************" << endl;
125 cout << *merged << endl;
129 const Feature *f = merged->deep_lookup("font", "size", 0);
130 cout << "deep_lookup(\"font\", \"size\"): " ;
134 cout << "(nil)" << endl;
136 // now try it with Symbols
137 Symbol font (gSymTab->intern("font"));
138 Symbol size (gSymTab->intern("size"));
139 f = merged->deep_lookup(&font,
141 cout << "deep_lookup(\"font\", \"size\"): " ;
145 cout << "(nil)" << endl;
150 cout << "exception thrown" << endl;