CFXMLNode.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. { CFXMLNode.h
  2. Copyright (c) 1998-2005, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, November 2005 }
  5. {
  6. Modified for use with Free Pascal
  7. Version 200
  8. Please report any bugs to <[email protected]>
  9. }
  10. {$mode macpas}
  11. {$packenum 1}
  12. {$macro on}
  13. {$inline on}
  14. {$CALLING MWPASCAL}
  15. unit CFXMLNode;
  16. interface
  17. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  18. {$setc GAP_INTERFACES_VERSION := $0200}
  19. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  20. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  21. {$endc}
  22. {$ifc defined CPUPOWERPC and defined CPUI386}
  23. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  24. {$endc}
  25. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  26. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  27. {$endc}
  28. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  29. {$setc __ppc__ := 1}
  30. {$elsec}
  31. {$setc __ppc__ := 0}
  32. {$endc}
  33. {$ifc not defined __i386__ and defined CPUI386}
  34. {$setc __i386__ := 1}
  35. {$elsec}
  36. {$setc __i386__ := 0}
  37. {$endc}
  38. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  39. {$error Conflicting definitions for __ppc__ and __i386__}
  40. {$endc}
  41. {$ifc defined __ppc__ and __ppc__}
  42. {$setc TARGET_CPU_PPC := TRUE}
  43. {$setc TARGET_CPU_X86 := FALSE}
  44. {$elifc defined __i386__ and __i386__}
  45. {$setc TARGET_CPU_PPC := FALSE}
  46. {$setc TARGET_CPU_X86 := TRUE}
  47. {$elsec}
  48. {$error Neither __ppc__ nor __i386__ is defined.}
  49. {$endc}
  50. {$setc TARGET_CPU_PPC_64 := FALSE}
  51. {$ifc defined FPC_BIG_ENDIAN}
  52. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  53. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  54. {$elifc defined FPC_LITTLE_ENDIAN}
  55. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  56. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  57. {$elsec}
  58. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  59. {$endc}
  60. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  61. {$setc CALL_NOT_IN_CARBON := FALSE}
  62. {$setc OLDROUTINENAMES := FALSE}
  63. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  64. {$setc OPAQUE_UPP_TYPES := TRUE}
  65. {$setc OTCARBONAPPLICATION := TRUE}
  66. {$setc OTKERNEL := FALSE}
  67. {$setc PM_USE_SESSION_APIS := TRUE}
  68. {$setc TARGET_API_MAC_CARBON := TRUE}
  69. {$setc TARGET_API_MAC_OS8 := FALSE}
  70. {$setc TARGET_API_MAC_OSX := TRUE}
  71. {$setc TARGET_CARBON := TRUE}
  72. {$setc TARGET_CPU_68K := FALSE}
  73. {$setc TARGET_CPU_MIPS := FALSE}
  74. {$setc TARGET_CPU_SPARC := FALSE}
  75. {$setc TARGET_OS_MAC := TRUE}
  76. {$setc TARGET_OS_UNIX := FALSE}
  77. {$setc TARGET_OS_WIN32 := FALSE}
  78. {$setc TARGET_RT_MAC_68881 := FALSE}
  79. {$setc TARGET_RT_MAC_CFM := FALSE}
  80. {$setc TARGET_RT_MAC_MACHO := TRUE}
  81. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  82. {$setc TYPE_BOOL := FALSE}
  83. {$setc TYPE_EXTENDED := FALSE}
  84. {$setc TYPE_LONGLONG := TRUE}
  85. uses MacTypes,CFBase,CFArray,CFDictionary,CFString,CFTree,CFURL;
  86. {$ALIGN POWER}
  87. const
  88. kCFXMLNodeCurrentVersion = 1;
  89. type
  90. CFXMLNodeRef = ^SInt32; { an opaque 32-bit type }
  91. CFXMLNodeRefPtr = ^CFXMLNodeRef;
  92. CFXMLTreeRef = CFTreeRef;
  93. { An CFXMLNode describes an individual XML construct - like a tag, or a comment, or a string
  94. of character data. Each CFXMLNode contains 3 main pieces of information - the node's type,
  95. the data string, and a pointer to an additional data structure. The node's type ID is an enum
  96. value of type CFXMLNodeTypeID. The data string is always a CFStringRef; the meaning of the
  97. string is dependent on the node's type ID. The format of the additional data is also dependent
  98. on the node's type; in general, there is a custom structure for each type that requires
  99. additional data. See below for the mapping from type ID to meaning of the data string and
  100. structure of the additional data. Note that these structures are versioned, and may change
  101. as the parser changes. The current version can always be identified by kCFXMLNodeCurrentVersion;
  102. earlier versions can be identified and used by passing earlier values for the version number
  103. (although the older structures would have been removed from the header).
  104. An CFXMLTree is simply a CFTree whose context data is known to be an CFXMLNodeRef. As
  105. such, an CFXMLTree can be used to represent an entire XML document; the CFTree
  106. provides the tree structure of the document, while the CFXMLNodes identify and describe
  107. the nodes of the tree. An XML document can be parsed to a CFXMLTree, and a CFXMLTree
  108. can generate the data for the equivalent XML document - see CFXMLParser.h for more
  109. information on parsing XML.
  110. }
  111. { Type codes for the different possible XML nodes; this list may grow.}
  112. type
  113. CFXMLNodeTypeCode = SInt32;
  114. const
  115. kCFXMLNodeTypeDocument = 1;
  116. kCFXMLNodeTypeElement = 2;
  117. kCFXMLNodeTypeAttribute = 3;
  118. kCFXMLNodeTypeProcessingInstruction = 4;
  119. kCFXMLNodeTypeComment = 5;
  120. kCFXMLNodeTypeText = 6;
  121. kCFXMLNodeTypeCDATASection = 7;
  122. kCFXMLNodeTypeDocumentFragment = 8;
  123. kCFXMLNodeTypeEntity = 9;
  124. kCFXMLNodeTypeEntityReference = 10;
  125. kCFXMLNodeTypeDocumentType = 11;
  126. kCFXMLNodeTypeWhitespace = 12;
  127. kCFXMLNodeTypeNotation = 13;
  128. kCFXMLNodeTypeElementTypeDeclaration = 14;
  129. kCFXMLNodeTypeAttributeListDeclaration = 15;
  130. type
  131. CFXMLElementInfoPtr = ^CFXMLElementInfo;
  132. CFXMLElementInfo = record
  133. attributes: CFDictionaryRef;
  134. attributeOrder: CFArrayRef;
  135. isEmpty: Boolean;
  136. _reserved1,_reserved2,_reserved3: SInt8;
  137. end;
  138. type
  139. CFXMLProcessingInstructionInfoPtr = ^CFXMLProcessingInstructionInfo;
  140. CFXMLProcessingInstructionInfo = record
  141. dataString: CFStringRef;
  142. end;
  143. type
  144. CFXMLDocumentInfoPtr = ^CFXMLDocumentInfo;
  145. CFXMLDocumentInfo = record
  146. sourceURL: CFURLRef;
  147. encoding: CFStringEncoding;
  148. end;
  149. type
  150. CFXMLExternalIDPtr = ^CFXMLExternalID;
  151. CFXMLExternalID = record
  152. systemID: CFURLRef;
  153. publicID: CFStringRef;
  154. end;
  155. type
  156. CFXMLDocumentTypeInfoPtr = ^CFXMLDocumentTypeInfo;
  157. CFXMLDocumentTypeInfo = record
  158. externalID: CFXMLExternalID;
  159. end;
  160. type
  161. CFXMLNotationInfoPtr = ^CFXMLNotationInfo;
  162. CFXMLNotationInfo = record
  163. externalID: CFXMLExternalID;
  164. end;
  165. type
  166. CFXMLElementTypeDeclarationInfoPtr = ^CFXMLElementTypeDeclarationInfo;
  167. CFXMLElementTypeDeclarationInfo = record
  168. { This is expected to change in future versions }
  169. contentDescription: CFStringRef;
  170. end;
  171. type
  172. CFXMLAttributeDeclarationInfoPtr = ^CFXMLAttributeDeclarationInfo;
  173. CFXMLAttributeDeclarationInfo = record
  174. { This is expected to change in future versions }
  175. attributeName: CFStringRef;
  176. typeString: CFStringRef;
  177. defaultString: CFStringRef;
  178. end;
  179. type
  180. CFXMLAttributeListDeclarationInfoPtr = ^CFXMLAttributeListDeclarationInfo;
  181. CFXMLAttributeListDeclarationInfo = record
  182. numberOfAttributes: CFIndex;
  183. attributes: CFXMLAttributeDeclarationInfoPtr;
  184. end;
  185. type
  186. CFXMLEntityTypeCode = SInt32;
  187. const
  188. kCFXMLEntityTypeParameter = 0; { Implies parsed, internal }
  189. kCFXMLEntityTypeParsedInternal = 1;
  190. kCFXMLEntityTypeParsedExternal = 2;
  191. kCFXMLEntityTypeUnparsed = 3;
  192. kCFXMLEntityTypeCharacter = 4;
  193. type
  194. CFXMLEntityInfoPtr = ^CFXMLEntityInfo;
  195. CFXMLEntityInfo = record
  196. entityType: CFXMLEntityTypeCode;
  197. replacementText: CFStringRef; { NULL if entityType is external or unparsed }
  198. entityID: CFXMLExternalID; { entityID.systemID will be NULL if entityType is internal }
  199. notationName: CFStringRef; { NULL if entityType is parsed }
  200. end;
  201. type
  202. CFXMLEntityReferenceInfoPtr = ^CFXMLEntityReferenceInfo;
  203. CFXMLEntityReferenceInfo = record
  204. entityType: CFXMLEntityTypeCode;
  205. end;
  206. {
  207. dataTypeCode meaning of dataString format of infoPtr
  208. =========== ===================== =================
  209. kCFXMLNodeTypeDocument <currently unused> CFXMLDocumentInfo *
  210. kCFXMLNodeTypeElement tag name CFXMLElementInfo *
  211. kCFXMLNodeTypeAttribute <currently unused> <currently unused>
  212. kCFXMLNodeTypeProcessingInstruction name of the target CFXMLProcessingInstructionInfo *
  213. kCFXMLNodeTypeComment text of the comment NULL
  214. kCFXMLNodeTypeText the text's contents NULL
  215. kCFXMLNodeTypeCDATASection text of the CDATA NULL
  216. kCFXMLNodeTypeDocumentFragment <currently unused> <currently unused>
  217. kCFXMLNodeTypeEntity name of the entity CFXMLEntityInfo *
  218. kCFXMLNodeTypeEntityReference name of the referenced entity CFXMLEntityReferenceInfo *
  219. kCFXMLNodeTypeDocumentType name given as top-level element CFXMLDocumentTypeInfo *
  220. kCFXMLNodeTypeWhitespace text of the whitespace NULL
  221. kCFXMLNodeTypeNotation notation name CFXMLNotationInfo *
  222. kCFXMLNodeTypeElementTypeDeclaration tag name CFXMLElementTypeDeclarationInfo *
  223. kCFXMLNodeTypeAttributeListDeclaration tag name CFXMLAttributeListDeclarationInfo *
  224. }
  225. function CFXMLNodeGetTypeID: CFTypeID; external name '_CFXMLNodeGetTypeID';
  226. { Creates a new node based on xmlType, dataString, and additionalInfoPtr. version (together with xmlType) determines the expected structure of additionalInfoPtr }
  227. function CFXMLNodeCreate( alloc: CFAllocatorRef; xmlType: CFXMLNodeTypeCode; dataString: CFStringRef; additionalInfoPtr: {const} UnivPtr; version: CFIndex ): CFXMLNodeRef; external name '_CFXMLNodeCreate';
  228. { Creates a copy of origNode (which may not be NULL). }
  229. function CFXMLNodeCreateCopy( alloc: CFAllocatorRef; origNode: CFXMLNodeRef ): CFXMLNodeRef; external name '_CFXMLNodeCreateCopy';
  230. function CFXMLNodeGetTypeCode( node: CFXMLNodeRef ): CFXMLNodeTypeCode; external name '_CFXMLNodeGetTypeCode';
  231. function CFXMLNodeGetString( node: CFXMLNodeRef ): CFStringRef; external name '_CFXMLNodeGetString';
  232. function CFXMLNodeGetInfoPtr( node: CFXMLNodeRef ): UnivPtr; external name '_CFXMLNodeGetInfoPtr';
  233. function CFXMLNodeGetVersion( node: CFXMLNodeRef ): CFIndex; external name '_CFXMLNodeGetVersion';
  234. { CFXMLTreeRef }
  235. { Creates a childless, parentless tree from node }
  236. function CFXMLTreeCreateWithNode( allocator: CFAllocatorRef; node: CFXMLNodeRef ): CFXMLTreeRef; external name '_CFXMLTreeCreateWithNode';
  237. { Extracts and returns the node stored in xmlTree }
  238. function CFXMLTreeGetNode( xmlTree: CFXMLTreeRef ): CFXMLNodeRef; external name '_CFXMLTreeGetNode';
  239. end.