Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/0.2.X/KissXML/Private/DDXMLPrivate.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 274 - (show annotations) (download) (as text)
Fri May 6 10:07:02 2011 UTC (13 years ago) by poi-poi-capsule
File MIME type: text/x-chdr
File size: 6841 byte(s)
kissxmlアップデート
1 #import "DDXML.h"
2
3
4 // We can't rely solely on NSAssert, because many developers disable them for release builds.
5 // Our API contract requires us to keep these assertions intact.
6 #define DDXMLAssert(condition, desc, ...) \
7 do{ \
8 if(!(condition)) \
9 { \
10 [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd \
11 object:self \
12 file:[NSString stringWithUTF8String:__FILE__] \
13 lineNumber:__LINE__ \
14 description:(desc), ##__VA_ARGS__]; \
15 } \
16 }while(NO)
17
18 #define DDLastErrorKey @"DDXML:LastError"
19
20 /**
21 * DDXMLNode can represent several underlying types, such as xmlNodePtr, xmlDocPtr, xmlAttrPtr, xmlNsPtr, etc.
22 * All of these are pointers to structures, and all of those structures start with a pointer, and a type.
23 * The xmlKind struct is used as a generic structure, and a stepping stone.
24 * We use it to check the type of a structure, and then perform the appropriate cast.
25 *
26 * For example:
27 * if(genericPtr->type == XML_ATTRIBUTE_NODE)
28 * {
29 * xmlAttrPtr attr = (xmlAttrPtr)genericPtr;
30 * // Do something with attr
31 * }
32 **/
33 struct _xmlKind {
34 void * ignore;
35 xmlElementType type;
36 };
37 typedef struct _xmlKind *xmlKindPtr;
38
39 /**
40 * Most xml types all start with this standard structure. In fact, all do except the xmlNsPtr.
41 * We will occasionally take advantage of this to simplify code when the code wouldn't vary from type to type.
42 * Obviously, you cannnot cast a xmlNsPtr to a xmlStdPtr.
43 **/
44 struct _xmlStd {
45 void * _private;
46 xmlElementType type;
47 const xmlChar *name;
48 struct _xmlNode *children;
49 struct _xmlNode *last;
50 struct _xmlNode *parent;
51 struct _xmlStd *next;
52 struct _xmlStd *prev;
53 struct _xmlDoc *doc;
54 };
55 typedef struct _xmlStd *xmlStdPtr;
56
57
58 NS_INLINE BOOL IsXmlAttrPtr(void *kindPtr)
59 {
60 return ((xmlKindPtr)kindPtr)->type == XML_ATTRIBUTE_NODE;
61 }
62
63 NS_INLINE BOOL IsXmlNodePtr(void *kindPtr)
64 {
65 switch (((xmlKindPtr)kindPtr)->type)
66 {
67 case XML_ELEMENT_NODE :
68 case XML_PI_NODE :
69 case XML_COMMENT_NODE :
70 case XML_TEXT_NODE :
71 case XML_CDATA_SECTION_NODE : return YES;
72 default : return NO;
73 }
74 }
75
76 NS_INLINE BOOL IsXmlDocPtr(void *kindPtr)
77 {
78 return ((xmlKindPtr)kindPtr)->type == XML_DOCUMENT_NODE;
79 }
80
81 NS_INLINE BOOL IsXmlDtdPtr(void *kindPtr)
82 {
83 return ((xmlKindPtr)kindPtr)->type == XML_DTD_NODE;
84 }
85
86 NS_INLINE BOOL IsXmlNsPtr(void *kindPtr)
87 {
88 return ((xmlKindPtr)kindPtr)->type == XML_NAMESPACE_DECL;
89 }
90
91 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
92 #pragma mark -
93 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
94
95 @interface DDXMLNamespaceNode : DDXMLNode
96 {
97 // The xmlNsPtr type doesn't store a reference to it's parent.
98 // This is here to fix the problem, and make this class more compatible with the NSXML classes.
99 xmlNodePtr nsParentPtr;
100 }
101
102 + (id)nodeWithNsPrimitive:(xmlNsPtr)ns nsParent:(xmlNodePtr)parent freeOnDealloc:(BOOL)flag;
103 - (id)initWithNsPrimitive:(xmlNsPtr)ns nsParent:(xmlNodePtr)parent freeOnDealloc:(BOOL)flag;
104
105 - (xmlNodePtr)nsParentPtr;
106 - (void)setNsParentPtr:(xmlNodePtr)parentPtr;
107
108 // Overrides several methods in DDXMLNode
109
110 @end
111
112 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
113 #pragma mark -
114 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115
116 @interface DDXMLAttributeNode : DDXMLNode
117
118 + (id)nodeWithAttrPrimitive:(xmlAttrPtr)attr freeOnDealloc:(BOOL)flag;
119 - (id)initWithAttrPrimitive:(xmlAttrPtr)attr freeOnDealloc:(BOOL)flag;
120
121 // Overrides several methods in DDXMLNode
122
123 @end
124
125 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
126 #pragma mark -
127 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
128
129 @interface DDXMLNode (PrivateAPI)
130
131 + (id)nodeWithUnknownPrimitive:(xmlKindPtr)kindPtr freeOnDealloc:(BOOL)flag;
132
133 + (id)nodeWithPrimitive:(xmlKindPtr)kindPtr freeOnDealloc:(BOOL)flag;
134 - (id)initWithPrimitive:(xmlKindPtr)kindPtr freeOnDealloc:(BOOL)flag;
135
136 - (BOOL)hasParent;
137
138 + (void)recursiveStripDocPointersFromNode:(xmlNodePtr)node;
139
140 + (void)detachAttribute:(xmlAttrPtr)attr fromNode:(xmlNodePtr)node;
141 + (void)removeAttribute:(xmlAttrPtr)attr fromNode:(xmlNodePtr)node;
142 + (void)removeAllAttributesFromNode:(xmlNodePtr)node;
143
144 + (void)detachNamespace:(xmlNsPtr)ns fromNode:(xmlNodePtr)node;
145 + (void)removeNamespace:(xmlNsPtr)ns fromNode:(xmlNodePtr)node;
146 + (void)removeAllNamespacesFromNode:(xmlNodePtr)node;
147
148 + (void)detachChild:(xmlNodePtr)child fromNode:(xmlNodePtr)node;
149 + (void)removeChild:(xmlNodePtr)child fromNode:(xmlNodePtr)node;
150 + (void)removeAllChildrenFromNode:(xmlNodePtr)node;
151
152 - (void)nodeFree;
153
154 + (NSError *)lastError;
155
156 @end
157
158 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
159 #pragma mark -
160 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
161
162 @interface DDXMLElement (PrivateAPI)
163
164 + (id)nodeWithElementPrimitive:(xmlNodePtr)node freeOnDealloc:(BOOL)flag;
165 - (id)initWithElementPrimitive:(xmlNodePtr)node freeOnDealloc:(BOOL)flag;
166
167 - (NSArray *)elementsForName:(NSString *)name uri:(NSString *)URI;
168
169 + (DDXMLNode *)resolveNamespaceForPrefix:(NSString *)prefix atNode:(xmlNodePtr)nodePtr;
170 + (NSString *)resolvePrefixForURI:(NSString *)uri atNode:(xmlNodePtr)nodePtr;
171
172 @end
173
174 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
175 #pragma mark -
176 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
177
178 @interface DDXMLDocument (PrivateAPI)
179
180 + (id)nodeWithDocPrimitive:(xmlDocPtr)doc freeOnDealloc:(BOOL)flag;
181 - (id)initWithDocPrimitive:(xmlDocPtr)doc freeOnDealloc:(BOOL)flag;
182
183 @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26