ObjFW
src/OFXMLParser.h
00001 /*
00002  * Copyright (c) 2008, 2009, 2010, 2011, 2012
00003  *   Jonathan Schleifer <js@webkeks.org>
00004  *
00005  * All rights reserved.
00006  *
00007  * This file is part of ObjFW. It may be distributed under the terms of the
00008  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
00009  * the packaging of this file.
00010  *
00011  * Alternatively, it may be distributed under the terms of the GNU General
00012  * Public License, either version 2 or 3, which can be found in the file
00013  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
00014  * file.
00015  */
00016 
00017 #import "OFObject.h"
00018 #import "OFString.h"
00019 #import "OFXMLAttribute.h"
00020 
00021 @class OFXMLParser;
00022 @class OFArray;
00023 @class OFMutableArray;
00024 @class OFDataArray;
00025 @class OFStream;
00026 
00030 #ifndef OF_XML_PARSER_M
00031 @protocol OFXMLParserDelegate <OFObject>
00032 #else
00033 @protocol OFXMLParserDelegate
00034 #endif
00035 #ifdef OF_HAVE_OPTIONAL_PROTOCOLS
00036 @optional
00037 #endif
00038 
00045 -                (void)parser: (OFXMLParser*)parser
00046   foundProcessingInstructions: (OFString*)pi;
00047 
00059 -    (void)parser: (OFXMLParser*)parser
00060   didStartElement: (OFString*)name
00061        withPrefix: (OFString*)prefix
00062         namespace: (OFString*)ns
00063        attributes: (OFArray*)attributes;
00064 
00073 -  (void)parser: (OFXMLParser*)parser
00074   didEndElement: (OFString*)name
00075      withPrefix: (OFString*)prefix
00076       namespace: (OFString*)ns;
00077 
00087 -    (void)parser: (OFXMLParser*)parser
00088   foundCharacters: (OFString*)characters;
00089 
00096 - (void)parser: (OFXMLParser*)parser
00097     foundCDATA: (OFString*)CDATA;
00098 
00105 - (void)parser: (OFXMLParser*)parser
00106   foundComment: (OFString*)comment;
00107 
00120 -       (OFString*)parser: (OFXMLParser*)parser
00121   foundUnknownEntityNamed: (OFString*)entity;
00122 @end
00123 
00130 @interface OFXMLParser: OFObject <OFStringXMLUnescapingDelegate>
00131 {
00132         id <OFXMLParserDelegate> delegate;
00133         enum {
00134                 OF_XMLPARSER_OUTSIDE_TAG,
00135                 OF_XMLPARSER_TAG_OPENED,
00136                 OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS,
00137                 OF_XMLPARSER_IN_TAG_NAME,
00138                 OF_XMLPARSER_IN_CLOSE_TAG_NAME,
00139                 OF_XMLPARSER_IN_TAG,
00140                 OF_XMLPARSER_IN_ATTR_NAME,
00141                 OF_XMLPARSER_EXPECT_DELIM,
00142                 OF_XMLPARSER_IN_ATTR_VALUE,
00143                 OF_XMLPARSER_EXPECT_CLOSE,
00144                 OF_XMLPARSER_EXPECT_SPACE_OR_CLOSE,
00145                 OF_XMLPARSER_IN_EXCLAMATIONMARK,
00146                 OF_XMLPARSER_IN_CDATA_OPENING,
00147                 OF_XMLPARSER_IN_CDATA_1,
00148                 OF_XMLPARSER_IN_CDATA_2,
00149                 OF_XMLPARSER_IN_COMMENT_OPENING,
00150                 OF_XMLPARSER_IN_COMMENT_1,
00151                 OF_XMLPARSER_IN_COMMENT_2,
00152                 OF_XMLPARSER_IN_DOCTYPE,
00153                 OF_XMLPARSER_NUM_STATES
00154         } state;
00155         OFDataArray *cache;
00156         OFString *name;
00157         OFString *prefix;
00158         OFMutableArray *namespaces;
00159         OFMutableArray *attributes;
00160         OFString *attributeName;
00161         OFString *attributePrefix;
00162         char delimiter;
00163         OFMutableArray *previous;
00164         size_t level;
00165         BOOL acceptProlog;
00166         size_t lineNumber;
00167         BOOL lastCarriageReturn;
00168         BOOL finishedParsing;
00169         of_string_encoding_t encoding;
00170 }
00171 
00172 #ifdef OF_HAVE_PROPERTIES
00173 @property (assign) id <OFXMLParserDelegate> delegate;
00174 #endif
00175 
00181 + parser;
00182 
00188 - (id <OFXMLParserDelegate>)delegate;
00189 
00195 - (void)setDelegate: (id <OFXMLParserDelegate>)delegate;
00196 
00203 - (void)parseBuffer: (const char*)buffer
00204          withLength: (size_t)length;
00205 
00211 - (void)parseString: (OFString*)string;
00212 
00218 - (void)parseStream: (OFStream*)stream;
00219 
00225 - (void)parseFile: (OFString*)path;
00226 
00232 - (size_t)lineNumber;
00233 
00239 - (BOOL)finishedParsing;
00240 @end
00241 
00242 @interface OFObject (OFXMLParserDelegate) <OFXMLParserDelegate>
00243 @end
 All Classes Functions Variables Properties