ObjFW  Diff

Differences From Artifact [a3fee8ab7a]:

To Artifact [2b459f4eb7]:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#import "OFObject.h"
#import "OFXMLParser.h"

@class OFMutableArray;
@class OFXMLElement;
@class OFXMLElementBuilder;

/**
 * \brief A protocol that needs to be implemented by delegates for
 * OFXMLElementBuilder.
 */
#ifndef OF_XML_ELEMENT_BUILDER_M
@protocol OFXMLElementBuilderDelegate <OFObject>
#else
@protocol OFXMLElementBuilderDelegate
#endif
/**
 * \brief This callback is called when the OFXMLElementBuilder built an element.
 *
 * If the OFXMLElementBuilder was used as a delegate for the OFXMLParser since
 * parsing started, this will return the complete document as an OFXMLElement
 * with all children.
 *
 * \param builder The builder which built an OFXMLElement
 * \param elem The OFXMLElement the OFXMLElementBuilder built
 */
- (void)elementBuilder: (OFXMLElementBuilder*)builder
       didBuildElement: (OFXMLElement*)element;

#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif

/**
 * \brief This callback is called when the OFXMLElementBuilder built an
 *	  OFXMLNode which is not inside an element.
 *
 * This is usually called for comments or whitespace character data before the
 * root element.
 *
 * \param builder The builder which built the OFXMLNode without parent
 * \param node The OFXMLNode the OFXMLElementBuilder built
 */
-   (void)elementBuilder: (OFXMLElementBuilder*)builder
  didBuildParentlessNode: (OFXMLNode*)node;

/**
 * \brief This callback is called when the OFXMLElementBuilder gets a close tag
 *	  which does not belong there.
 *
 * Most likely, the OFXMLElementBuilder was used to build XML only of a child
 * of the root element and the root element was closed. Often the delegate is
 * set to the OFXMLElementBuilder when a certain element is found, this can be
 * used then to set the delegate back after that certain element has been
 * closed.
 *
 * If this method is not implemented in the delegate, the default is to throw
 * an OFMalformedXMLException.
 *
 * \param builder The builder which did not expect the close tag
 * \param name The name of the close tag
 * \param prefix The prefix of the close tag
 * \param ns The namespace of the close tag
 */
- (void)elementBuilder: (OFXMLElementBuilder*)builder
  didNotExpectCloseTag: (OFString*)name
	    withPrefix: (OFString*)prefix
	     namespace: (OFString*)ns;

/**
 * \brief This callback is called when the XML parser for the element builder
 *	  found an unknown entity.
 *
 * \param entity The name of the entity
 * \return The substitution for the entity
 */
- (OFString*)elementBuilder: (OFXMLElementBuilder*)builder
    foundUnknownEntityNamed: (OFString*)entity;
@end

/**
 * \brief A class implementing the OFXMLParserDelegate protocol that can build
 * OFXMLElements from the document parsed by the OFXMLParser.
 *
 * It can also be used to build OFXMLElements from parts of the document by
 * first parsing stuff using the OFXMLParser with another delegate and then
 * setting the OFXMLElementBuilder as delegate for the parser.
 */
@interface OFXMLElementBuilder: OFObject <OFXMLParserDelegate>
{
	OFMutableArray *stack;
	id <OFXMLElementBuilderDelegate> delegate;
}

#ifdef OF_HAVE_PROPERTIES
@property (assign) id <OFXMLElementBuilderDelegate> delegate;
#endif

/**
 * \brief Creates a new element builder.
 *
 * \return A new, autoreleased OFXMLElementBuilder
 */
+ (instancetype)elementBuilder;

/**
 * \brief Returns the delegate for the OFXMLElementBuilder.
 *
 * \return The delegate for the OFXMLElementBuilder
 */
- (id <OFXMLElementBuilderDelegate>)delegate;

/**
 * \brief Sets the delegate for the OFXMLElementBuilder.
 *
 * \param delegate The delegate for the OFXMLElementBuilder
 */
- (void)setDelegate: (id <OFXMLElementBuilderDelegate>)delegate;
@end

@interface OFObject (OFXMLElementBuilderDelegate) <OFXMLElementBuilderDelegate>
@end







|
|







|
|





|
|








|
|





|
|




|
|











|
|
|
|






|
|


|
|





|
|
















|
|

|



|
|

|



|
|

|






17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#import "OFObject.h"
#import "OFXMLParser.h"

@class OFMutableArray;
@class OFXMLElement;
@class OFXMLElementBuilder;

/*!
 * @brief A protocol that needs to be implemented by delegates for
 * OFXMLElementBuilder.
 */
#ifndef OF_XML_ELEMENT_BUILDER_M
@protocol OFXMLElementBuilderDelegate <OFObject>
#else
@protocol OFXMLElementBuilderDelegate
#endif
/*!
 * @brief This callback is called when the OFXMLElementBuilder built an element.
 *
 * If the OFXMLElementBuilder was used as a delegate for the OFXMLParser since
 * parsing started, this will return the complete document as an OFXMLElement
 * with all children.
 *
 * @param builder The builder which built an OFXMLElement
 * @param elem The OFXMLElement the OFXMLElementBuilder built
 */
- (void)elementBuilder: (OFXMLElementBuilder*)builder
       didBuildElement: (OFXMLElement*)element;

#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif

/*!
 * @brief This callback is called when the OFXMLElementBuilder built an
 *	  OFXMLNode which is not inside an element.
 *
 * This is usually called for comments or whitespace character data before the
 * root element.
 *
 * @param builder The builder which built the OFXMLNode without parent
 * @param node The OFXMLNode the OFXMLElementBuilder built
 */
-   (void)elementBuilder: (OFXMLElementBuilder*)builder
  didBuildParentlessNode: (OFXMLNode*)node;

/*!
 * @brief This callback is called when the OFXMLElementBuilder gets a close tag
 *	  which does not belong there.
 *
 * Most likely, the OFXMLElementBuilder was used to build XML only of a child
 * of the root element and the root element was closed. Often the delegate is
 * set to the OFXMLElementBuilder when a certain element is found, this can be
 * used then to set the delegate back after that certain element has been
 * closed.
 *
 * If this method is not implemented in the delegate, the default is to throw
 * an OFMalformedXMLException.
 *
 * @param builder The builder which did not expect the close tag
 * @param name The name of the close tag
 * @param prefix The prefix of the close tag
 * @param ns The namespace of the close tag
 */
- (void)elementBuilder: (OFXMLElementBuilder*)builder
  didNotExpectCloseTag: (OFString*)name
	    withPrefix: (OFString*)prefix
	     namespace: (OFString*)ns;

/*!
 * @brief This callback is called when the XML parser for the element builder
 *	  found an unknown entity.
 *
 * @param entity The name of the entity
 * @return The substitution for the entity
 */
- (OFString*)elementBuilder: (OFXMLElementBuilder*)builder
    foundUnknownEntityNamed: (OFString*)entity;
@end

/*!
 * @brief A class implementing the OFXMLParserDelegate protocol that can build
 * OFXMLElements from the document parsed by the OFXMLParser.
 *
 * It can also be used to build OFXMLElements from parts of the document by
 * first parsing stuff using the OFXMLParser with another delegate and then
 * setting the OFXMLElementBuilder as delegate for the parser.
 */
@interface OFXMLElementBuilder: OFObject <OFXMLParserDelegate>
{
	OFMutableArray *stack;
	id <OFXMLElementBuilderDelegate> delegate;
}

#ifdef OF_HAVE_PROPERTIES
@property (assign) id <OFXMLElementBuilderDelegate> delegate;
#endif

/*!
 * @brief Creates a new element builder.
 *
 * @return A new, autoreleased OFXMLElementBuilder
 */
+ (instancetype)elementBuilder;

/*!
 * @brief Returns the delegate for the OFXMLElementBuilder.
 *
 * @return The delegate for the OFXMLElementBuilder
 */
- (id <OFXMLElementBuilderDelegate>)delegate;

/*!
 * @brief Sets the delegate for the OFXMLElementBuilder.
 *
 * @param delegate The delegate for the OFXMLElementBuilder
 */
- (void)setDelegate: (id <OFXMLElementBuilderDelegate>)delegate;
@end

@interface OFObject (OFXMLElementBuilderDelegate) <OFXMLElementBuilderDelegate>
@end