ObjFW
Loading...
Searching...
No Matches
OFXMLElement.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This file is part of ObjFW. It may be distributed under the terms of the
7 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8 * the packaging of this file.
9 *
10 * Alternatively, it may be distributed under the terms of the GNU General
11 * Public License, either version 2 or 3, which can be found in the file
12 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13 * file.
14 */
15
16#import "OFXMLNode.h"
17
18OF_ASSUME_NONNULL_BEGIN
19
20@class OFArray OF_GENERIC(ObjectType);
21@class OFMutableArray OF_GENERIC(ObjectType);
22@class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
23@class OFMutableString;
24@class OFStream;
25@class OFString;
26@class OFXMLAttribute;
27
34{
35 OFString *_name, *_Nullable _namespace;
36 OFMutableArray OF_GENERIC(OFXMLAttribute *) *_Nullable _attributes;
37 OFMutableDictionary OF_GENERIC(OFString *, OFString *) *_Nullable
38 _namespaces;
39 OFMutableArray OF_GENERIC(OFXMLNode *) *_Nullable _children;
40 OF_RESERVE_IVARS(OFXMLElement, 4)
41}
42
46@property (copy, nonatomic) OFString *name;
47
51#ifndef __cplusplus
52@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *namespace;
53#else
54@property OF_NULLABLE_PROPERTY (copy, nonatomic,
55 getter=namespace, setter=setNamespace:) OFString *nameSpace;
56#endif
57
61@property OF_NULLABLE_PROPERTY (readonly, nonatomic)
62 OFArray OF_GENERIC(OFXMLAttribute *) *attributes;
63
67@property OF_NULLABLE_PROPERTY (nonatomic, copy)
68 OFArray OF_GENERIC(OFXMLNode *) *children;
69
73@property (readonly, nonatomic) OFArray OF_GENERIC(OFXMLElement *) *elements;
74
81+ (instancetype)elementWithName: (OFString *)name;
82
91+ (instancetype)elementWithName: (OFString *)name
92 stringValue: (nullable OFString *)stringValue;
93
102+ (instancetype)elementWithName: (OFString *)name
103 namespace: (nullable OFString *)nameSpace;
104
115+ (instancetype)elementWithName: (OFString *)name
116 namespace: (nullable OFString *)nameSpace
117 stringValue: (nullable OFString *)stringValue;
118
129+ (instancetype)elementWithXMLString: (OFString *)string;
130
142+ (instancetype)elementWithStream: (OFStream *)stream;
143
144- (instancetype)init OF_UNAVAILABLE;
145
152- (instancetype)initWithName: (OFString *)name;
153
163- (instancetype)initWithName: (OFString *)name
164 stringValue: (nullable OFString *)stringValue;
165
175- (instancetype)initWithName: (OFString *)name
176 namespace: (nullable OFString *)nameSpace
177 OF_DESIGNATED_INITIALIZER;
178
189- (instancetype)initWithName: (OFString *)name
190 namespace: (nullable OFString *)nameSpace
191 stringValue: (nullable OFString *)stringValue;
192
204- (instancetype)initWithXMLString: (OFString *)string;
205
217- (instancetype)initWithStream: (OFStream *)stream;
218
225- (void)setPrefix: (OFString *)prefix forNamespace: (OFString *)nameSpace;
226
233- (void)bindPrefix: (OFString *)prefix forNamespace: (OFString *)nameSpace;
234
243- (void)addAttribute: (OFXMLAttribute *)attribute;
244
254- (void)addAttributeWithName: (OFString *)name
255 stringValue: (OFString *)stringValue;
256
268- (void)addAttributeWithName: (OFString *)name
269 namespace: (nullable OFString *)nameSpace
270 stringValue: (OFString *)stringValue;
271
278- (nullable OFXMLAttribute *)attributeForName: (OFString *)attributeName;
279
287- (nullable OFXMLAttribute *)attributeForName: (OFString *)attributeName
288 namespace: (nullable OFString *)attributeNS;
289
295- (void)removeAttributeForName: (OFString *)attributeName;
296
303- (void)removeAttributeForName: (OFString *)attributeName
304 namespace: (nullable OFString *)attributeNS;
305
311- (void)addChild: (OFXMLNode *)child;
312
319- (void)insertChild: (OFXMLNode *)child atIndex: (size_t)index;
320
327- (void)insertChildren: (OFArray OF_GENERIC(OFXMLNode *) *)children
328 atIndex: (size_t)index;
329
335- (void)removeChild: (OFXMLNode *)child;
336
342- (void)removeChildAtIndex: (size_t)index;
343
351- (void)replaceChild: (OFXMLNode *)child withNode: (OFXMLNode *)node;
352
359- (void)replaceChildAtIndex: (size_t)index withNode: (OFXMLNode *)node;
360
366- (OFArray OF_GENERIC(OFXMLElement *) *)
367 elementsForNamespace: (nullable OFString *)elementNS;
368
375- (nullable OFXMLElement *)elementForName: (OFString *)elementName;
376
383- (OFArray OF_GENERIC(OFXMLElement *) *)
384 elementsForName: (OFString *)elementName;
385
393- (nullable OFXMLElement *)elementForName: (OFString *)elementName
394 namespace: (nullable OFString *)elementNS;
395
403- (OFArray OF_GENERIC(OFXMLElement *) *)
404 elementsForName: (OFString *)elementName
405 namespace: (nullable OFString *)elementNS;
406
418- (OFString *)XMLStringWithIndentation: (unsigned int)indentation;
419
432- (OFString *)XMLStringWithDefaultNamespace: (OFString *)defaultNS
433 indentation: (unsigned int)indentation;
434@end
435
436OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition OFArray.h:105
An abstract class for storing, adding and removing objects in an array.
Definition OFMutableArray.h:44
An abstract class for storing and changing objects in a dictionary.
Definition OFMutableDictionary.h:44
A class for storing and modifying strings.
Definition OFMutableString.h:26
A base class for different types of streams.
Definition OFStream.h:188
A class for handling strings.
Definition OFString.h:135
A representation of an attribute of an XML element as an object.
Definition OFXMLAttribute.h:29
A class which stores an XML element.
Definition OFXMLElement.h:34
A class which stores an XML element.
Definition OFXMLNode.h:27