InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IAttrCompare Class Referenceabstract

#include <IAttrCompare.h>

Inheritance diagram for IAttrCompare:
IPMUnknown

Public Types

enum  { kDefaultIID = IID_IATTRCOMPARE }
 

Public Member Functions

virtual bool16 Compare (IDataBase *db, const IPMUnknown *theOther) const =0
 
virtual int16 MemCmp (IDataBase *db, const IPMUnknown *theOther) const =0
 
- Public Member Functions inherited from IPMUnknown
virtual IPMUnknownQueryInterface (PMIID interfaceID) const =0
 
virtual void AddRef () const =0
 
virtual void Release () const =0
 

Detailed Description

Normally text attributes are compared by calling the ReadWrite on their persistent interfaces and comparing what is written. A text attribute can optionally aggregate an implementation of this interface to get special compare semantics. For example, if an object has multiple values that should be treated as equivalent, it's necessary to override the comparison behavior via this interface.

Member Function Documentation

virtual bool16 IAttrCompare::Compare (IDataBasedb,
const IPMUnknowntheOther 
) const
pure virtual

This method is used to compare the value of two instances of a text attribute. This method differs from MemCmp below in that the purpose of MemCmp is to provide an ordering/sorting for a list of attributes of this type. In some cases MemCmp may return not equal for two attributes when Compare would have considered them equal. (An example is the font style attribute, where a nil font style name is considered equivalent to the "Regular/Roman/Plain/Etc." face in a font by Compare, but are sorted as separate values by MemCmp().) Assuming this different is not important and this method cannot be implemented in a significantly faster way than MemCmp, a typical implementation would be "return this->MemCmp(db, theOther) == 0;" This method assumes the caller has insured the ClassID of this attribute and "theOther" match before calling Compare.

Returns
bool16 indicating whether the attribute values are equivalent
Parameters
dbIN database that the attributes are in. This may be need to look up objects the attribute refers to internally (e.g. colors, fonts, etc.).
theOtherIN any interface on the attribute to be compared to.
virtual int16 IAttrCompare::MemCmp (IDataBasedb,
const IPMUnknowntheOther 
) const
pure virtual

This method is used to compare one attribute to another and may be used to create an ordered list of attributes. This method assumes the caller has insured the ClassID of this attribute and "theOther" match before calling MemCmp.

Returns
-1, 0 or 1 indicating this attribute is less than, equal to, or greater than "theOther". This is used for sorting purposes when maintaining lists of attributes.
Parameters
dbIN database that the attributes are in. This may be need to look up objects the attribute refers to internally (e.g. colors, fonts, etc.).
theOtherIN any interface on the attribute to be compared to.