bool CssmDbAttributeInfo::operator <(const CssmDbAttributeInfo& other) const { if (nameFormat() < other.nameFormat()) return true; if (other.nameFormat() < nameFormat()) return false; // nameFormat's are equal. switch (nameFormat()) { case CSSM_DB_ATTRIBUTE_NAME_AS_STRING: { int res = strcmp(static_cast<const char *>(*this), static_cast<const char *>(other)); if (res < 0) return true; if (res > 0) return false; break; } case CSSM_DB_ATTRIBUTE_NAME_AS_OID: if (static_cast<const CssmOid &>(*this) < static_cast<const CssmOid &>(other)) return true; if (static_cast<const CssmOid &>(other) < static_cast<const CssmOid &>(*this)) return false; break; case CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER: if (static_cast<uint32>(*this) < static_cast<uint32>(other)) return true; if (static_cast<uint32>(other) < static_cast<uint32>(*this)) return false; break; default: CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME); } return format() < other.format(); }
bool CssmDbAttributeInfo::operator ==(const CssmDbAttributeInfo& other) const { if (nameFormat() != other.nameFormat()) return false; if (format() != other.format()) return false; switch (nameFormat()) { case CSSM_DB_ATTRIBUTE_NAME_AS_STRING: return !strcmp(static_cast<const char *>(*this), static_cast<const char *>(other)); case CSSM_DB_ATTRIBUTE_NAME_AS_OID: return static_cast<const CssmOid &>(*this) == static_cast<const CssmOid &>(other); case CSSM_DB_ATTRIBUTE_NAME_AS_INTEGER: return static_cast<uint32>(*this) == static_cast<uint32>(other); default: CssmError::throwMe(CSSMERR_DL_INVALID_FIELD_NAME); } }