ObjFW  Check-in [3af65b5d98]

Overview
Comment:OFXMLElement: Add a few extra type checks
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3af65b5d981be2e8a32a212adef2f483a78c3c9df5cebe3d69389e91612378f9
User & Date: js on 2018-06-16 14:21:29
Other Links: manifest | tags
Context
2018-06-16
14:36
OFXML*: Remember delimiter of attributes check-in: 0ec6f9c1d9 user: js tags: trunk
14:21
OFXMLElement: Add a few extra type checks check-in: 3af65b5d98 user: js tags: trunk
14:15
Wrap a few @public in #ifdefs check-in: 7d86d2dd2b user: js tags: trunk
Changes

Modified src/OFXMLAttribute.h from [b8ee421c7f] to [a635c9f146].

24
25
26
27
28
29
30

31

32
33
34
35
36
37
38
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40







+

+







/*!
 * @class OFXMLAttribute OFXMLAttribute.h ObjFW/OFXMLAttribute.h
 *
 * @brief A representation of an attribute of an XML element as an object.
 */
@interface OFXMLAttribute: OFXMLNode
{
#if defined(OF_XML_ELEMENT_M) || defined(OF_XML_PARSER_M)
@public
#endif
	OFString *_name, *_Nullable _namespace, *_stringValue;
}

/*!
 * @brief The name of the attribute.
 */
@property (readonly, nonatomic) OFString *name;

Modified src/OFXMLElement.m from [6014d156f0] to [0b50609229].

13
14
15
16
17
18
19


20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28







+
+







 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#define OF_XML_ELEMENT_M

#include <stdlib.h>
#include <string.h>

#include <assert.h>

#import "OFXMLElement.h"
#import "OFXMLNode+Private.h"
187
188
189
190
191
192
193
194


195
196
197
198
199
200
201
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203
204







-
+
+







}

- (instancetype)initWithElement: (OFXMLElement *)element
{
	self = [super of_init];

	@try {
		if (element == nil)
		if (element == nil ||
		    ![element isKindOfClass: [OFXMLElement class]])
			@throw [OFInvalidArgumentException exception];

		_name = [element->_name copy];
		_namespace = [element->_namespace copy];
		_defaultNamespace = [element->_defaultNamespace copy];
		_attributes = [element->_attributes mutableCopy];
		_namespaces = [element->_namespaces mutableCopy];
756
757
758
759
760
761
762



763
764
765
766
767
768
769
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775







+
+
+







	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}

- (void)addAttribute: (OFXMLAttribute *)attribute
{
	if (![attribute isKindOfClass: [OFXMLAttribute class]])
		@throw [OFInvalidArgumentException exception];

	if (_attributes == nil)
		_attributes = [[OFMutableArray alloc] init];

	if ([self attributeForName: attribute->_name
			 namespace: attribute->_namespace] == nil)
		[_attributes addObject: attribute];
}

Modified src/OFXMLParser.m from [b2f6d860ce] to [3d72b3b75b].

12
13
14
15
16
17
18


19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27







+
+







 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#define OF_XML_PARSER_M

#include <string.h>

#import "OFXMLParser.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"