Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / Feature.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 // $XConsortium: Feature.cc /main/3 1996/06/11 17:06:39 cde-hal $
24 #include "SymTab.h"
25 #include "Feature.h"
26 #include "FeatureValue.h"
27 #include <assert.h>
28 #include <stdarg.h>
29
30 Feature::Feature(const Symbol &name, FeatureValue *value)
31 : f_name(name),
32   f_value(value)
33 {
34 }
35
36 Feature::Feature(const Feature &orig_feature)
37 : f_name(orig_feature.name()),
38   f_value(orig_feature.value()->clone())
39 {
40 }
41
42 unsigned int Feature::operator==(const Feature &f )
43 {
44   return f.name() == f_name;
45 }
46
47 Feature::~Feature()
48 {
49   delete f_value ;
50 }
51
52 FeatureValue *
53 Feature::evaluate() const
54 {
55   
56   return f_value->evaluate();
57
58 }
59
60 // /////////////////////////////////////////////////////////////////////////
61 // Printing
62 // /////////////////////////////////////////////////////////////////////////
63
64 ostream &operator << (ostream &o, const Feature &f)
65 {
66   return f.print(o);
67 }
68
69 ostream &
70 Feature::print(ostream &o) const
71 {
72   return o << f_name << ": " << *f_value ;
73 }
74
75
76 void
77 Feature::merge(const Feature &feature_to_merge)
78 {
79   assert(f_name == feature_to_merge.name());
80
81   if (*f_value == *feature_to_merge.value())
82     ;
83   else
84     {
85       FeatureValue *new_value = f_value->merge(*feature_to_merge.value());
86       delete f_value ;
87       f_value = new_value ;
88     }
89 }
90