ObjFW
OFXMLParser.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 "OFObject.h"
17 #import "OFString.h"
18 #import "OFXMLAttribute.h"
19 
20 OF_ASSUME_NONNULL_BEGIN
21 
22 @class OFArray OF_GENERIC(ObjectType);
23 @class OFMutableData;
24 @class OFMutableArray OF_GENERIC(ObjectType);
25 @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
26 @class OFStream;
27 @class OFXMLParser;
28 
35 @optional
44 - (void)parser: (OFXMLParser *)parser
45  foundProcessingInstructionWithTarget: (OFString *)target
46  text: (nullable OFString *)text;
47 
59 - (void)parser: (OFXMLParser *)parser
60  didStartElement: (OFString *)name
61  prefix: (nullable OFString *)prefix
62  namespace: (nullable OFString *)nameSpace
63  attributes: (nullable OFArray OF_GENERIC(OFXMLAttribute *) *)attributes;
64 
73 - (void)parser: (OFXMLParser *)parser
74  didEndElement: (OFString *)name
75  prefix: (nullable OFString *)prefix
76  namespace: (nullable OFString *)nameSpace;
77 
87 - (void)parser: (OFXMLParser *)parser foundCharacters: (OFString *)characters;
88 
95 - (void)parser: (OFXMLParser *)parser foundCDATA: (OFString *)CDATA;
96 
103 - (void)parser: (OFXMLParser *)parser foundComment: (OFString *)comment;
104 
117 - (nullable OFString *)parser: (OFXMLParser *)parser
118  foundUnknownEntityNamed: (OFString *)entity;
119 @end
120 
129 OF_SUBCLASSING_RESTRICTED
131 {
132  id <OFXMLParserDelegate> _Nullable _delegate;
133  uint_least8_t _state;
134  size_t _i, _last;
135  const char *_Nullable _data;
136  OFMutableData *_buffer;
137  OFString *_Nullable _name, *_Nullable _prefix;
139  OF_GENERIC(OFMutableDictionary OF_GENERIC(OFString *, OFString *) *)
140  *_namespaces;
141  OFMutableArray OF_GENERIC(OFXMLAttribute *) *_attributes;
142  OFString *_Nullable _attributeName, *_Nullable _attributePrefix;
143  char _delimiter;
144  OFMutableArray OF_GENERIC(OFString *) *_previous;
145  size_t _level;
146  bool _acceptProlog;
147  size_t _lineNumber;
148  bool _lastCarriageReturn, _finishedParsing;
149  OFStringEncoding _encoding;
150  size_t _depthLimit;
151 }
152 
156 @property OF_NULLABLE_PROPERTY (assign, nonatomic)
157  id <OFXMLParserDelegate> delegate;
158 
162 @property (readonly, nonatomic) size_t lineNumber;
163 
167 @property (readonly, nonatomic, getter=hasFinishedParsing) bool finishedParsing;
168 
176 @property (nonatomic) size_t depthLimit;
177 
183 + (instancetype)parser;
184 
195 - (void)parseBuffer: (const char *)buffer length: (size_t)length;
196 
206 - (void)parseString: (OFString *)string;
207 
217 - (void)parseStream: (OFStream *)stream;
218 @end
219 
220 OF_ASSUME_NONNULL_END
OFStringEncoding
The encoding of a string.
Definition: OFString.h:61
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
A class for storing and manipulating arbitrary data in an array.
Definition: OFMutableData.h:26
An abstract class for storing and changing objects in a dictionary.
Definition: OFMutableDictionary.h:44
The root class for all other classes inside ObjFW.
Definition: OFObject.h:688
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
An event-based XML parser.
Definition: OFXMLParser.h:131
A protocol that needs to be implemented by delegates for OFXMLParser.
Definition: OFXMLParser.h:34