Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
68
cde/programs/dtinfo/DtMmdb/StyleSheet/Feature.C
Normal file
68
cde/programs/dtinfo/DtMmdb/StyleSheet/Feature.C
Normal file
@@ -0,0 +1,68 @@
|
||||
// $XConsortium: Feature.cc /main/3 1996/06/11 17:06:39 cde-hal $
|
||||
#include "SymTab.h"
|
||||
#include "Feature.h"
|
||||
#include "FeatureValue.h"
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
Feature::Feature(const Symbol &name, FeatureValue *value)
|
||||
: f_name(name),
|
||||
f_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
Feature::Feature(const Feature &orig_feature)
|
||||
: f_name(orig_feature.name()),
|
||||
f_value(orig_feature.value()->clone())
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int Feature::operator==(const Feature &f )
|
||||
{
|
||||
return f.name() == f_name;
|
||||
}
|
||||
|
||||
Feature::~Feature()
|
||||
{
|
||||
delete f_value ;
|
||||
}
|
||||
|
||||
FeatureValue *
|
||||
Feature::evaluate() const
|
||||
{
|
||||
|
||||
return f_value->evaluate();
|
||||
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
// Printing
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ostream &operator << (ostream &o, const Feature &f)
|
||||
{
|
||||
return f.print(o);
|
||||
}
|
||||
|
||||
ostream &
|
||||
Feature::print(ostream &o) const
|
||||
{
|
||||
return o << f_name << ": " << *f_value ;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Feature::merge(const Feature &feature_to_merge)
|
||||
{
|
||||
assert(f_name == feature_to_merge.name());
|
||||
|
||||
if (*f_value == *feature_to_merge.value())
|
||||
;
|
||||
else
|
||||
{
|
||||
FeatureValue *new_value = f_value->merge(*feature_to_merge.value());
|
||||
delete f_value ;
|
||||
f_value = new_value ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user