ObjXMPP  Diff

Differences From Artifact [45b58d387c]:

To Artifact [6198736245]:


1
2
3
4
5
6
7
8
9
10
/*
 * Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de>
 * Copyright (c) 2013, 2016, 2019, Jonathan Schleifer <js@heap.zone>
 *
 * https://heap.zone/objxmpp/
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
 *


|







1
2
3
4
5
6
7
8
9
10
/*
 * Copyright (c) 2013, Florian Zeitz <florob@babelmonkeys.de>
 * Copyright (c) 2013, 2016, 2019, 2021, Jonathan Schleifer <js@nil.im>
 *
 * https://heap.zone/objxmpp/
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice is present in all copies.
 *
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
	    (_name == identity->_name || [_name isEqual: identity->_name]) &&
	    [_type isEqual: identity->_type])
		return true;

	return false;
}

- (uint32_t)hash
{
	uint32_t hash;

	OF_HASH_INIT(hash);

	OF_HASH_ADD_HASH(hash, _category.hash);
	OF_HASH_ADD_HASH(hash, _type.hash);
	OF_HASH_ADD_HASH(hash, _name.hash);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (of_comparison_result_t)compare: (id <OFComparing>)object
{
	XMPPDiscoIdentity *identity;
	of_comparison_result_t categoryResult;
	of_comparison_result_t typeResult;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![(id)object isKindOfClass: [XMPPDiscoIdentity class]])
		@throw [OFInvalidArgumentException exception];

	identity = (XMPPDiscoIdentity *)object;

	categoryResult = [_category compare: identity->_category];
	if (categoryResult != OF_ORDERED_SAME)
		return categoryResult;

	typeResult = [_type compare: identity->_type];
	if (typeResult != OF_ORDERED_SAME)
		return typeResult;

	return [_name compare: identity->_name];
}
@end







|

|

|

|
|
|

|




|


|
<


|







|



|





101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
	    (_name == identity->_name || [_name isEqual: identity->_name]) &&
	    [_type isEqual: identity->_type])
		return true;

	return false;
}

- (unsigned long)hash
{
	unsigned long hash;

	OFHashInit(&hash);

	OFHashAddHash(&hash, _category.hash);
	OFHashAddHash(&hash, _type.hash);
	OFHashAddHash(&hash, _name.hash);

	OFHashFinalize(&hash);

	return hash;
}

- (OFComparisonResult)compare: (id <OFComparing>)object
{
	XMPPDiscoIdentity *identity;
	OFComparisonResult categoryResult, typeResult;


	if (object == self)
		return OFOrderedSame;

	if (![(id)object isKindOfClass: [XMPPDiscoIdentity class]])
		@throw [OFInvalidArgumentException exception];

	identity = (XMPPDiscoIdentity *)object;

	categoryResult = [_category compare: identity->_category];
	if (categoryResult != OFOrderedSame)
		return categoryResult;

	typeResult = [_type compare: identity->_type];
	if (typeResult != OFOrderedSame)
		return typeResult;

	return [_name compare: identity->_name];
}
@end