CFPropertyList.pas 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. { CFPropertyList.h
  2. Copyright (c) 1998-2005, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, September 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 CFPropertyList;
  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,CFData,CFString,CFStream;
  86. {$ALIGN POWER}
  87. type
  88. CFPropertyListMutabilityOptions = SInt32;
  89. const
  90. kCFPropertyListImmutable = 0;
  91. kCFPropertyListMutableContainers = 1;
  92. kCFPropertyListMutableContainersAndLeaves = 2;
  93. {
  94. Creates a property list object from its XML description; xmlData should
  95. be the raw bytes of that description, possibly the contents of an XML
  96. file. Returns NULL if the data cannot be parsed; if the parse fails
  97. and errorString is non-NULL, a human-readable description of the failure
  98. is returned in errorString. It is the caller's responsibility to release
  99. either the returned object or the error string, whichever is applicable.
  100. }
  101. function CFPropertyListCreateFromXMLData( allocator: CFAllocatorRef; xmlData: CFDataRef; mutabilityOption: CFOptionFlags; errorString: CFStringRefPtr ): CFPropertyListRef; external name '_CFPropertyListCreateFromXMLData';
  102. {
  103. Returns the XML description of the given object; propertyList must
  104. be one of the supported property list types, and (for composite types
  105. like CFArray and CFDictionary) must not contain any elements that
  106. are not themselves of a property list type. If a non-property list
  107. type is encountered, NULL is returned. The returned data is
  108. appropriate for writing out to an XML file. Note that a data, not a
  109. string, is returned because the bytes contain in them a description
  110. of the string encoding used.
  111. }
  112. function CFPropertyListCreateXMLData( allocator: CFAllocatorRef; propertyList: CFPropertyListRef ): CFDataRef; external name '_CFPropertyListCreateXMLData';
  113. {
  114. Recursively creates a copy of the given property list (so nested arrays
  115. and dictionaries are copied as well as the top-most container). The
  116. resulting property list has the mutability characteristics determined
  117. by mutabilityOption.
  118. }
  119. function CFPropertyListCreateDeepCopy( allocator: CFAllocatorRef; propertyList: CFPropertyListRef; mutabilityOption: CFOptionFlags ): CFPropertyListRef; external name '_CFPropertyListCreateDeepCopy';
  120. {#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED}
  121. type
  122. CFPropertyListFormat = SInt32;
  123. const
  124. kCFPropertyListOpenStepFormat = 1;
  125. kCFPropertyListXMLFormat_v1_0 = 100;
  126. kCFPropertyListBinaryFormat_v1_0 = 200;
  127. function CFPropertyListIsValid( plist: CFPropertyListRef; format: CFPropertyListFormat ): Boolean; external name '_CFPropertyListIsValid';
  128. { Returns true if the object graph rooted at plist is a valid property list
  129. * graph -- that is, no cycles, containing only plist objects, and dictionary
  130. * keys are strings. The debugging library version spits out some messages
  131. * to be helpful. The plist structure which is to be allowed is given by
  132. * the format parameter. }
  133. function CFPropertyListWriteToStream( propertyList: CFPropertyListRef; stream: CFWriteStreamRef; format: CFPropertyListFormat; var errorString: CFStringRef ): CFIndex; external name '_CFPropertyListWriteToStream';
  134. { Writes the bytes of a plist serialization out to the stream. The
  135. * stream must be opened and configured -- the function simply writes
  136. * a bunch of bytes to the stream. The output plist format can be chosen.
  137. * Leaves the stream open, but note that reading a plist expects the
  138. * reading stream to end wherever the writing ended, so that the
  139. * end of the plist data can be identified. Returns the number of bytes
  140. * written, or 0 on error. Error messages are not currently localized, but
  141. * may be in the future, so they are not suitable for comparison. }
  142. function CFPropertyListCreateFromStream( allocator: CFAllocatorRef; stream: CFReadStreamRef; streamLength: CFIndex; mutabilityOption: CFOptionFlags; var format: CFPropertyListFormat; var errorString: CFStringRef ): CFPropertyListRef; external name '_CFPropertyListCreateFromStream';
  143. { Same as current function CFPropertyListCreateFromXMLData()
  144. * but takes a stream instead of data, and works on any plist file format.
  145. * CFPropertyListCreateFromXMLData() also works on any plist file format.
  146. * The stream must be open and configured -- the function simply reads a bunch
  147. * of bytes from it starting at the current location in the stream, to the END
  148. * of the stream, which is expected to be the end of the plist, or up to the
  149. * number of bytes given by the length parameter if it is not 0. Error messages
  150. * are not currently localized, but may be in the future, so they are not
  151. * suitable for comparison. }
  152. {#endif}
  153. end.