Bug 984761 - Add FilterAttribute::operator==. r=roc

This commit is contained in:
Markus Stange 2014-03-20 10:12:44 +08:00
parent a845b1be54
commit 26ae3d738f

View File

@ -1576,6 +1576,12 @@ struct FilterAttribute {
FilterAttribute(const FilterAttribute& aOther);
~FilterAttribute();
bool operator==(const FilterAttribute& aOther) const;
bool operator!=(const FilterAttribute& aOther) const
{
return !(*this == aOther);
}
#define MAKE_CONSTRUCTOR_AND_ACCESSOR_BASIC(type, typeLabel) \
FilterAttribute(type aValue) \
: mType(AttributeType::e##typeLabel), m##typeLabel(aValue) \
@ -1708,6 +1714,39 @@ FilterAttribute::~FilterAttribute() {
}
}
bool
FilterAttribute::operator==(const FilterAttribute& aOther) const
{
if (mType != aOther.mType) {
return false;
}
switch (mType) {
#define HANDLE_TYPE(typeName) \
case AttributeType::e##typeName: \
return m##typeName == aOther.m##typeName;
HANDLE_TYPE(Bool)
HANDLE_TYPE(Uint)
HANDLE_TYPE(Float)
HANDLE_TYPE(Size)
HANDLE_TYPE(IntSize)
HANDLE_TYPE(IntPoint)
HANDLE_TYPE(Matrix)
HANDLE_TYPE(Matrix5x4)
HANDLE_TYPE(Point3D)
HANDLE_TYPE(Color)
HANDLE_TYPE(AttributeMap)
HANDLE_TYPE(Floats)
#undef HANDLE_TYPE
default:
return false;
}
}
typedef FilterAttribute Attribute;
AttributeMap::AttributeMap()