GNUstep CoreBase Library 0.2
CFXMLParser.h
1/* CFXMLParser.h
2
3 Copyright (C) 2010 Free Software Foundation, Inc.
4
5 Written by: Stefan Bidigaray
6 Date: December, 2011
7
8 This file is part of the GNUstep CoreBase Library.
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; see the file COPYING.LIB.
22 If not, see <http://www.gnu.org/licenses/> or write to the
23 Free Software Foundation, 51 Franklin Street, Fifth Floor,
24 Boston, MA 02110-1301, USA.
25*/
26
27#ifndef __CFCOREFOUNDATION_CFXMLPARSER_H__
28#define __CFCOREFOUNDATION_CFXMLPARSER_H__
29
30#include <CoreFoundation/CFBase.h>
31#include <CoreFoundation/CFData.h>
32#include <CoreFoundation/CFDictionary.h>
33#include <CoreFoundation/CFTree.h>
34#include <CoreFoundation/CFURL.h>
35#include <CoreFoundation/CFXMLNode.h>
36
37CF_EXTERN_C_BEGIN
41typedef struct __CFXMLParser *CFXMLParserRef;
42
43typedef enum
44{
45 kCFXMLStatusParseNotBegun = -2,
46 kCFXMLStatusParseInProgress = -1,
47 kCFXMLStatusParseSuccessful = 0,
48 kCFXMLErrorUnexpectedEOF = 1,
49 kCFXMLErrorUnknownEncoding = 2,
50 kCFXMLErrorEncodingConversionFailure = 3,
51 kCFXMLErrorMalformedProcessingInstruction = 4,
52 kCFXMLErrorMalformedDTD = 5,
53 kCFXMLErrorMalformedName = 6,
54 kCFXMLErrorMalformedCDSect = 7,
55 kCFXMLErrorMalformedCloseTag = 8,
56 kCFXMLErrorMalformedStartTag = 9,
57 kCFXMLErrorMalformedDocument = 10,
58 kCFXMLErrorElementlessDocument = 11,
59 kCFXMLErrorMalformedComment = 12,
60 kCFXMLErrorMalformedCharacterReference = 13,
61 kCFXMLErrorMalformedParsedCharacterData = 14,
62 kCFXMLErrorNoData = 15
63} CFXMLParserStatusCode;
64
65typedef enum
66{
67 kCFXMLParserValidateDocument = (1 << 0),
68 kCFXMLParserSkipMetaData = (1 << 1),
69 kCFXMLParserReplacePhysicalEntities = (1 << 2),
70 kCFXMLParserSkipWhitespace = (1 << 3),
71 kCFXMLParserResolveExternalEntities = (1 << 4),
72 kCFXMLParserAddImpliedAttributes = (1 << 5),
73 kCFXMLParserAllOptions = 0x00FFFFFF,
74 kCFXMLParserNoOptions = 0
75} CFXMLParserOptions;
76
77typedef void *(*CFXMLParserCreateXMLStructureCallBack) (CFXMLParserRef parser,
78 CFXMLNodeRef nodeDesc,
79 void *info);
80typedef void (*CFXMLParserAddChildCallBack) (CFXMLParserRef parser,
81 void *parent, void *child,
82 void *info);
83typedef void (*CFXMLParserEndXMLStructureCallBack) (CFXMLParserRef parser,
84 void *xmlType, void *info);
85typedef
86CFDataRef (*CFXMLParserResolveExternalEntityCallBack)
87 (CFXMLParserRef parser, CFXMLExternalID * extID, void *info);
88 typedef Boolean (*CFXMLParserHandleErrorCallBack) (CFXMLParserRef parser,
89 CFXMLParserStatusCode
90 error, void *info);
91
92 typedef CFStringRef (*CFXMLParserCopyDescriptionCallBack) (const void
93 *info);
94 typedef void (*CFXMLParserReleaseCallBack) (const void *info);
95 typedef const void *(*CFXMLParserRetainCallBack) (const void *info);
96
99 {
100 CFIndex version;
101 CFXMLParserCreateXMLStructureCallBack createXMLStructure;
102 CFXMLParserAddChildCallBack addChild;
103 CFXMLParserEndXMLStructureCallBack endXMLStructure;
104 CFXMLParserResolveExternalEntityCallBack resolveExternalEntity;
105 CFXMLParserHandleErrorCallBack handleError;
106 };
107
110 {
111 CFIndex version;
112 void *info;
113 CFXMLParserRetainCallBack retain;
114 CFXMLParserReleaseCallBack release;
115 CFXMLParserCopyDescriptionCallBack copyDescription;
116 };
117
118 CF_EXPORT CFTypeID CFXMLParserGetTypeID (void);
119
120 CF_EXPORT void
121 CFXMLParserAbort (CFXMLParserRef parser, CFXMLParserStatusCode errorCode,
122 CFStringRef errorDescription);
123
124 CF_EXPORT CFStringRef
125 CFXMLParserCopyErrorDescription (CFXMLParserRef parser);
126
127 CF_EXPORT CFXMLParserRef
128 CFXMLParserCreate (CFAllocatorRef allocator, CFDataRef xmlData,
129 CFURLRef dataSource, CFOptionFlags parseOptions,
130 CFIndex versionOfNodes,
131 CFXMLParserCallBacks * callBacks,
132 CFXMLParserContext * context);
133
134 CF_EXPORT CFXMLParserRef
135 CFXMLParserCreateWithDataFromURL (CFAllocatorRef allocator,
136 CFURLRef dataSource,
137 CFOptionFlags parseOptions,
138 CFIndex versionOfNodes,
139 CFXMLParserCallBacks * callBacks,
140 CFXMLParserContext * context);
141
142 CF_EXPORT void
143 CFXMLParserGetCallBacks (CFXMLParserRef parser,
144 CFXMLParserCallBacks * callBacks);
145
146 CF_EXPORT void
147 CFXMLParserGetContext (CFXMLParserRef parser,
148 CFXMLParserContext * context);
149
150 CF_EXPORT void *CFXMLParserGetDocument (CFXMLParserRef parser);
151
152 CF_EXPORT CFIndex CFXMLParserGetLineNumber (CFXMLParserRef parser);
153
154 CF_EXPORT CFIndex CFXMLParserGetLocation (CFXMLParserRef parser);
155
156 CF_EXPORT CFURLRef CFXMLParserGetSourceURL (CFXMLParserRef parser);
157
158 CF_EXPORT CFXMLParserStatusCode
159 CFXMLParserGetStatusCode (CFXMLParserRef parser);
160
161 CF_EXPORT Boolean CFXMLParserParse (CFXMLParserRef parser);
167 CF_EXPORT CFXMLTreeRef
168 CFXMLTreeCreateFromData (CFAllocatorRef allocator, CFDataRef xmlData,
169 CFURLRef dataSource, CFOptionFlags parseOptions,
170 CFIndex versionOfNodes);
171
172 CF_EXPORT CFXMLTreeRef
173 CFXMLTreeCreateWithDataFromURL (CFAllocatorRef allocator,
174 CFURLRef dataSource,
175 CFOptionFlags parseOptions,
176 CFIndex versionOfNodes);
177
178 CF_EXPORT CFDataRef
179 CFXMLTreeCreateXMLData (CFAllocatorRef allocator, CFXMLTreeRef xmlTree);
180
181#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
182 CF_EXPORT const CFStringRef kCFXMLTreeErrorDescription;
183 CF_EXPORT const CFStringRef kCFXMLTreeErrorLineNumber;
184 CF_EXPORT const CFStringRef kCFXMLTreeErrorLocation;
185 CF_EXPORT const CFStringRef kCFXMLTreeErrorStatusCode;
186
187 CF_EXPORT CFStringRef
188 CFXMLCreateStringByEscapingEntities (CFAllocatorRef allocator,
189 CFStringRef string,
190 CFDictionaryRef entitiesDictionary);
191
192 CF_EXPORT CFStringRef
193 CFXMLCreateStringByUnescapingEntities (CFAllocatorRef allocator,
194 CFStringRef string,
195 CFDictionaryRef
196 entitiesDictionary);
197
198 CF_EXPORT CFXMLTreeRef
199 CFXMLTreeCreateFromDataWithError (CFAllocatorRef allocator,
200 CFDataRef xmlData, CFURLRef dataSource,
201 CFOptionFlags parseOptions,
202 CFIndex versionOfNodes,
203 CFDictionaryRef * errorDict);
204#endif /* MAC_OS_X_VERSION_10_3 */
207CF_EXTERN_C_END
208#endif /* __CFCOREFOUNDATION_CFXMLPARSER_H__ */
unsigned long CFOptionFlags
Definition CFBase.h:163
signed long CFIndex
Definition CFBase.h:165
const struct __CFAllocator * CFAllocatorRef
A reference to a CFAllocator object.
Definition CFBase.h:301
Definition CFXMLNode.h:77
Definition CFXMLParser.h:99
Definition CFXMLParser.h:110