CFDictionary.pas 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. { CFDictionary.h
  2. Copyright (c) 1998-2009, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, September 2005 }
  5. { Pascal Translation Updated: Jonas Maebe, <[email protected]>, October 2009 }
  6. {
  7. Modified for use with Free Pascal
  8. Version 308
  9. Please report any bugs to <[email protected]>
  10. }
  11. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  12. {$mode macpas}
  13. {$packenum 1}
  14. {$macro on}
  15. {$inline on}
  16. {$calling mwpascal}
  17. unit CFDictionary;
  18. interface
  19. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  20. {$setc GAP_INTERFACES_VERSION := $0308}
  21. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  22. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  23. {$endc}
  24. {$ifc defined CPUPOWERPC and defined CPUI386}
  25. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  26. {$endc}
  27. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  28. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  29. {$endc}
  30. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  31. {$setc __ppc__ := 1}
  32. {$elsec}
  33. {$setc __ppc__ := 0}
  34. {$endc}
  35. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  36. {$setc __ppc64__ := 1}
  37. {$elsec}
  38. {$setc __ppc64__ := 0}
  39. {$endc}
  40. {$ifc not defined __i386__ and defined CPUI386}
  41. {$setc __i386__ := 1}
  42. {$elsec}
  43. {$setc __i386__ := 0}
  44. {$endc}
  45. {$ifc not defined __x86_64__ and defined CPUX86_64}
  46. {$setc __x86_64__ := 1}
  47. {$elsec}
  48. {$setc __x86_64__ := 0}
  49. {$endc}
  50. {$ifc not defined __arm__ and defined CPUARM}
  51. {$setc __arm__ := 1}
  52. {$elsec}
  53. {$setc __arm__ := 0}
  54. {$endc}
  55. {$ifc defined cpu64}
  56. {$setc __LP64__ := 1}
  57. {$elsec}
  58. {$setc __LP64__ := 0}
  59. {$endc}
  60. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  61. {$error Conflicting definitions for __ppc__ and __i386__}
  62. {$endc}
  63. {$ifc defined __ppc__ and __ppc__}
  64. {$setc TARGET_CPU_PPC := TRUE}
  65. {$setc TARGET_CPU_PPC64 := FALSE}
  66. {$setc TARGET_CPU_X86 := FALSE}
  67. {$setc TARGET_CPU_X86_64 := FALSE}
  68. {$setc TARGET_CPU_ARM := FALSE}
  69. {$setc TARGET_OS_MAC := TRUE}
  70. {$setc TARGET_OS_IPHONE := FALSE}
  71. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  72. {$elifc defined __ppc64__ and __ppc64__}
  73. {$setc TARGET_CPU_PPC := FALSE}
  74. {$setc TARGET_CPU_PPC64 := TRUE}
  75. {$setc TARGET_CPU_X86 := FALSE}
  76. {$setc TARGET_CPU_X86_64 := FALSE}
  77. {$setc TARGET_CPU_ARM := FALSE}
  78. {$setc TARGET_OS_MAC := TRUE}
  79. {$setc TARGET_OS_IPHONE := FALSE}
  80. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  81. {$elifc defined __i386__ and __i386__}
  82. {$setc TARGET_CPU_PPC := FALSE}
  83. {$setc TARGET_CPU_PPC64 := FALSE}
  84. {$setc TARGET_CPU_X86 := TRUE}
  85. {$setc TARGET_CPU_X86_64 := FALSE}
  86. {$setc TARGET_CPU_ARM := FALSE}
  87. {$ifc defined(iphonesim)}
  88. {$setc TARGET_OS_MAC := FALSE}
  89. {$setc TARGET_OS_IPHONE := TRUE}
  90. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  91. {$elsec}
  92. {$setc TARGET_OS_MAC := TRUE}
  93. {$setc TARGET_OS_IPHONE := FALSE}
  94. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  95. {$endc}
  96. {$elifc defined __x86_64__ and __x86_64__}
  97. {$setc TARGET_CPU_PPC := FALSE}
  98. {$setc TARGET_CPU_PPC64 := FALSE}
  99. {$setc TARGET_CPU_X86 := FALSE}
  100. {$setc TARGET_CPU_X86_64 := TRUE}
  101. {$setc TARGET_CPU_ARM := FALSE}
  102. {$setc TARGET_OS_MAC := TRUE}
  103. {$setc TARGET_OS_IPHONE := FALSE}
  104. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  105. {$elifc defined __arm__ and __arm__}
  106. {$setc TARGET_CPU_PPC := FALSE}
  107. {$setc TARGET_CPU_PPC64 := FALSE}
  108. {$setc TARGET_CPU_X86 := FALSE}
  109. {$setc TARGET_CPU_X86_64 := FALSE}
  110. {$setc TARGET_CPU_ARM := TRUE}
  111. { will require compiler define when/if other Apple devices with ARM cpus ship }
  112. {$setc TARGET_OS_MAC := FALSE}
  113. {$setc TARGET_OS_IPHONE := TRUE}
  114. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  115. {$elsec}
  116. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
  117. {$endc}
  118. {$ifc defined __LP64__ and __LP64__ }
  119. {$setc TARGET_CPU_64 := TRUE}
  120. {$elsec}
  121. {$setc TARGET_CPU_64 := FALSE}
  122. {$endc}
  123. {$ifc defined FPC_BIG_ENDIAN}
  124. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  125. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  126. {$elifc defined FPC_LITTLE_ENDIAN}
  127. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  128. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  129. {$elsec}
  130. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  131. {$endc}
  132. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  133. {$setc CALL_NOT_IN_CARBON := FALSE}
  134. {$setc OLDROUTINENAMES := FALSE}
  135. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  136. {$setc OPAQUE_UPP_TYPES := TRUE}
  137. {$setc OTCARBONAPPLICATION := TRUE}
  138. {$setc OTKERNEL := FALSE}
  139. {$setc PM_USE_SESSION_APIS := TRUE}
  140. {$setc TARGET_API_MAC_CARBON := TRUE}
  141. {$setc TARGET_API_MAC_OS8 := FALSE}
  142. {$setc TARGET_API_MAC_OSX := TRUE}
  143. {$setc TARGET_CARBON := TRUE}
  144. {$setc TARGET_CPU_68K := FALSE}
  145. {$setc TARGET_CPU_MIPS := FALSE}
  146. {$setc TARGET_CPU_SPARC := FALSE}
  147. {$setc TARGET_OS_UNIX := FALSE}
  148. {$setc TARGET_OS_WIN32 := FALSE}
  149. {$setc TARGET_RT_MAC_68881 := FALSE}
  150. {$setc TARGET_RT_MAC_CFM := FALSE}
  151. {$setc TARGET_RT_MAC_MACHO := TRUE}
  152. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  153. {$setc TYPE_BOOL := FALSE}
  154. {$setc TYPE_EXTENDED := FALSE}
  155. {$setc TYPE_LONGLONG := TRUE}
  156. uses MacTypes,CFBase;
  157. {$endc} {not MACOSALLINCLUDE}
  158. {$ALIGN POWER}
  159. {!
  160. @header CFDictionary
  161. CFDictionary implements a container which pairs pointer-sized keys
  162. with pointer-sized values. Values are accessed via arbitrary
  163. user-defined keys. A CFDictionary differs from a CFArray in that
  164. the key used to access a particular value in the dictionary remains
  165. the same as values are added to or removed from the dictionary,
  166. unless a value associated with its particular key is replaced or
  167. removed. In a CFArray, the key (or index) used to retrieve a
  168. particular value can change over time as values are added to or
  169. deleted from the array. Also unlike an array, there is no ordering
  170. among values in a dictionary. To enable later retrieval of a value,
  171. the key of the key-value pair should be constant (or treated as
  172. constant); if the key changes after being used to put a value in
  173. the dictionary, the value may not be retrievable. The keys of a
  174. dictionary form a set; that is, no two keys which are equal to
  175. one another are present in the dictionary at any time.
  176. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  177. Dictionaries come in two flavors, immutable, which cannot have
  178. values added to them or removed from them after the dictionary is
  179. created, and mutable, to which you can add values or from which
  180. remove values. Mutable dictionaries have two subflavors,
  181. fixed-capacity, for which there is a maximum number set at creation
  182. time of values which can be put into the dictionary, and variable
  183. capacity, which can have an unlimited number of values (or rather,
  184. limited only by constraints external to CFDictionary, like the
  185. amount of available memory). Fixed-capacity dictionaries can be
  186. somewhat higher performing, if you can put a definate upper limit
  187. on the number of values that might be put into the dictionary.
  188. #else
  189. Dictionaries come in two flavors, immutable, which cannot have
  190. values added to them or removed from them after the dictionary is
  191. created, and mutable, to which you can add values or from which
  192. remove values. Mutable dictionaries can have an unlimited number
  193. of values (or rather, limited only by constraints external to
  194. CFDictionary, like the amount of available memory).
  195. #endif
  196. As with all CoreFoundation collection types, dictionaries maintain
  197. hard references on the values you put in them, but the retaining and
  198. releasing functions are user-defined callbacks that can actually do
  199. whatever the user wants (for example, nothing).
  200. Although a particular implementation of CFDictionary may not use
  201. hashing and a hash table for storage of the values, the keys have
  202. a hash-code generating function defined for them, and a function
  203. to test for equality of two keys. These two functions together
  204. must maintain the invariant that if equal(X, Y), then hash(X) ==
  205. hash(Y). Note that the converse will not generally be true (but
  206. the contrapositive, if hash(X) != hash(Y), then !equal(X, Y),
  207. will be as required by Boolean logic). If the hash() and equal()
  208. key callbacks are NULL, the key is used as a pointer-sized integer,
  209. and pointer equality is used. Care should be taken to provide a
  210. hash() callback which will compute sufficiently dispersed hash
  211. codes for the key set for best performance.
  212. Computational Complexity
  213. The access time for a value in the dictionary is guaranteed to be at
  214. worst O(N) for any implementation, current and future, but will
  215. often be O(1) (constant time). Insertion or deletion operations
  216. will typically be constant time as well, but are O(N*N) in the
  217. worst case in some implementations. Access of values through a key
  218. is faster than accessing values directly (if there are any such
  219. operations). Dictionaries will tend to use significantly more memory
  220. than a array with the same number of values.
  221. }
  222. {!
  223. @typedef CFDictionaryKeyCallBacks
  224. Structure containing the callbacks for keys of a CFDictionary.
  225. @field version The version number of the structure type being passed
  226. in as a parameter to the CFDictionary creation functions.
  227. This structure is version 0.
  228. @field retain The callback used to add a retain for the dictionary
  229. on keys as they are used to put values into the dictionary.
  230. This callback returns the value to use as the key in the
  231. dictionary, which is usually the value parameter passed to
  232. this callback, but may be a different value if a different
  233. value should be used as the key. The dictionary's allocator
  234. is passed as the first argument.
  235. @field release The callback used to remove a retain previously added
  236. for the dictionary from keys as their values are removed from
  237. the dictionary. The dictionary's allocator is passed as the
  238. first argument.
  239. @field copyDescription The callback used to create a descriptive
  240. string representation of each key in the dictionary. This
  241. is used by the CFCopyDescription() function.
  242. @field equal The callback used to compare keys in the dictionary for
  243. equality.
  244. @field hash The callback used to compute a hash code for keys as they
  245. are used to access, add, or remove values in the dictionary.
  246. }
  247. type
  248. CFDictionaryRetainCallBack = function( allocator: CFAllocatorRef; value: {const} UnivPtr ): UnivPtr;
  249. CFDictionaryReleaseCallBack = procedure( allocator: CFAllocatorRef; value: {const} UnivPtr );
  250. CFDictionaryCopyDescriptionCallBack = function( value: {const} UnivPtr ): CFStringRef;
  251. CFDictionaryEqualCallBack = function( value1: {const} UnivPtr; value2: {const} UnivPtr ): Boolean;
  252. CFDictionaryHashCallBack = function( value: {const} UnivPtr ): CFHashCode;
  253. CFDictionaryKeyCallBacks = record
  254. version: CFIndex;
  255. retain: CFDictionaryRetainCallBack;
  256. release: CFDictionaryReleaseCallBack;
  257. copyDescription: CFDictionaryCopyDescriptionCallBack;
  258. equal: CFDictionaryEqualCallBack;
  259. hash: CFDictionaryHashCallBack;
  260. end;
  261. CFDictionaryKeyCallBacksPtr = ^CFDictionaryKeyCallBacks;
  262. {!
  263. @constant kCFTypeDictionaryKeyCallBacks
  264. Predefined CFDictionaryKeyCallBacks structure containing a
  265. set of callbacks appropriate for use when the keys of a
  266. CFDictionary are all CFTypes.
  267. }
  268. var kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; external name '_kCFTypeDictionaryKeyCallBacks'; (* attribute const *)
  269. {!
  270. @constant kCFCopyStringDictionaryKeyCallBacks
  271. Predefined CFDictionaryKeyCallBacks structure containing a
  272. set of callbacks appropriate for use when the keys of a
  273. CFDictionary are all CFStrings, which may be mutable and
  274. need to be copied in order to serve as constant keys for
  275. the values in the dictionary.
  276. }
  277. var kCFCopyStringDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; external name '_kCFCopyStringDictionaryKeyCallBacks'; (* attribute const *)
  278. {!
  279. @typedef CFDictionaryValueCallBacks
  280. Structure containing the callbacks for values of a CFDictionary.
  281. @field version The version number of the structure type being passed
  282. in as a parameter to the CFDictionary creation functions.
  283. This structure is version 0.
  284. @field retain The callback used to add a retain for the dictionary
  285. on values as they are put into the dictionary.
  286. This callback returns the value to use as the value in the
  287. dictionary, which is usually the value parameter passed to
  288. this callback, but may be a different value if a different
  289. value should be added to the dictionary. The dictionary's
  290. allocator is passed as the first argument.
  291. @field release The callback used to remove a retain previously added
  292. for the dictionary from values as they are removed from
  293. the dictionary. The dictionary's allocator is passed as the
  294. first argument.
  295. @field copyDescription The callback used to create a descriptive
  296. string representation of each value in the dictionary. This
  297. is used by the CFCopyDescription() function.
  298. @field equal The callback used to compare values in the dictionary for
  299. equality in some operations.
  300. }
  301. type
  302. CFDictionaryValueCallBacks = record
  303. version: CFIndex;
  304. retain: CFDictionaryRetainCallBack;
  305. release: CFDictionaryReleaseCallBack;
  306. copyDescription: CFDictionaryCopyDescriptionCallBack;
  307. equal: CFDictionaryEqualCallBack;
  308. end;
  309. CFDictionaryValueCallBacksPtr = ^CFDictionaryValueCallBacks;
  310. {!
  311. @constant kCFTypeDictionaryValueCallBacks
  312. Predefined CFDictionaryValueCallBacks structure containing a set
  313. of callbacks appropriate for use when the values in a CFDictionary
  314. are all CFTypes.
  315. }
  316. var kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks; external name '_kCFTypeDictionaryValueCallBacks'; (* attribute const *)
  317. {!
  318. @typedef CFDictionaryApplierFunction
  319. Type of the callback function used by the apply functions of
  320. CFDictionarys.
  321. @param key The current key for the value.
  322. @param value The current value from the dictionary.
  323. @param context The user-defined context parameter given to the apply
  324. function.
  325. }
  326. type
  327. CFDictionaryApplierFunction = procedure( key: {const} UnivPtr; value: {const} UnivPtr; context: UnivPtr );
  328. {!
  329. @typedef CFDictionaryRef
  330. This is the type of a reference to immutable CFDictionarys.
  331. }
  332. type
  333. CFDictionaryRef = ^SInt32; { an opaque type }
  334. CFDictionaryRefPtr = ^CFDictionaryRef;
  335. {!
  336. @typedef CFMutableDictionaryRef
  337. This is the type of a reference to mutable CFDictionarys.
  338. }
  339. type
  340. CFMutableDictionaryRef = CFDictionaryRef;
  341. CFMutableDictionaryRefPtr = ^CFMutableDictionaryRef;
  342. {!
  343. @function CFDictionaryGetTypeID
  344. Returns the type identifier of all CFDictionary instances.
  345. }
  346. function CFDictionaryGetTypeID: CFTypeID; external name '_CFDictionaryGetTypeID';
  347. {!
  348. @function CFDictionaryCreate
  349. Creates a new immutable dictionary with the given values.
  350. @param allocator The CFAllocator which should be used to allocate
  351. memory for the dictionary and its storage for values. This
  352. parameter may be NULL in which case the current default
  353. CFAllocator is used. If this reference is not a valid
  354. CFAllocator, the behavior is undefined.
  355. @param keys A C array of the pointer-sized keys to be used for
  356. the parallel C array of values to be put into the dictionary.
  357. This parameter may be NULL if the numValues parameter is 0.
  358. This C array is not changed or freed by this function. If
  359. this parameter is not a valid pointer to a C array of at
  360. least numValues pointers, the behavior is undefined.
  361. @param values A C array of the pointer-sized values to be in the
  362. dictionary. This parameter may be NULL if the numValues
  363. parameter is 0. This C array is not changed or freed by
  364. this function. If this parameter is not a valid pointer to
  365. a C array of at least numValues pointers, the behavior is
  366. undefined.
  367. @param numValues The number of values to copy from the keys and
  368. values C arrays into the CFDictionary. This number will be
  369. the count of the dictionary. If this parameter is
  370. negative, or greater than the number of values actually
  371. in the keys or values C arrays, the behavior is undefined.
  372. @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure
  373. initialized with the callbacks for the dictionary to use on
  374. each key in the dictionary. The retain callback will be used
  375. within this function, for example, to retain all of the new
  376. keys from the keys C array. A copy of the contents of the
  377. callbacks structure is made, so that a pointer to a structure
  378. on the stack can be passed in, or can be reused for multiple
  379. dictionary creations. If the version field of this
  380. callbacks structure is not one of the defined ones for
  381. CFDictionary, the behavior is undefined. The retain field may
  382. be NULL, in which case the CFDictionary will do nothing to add
  383. a retain to the keys of the contained values. The release field
  384. may be NULL, in which case the CFDictionary will do nothing
  385. to remove the dictionary's retain (if any) on the keys when the
  386. dictionary is destroyed or a key-value pair is removed. If the
  387. copyDescription field is NULL, the dictionary will create a
  388. simple description for a key. If the equal field is NULL, the
  389. dictionary will use pointer equality to test for equality of
  390. keys. If the hash field is NULL, a key will be converted from
  391. a pointer to an integer to compute the hash code. This callbacks
  392. parameter itself may be NULL, which is treated as if a valid
  393. structure of version 0 with all fields NULL had been passed in.
  394. Otherwise, if any of the fields are not valid pointers to
  395. functions of the correct type, or this parameter is not a
  396. valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
  397. the behavior is undefined. If any of the keys put into the
  398. dictionary is not one understood by one of the callback functions
  399. the behavior when that callback function is used is undefined.
  400. @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure
  401. initialized with the callbacks for the dictionary to use on
  402. each value in the dictionary. The retain callback will be used
  403. within this function, for example, to retain all of the new
  404. values from the values C array. A copy of the contents of the
  405. callbacks structure is made, so that a pointer to a structure
  406. on the stack can be passed in, or can be reused for multiple
  407. dictionary creations. If the version field of this callbacks
  408. structure is not one of the defined ones for CFDictionary, the
  409. behavior is undefined. The retain field may be NULL, in which
  410. case the CFDictionary will do nothing to add a retain to values
  411. as they are put into the dictionary. The release field may be
  412. NULL, in which case the CFDictionary will do nothing to remove
  413. the dictionary's retain (if any) on the values when the
  414. dictionary is destroyed or a key-value pair is removed. If the
  415. copyDescription field is NULL, the dictionary will create a
  416. simple description for a value. If the equal field is NULL, the
  417. dictionary will use pointer equality to test for equality of
  418. values. This callbacks parameter itself may be NULL, which is
  419. treated as if a valid structure of version 0 with all fields
  420. NULL had been passed in. Otherwise,
  421. if any of the fields are not valid pointers to functions
  422. of the correct type, or this parameter is not a valid
  423. pointer to a CFDictionaryValueCallBacks callbacks structure,
  424. the behavior is undefined. If any of the values put into the
  425. dictionary is not one understood by one of the callback functions
  426. the behavior when that callback function is used is undefined.
  427. @result A reference to the new immutable CFDictionary.
  428. }
  429. function CFDictionaryCreate( allocator: CFAllocatorRef; {const} keys: UnivPtrPtr; {const} values: UnivPtrPtr; numValues: CFIndex; {const} keyCallBacks: CFDictionaryKeyCallBacksPtr { can be NULL }; {const} valueCallBacks: CFDictionaryValueCallBacksPtr { can be NULL } ): CFDictionaryRef; external name '_CFDictionaryCreate';
  430. {!
  431. @function CFDictionaryCreateCopy
  432. Creates a new immutable dictionary with the key-value pairs from
  433. the given dictionary.
  434. @param allocator The CFAllocator which should be used to allocate
  435. memory for the dictionary and its storage for values. This
  436. parameter may be NULL in which case the current default
  437. CFAllocator is used. If this reference is not a valid
  438. CFAllocator, the behavior is undefined.
  439. @param theDict The dictionary which is to be copied. The keys and values
  440. from the dictionary are copied as pointers into the new
  441. dictionary (that is, the values themselves are copied, not
  442. that which the values point to, if anything). However, the
  443. keys and values are also retained by the new dictionary using
  444. the retain function of the original dictionary.
  445. The count of the new dictionary will be the same as the
  446. given dictionary. The new dictionary uses the same callbacks
  447. as the dictionary to be copied. If this parameter is
  448. not a valid CFDictionary, the behavior is undefined.
  449. @result A reference to the new immutable CFDictionary.
  450. }
  451. function CFDictionaryCreateCopy( allocator: CFAllocatorRef; theDict: CFDictionaryRef ): CFDictionaryRef; external name '_CFDictionaryCreateCopy';
  452. {!
  453. @function CFDictionaryCreateMutable
  454. Creates a new mutable dictionary.
  455. @param allocator The CFAllocator which should be used to allocate
  456. memory for the dictionary and its storage for values. This
  457. parameter may be NULL in which case the current default
  458. CFAllocator is used. If this reference is not a valid
  459. CFAllocator, the behavior is undefined.
  460. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  461. @param capacity The maximum number of values that can be contained by
  462. the CFDictionary. The dictionary starts empty, and can grow
  463. to this number of values (and it can have less). If this
  464. parameter is 0, the dictionary's maximum capacity is unlimited
  465. (or rather, only limited by address space and available memory
  466. constraints). If this parameter is negative, the behavior is
  467. undefined.
  468. #else
  469. @param capacity A hint about the number of values that will be held
  470. by the CFDictionary. Pass 0 for no hint. The implementation may
  471. ignore this hint, or may use it to optimize various
  472. operations. A dictionary's actual capacity is only limited by
  473. address space and available memory constraints). If this
  474. parameter is negative, the behavior is undefined.
  475. #endif
  476. @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure
  477. initialized with the callbacks for the dictionary to use on
  478. each key in the dictionary. A copy of the contents of the
  479. callbacks structure is made, so that a pointer to a structure
  480. on the stack can be passed in, or can be reused for multiple
  481. dictionary creations. If the version field of this
  482. callbacks structure is not one of the defined ones for
  483. CFDictionary, the behavior is undefined. The retain field may
  484. be NULL, in which case the CFDictionary will do nothing to add
  485. a retain to the keys of the contained values. The release field
  486. may be NULL, in which case the CFDictionary will do nothing
  487. to remove the dictionary's retain (if any) on the keys when the
  488. dictionary is destroyed or a key-value pair is removed. If the
  489. copyDescription field is NULL, the dictionary will create a
  490. simple description for a key. If the equal field is NULL, the
  491. dictionary will use pointer equality to test for equality of
  492. keys. If the hash field is NULL, a key will be converted from
  493. a pointer to an integer to compute the hash code. This callbacks
  494. parameter itself may be NULL, which is treated as if a valid
  495. structure of version 0 with all fields NULL had been passed in.
  496. Otherwise, if any of the fields are not valid pointers to
  497. functions of the correct type, or this parameter is not a
  498. valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
  499. the behavior is undefined. If any of the keys put into the
  500. dictionary is not one understood by one of the callback functions
  501. the behavior when that callback function is used is undefined.
  502. @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure
  503. initialized with the callbacks for the dictionary to use on
  504. each value in the dictionary. The retain callback will be used
  505. within this function, for example, to retain all of the new
  506. values from the values C array. A copy of the contents of the
  507. callbacks structure is made, so that a pointer to a structure
  508. on the stack can be passed in, or can be reused for multiple
  509. dictionary creations. If the version field of this callbacks
  510. structure is not one of the defined ones for CFDictionary, the
  511. behavior is undefined. The retain field may be NULL, in which
  512. case the CFDictionary will do nothing to add a retain to values
  513. as they are put into the dictionary. The release field may be
  514. NULL, in which case the CFDictionary will do nothing to remove
  515. the dictionary's retain (if any) on the values when the
  516. dictionary is destroyed or a key-value pair is removed. If the
  517. copyDescription field is NULL, the dictionary will create a
  518. simple description for a value. If the equal field is NULL, the
  519. dictionary will use pointer equality to test for equality of
  520. values. This callbacks parameter itself may be NULL, which is
  521. treated as if a valid structure of version 0 with all fields
  522. NULL had been passed in. Otherwise,
  523. if any of the fields are not valid pointers to functions
  524. of the correct type, or this parameter is not a valid
  525. pointer to a CFDictionaryValueCallBacks callbacks structure,
  526. the behavior is undefined. If any of the values put into the
  527. dictionary is not one understood by one of the callback functions
  528. the behavior when that callback function is used is undefined.
  529. @result A reference to the new mutable CFDictionary.
  530. }
  531. function CFDictionaryCreateMutable( allocator: CFAllocatorRef; capacity: CFIndex; {const} keyCallBacks: CFDictionaryKeyCallBacksPtr { can be NULL }; {const} valueCallBacks: CFDictionaryValueCallBacksPtr { can be NULL } ): CFMutableDictionaryRef; external name '_CFDictionaryCreateMutable';
  532. {!
  533. @function CFDictionaryCreateMutableCopy
  534. Creates a new mutable dictionary with the key-value pairs from
  535. the given dictionary.
  536. @param allocator The CFAllocator which should be used to allocate
  537. memory for the dictionary and its storage for values. This
  538. parameter may be NULL in which case the current default
  539. CFAllocator is used. If this reference is not a valid
  540. CFAllocator, the behavior is undefined.
  541. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  542. @param capacity The maximum number of values that can be contained
  543. by the CFDictionary. The dictionary starts empty, and can grow
  544. to this number of values (and it can have less). If this
  545. parameter is 0, the dictionary's maximum capacity is unlimited
  546. (or rather, only limited by address space and available memory
  547. constraints). This parameter must be greater than or equal
  548. to the count of the dictionary which is to be copied, or the
  549. behavior is undefined. If this parameter is negative, the
  550. behavior is undefined.
  551. #else
  552. @param capacity A hint about the number of values that will be held
  553. by the CFDictionary. Pass 0 for no hint. The implementation may
  554. ignore this hint, or may use it to optimize various
  555. operations. A dictionary's actual capacity is only limited by
  556. address space and available memory constraints).
  557. This parameter must be greater than or equal
  558. to the count of the dictionary which is to be copied, or the
  559. behavior is undefined. If this parameter is negative, the
  560. behavior is undefined.
  561. #endif
  562. @param theDict The dictionary which is to be copied. The keys and values
  563. from the dictionary are copied as pointers into the new
  564. dictionary (that is, the values themselves are copied, not
  565. that which the values point to, if anything). However, the
  566. keys and values are also retained by the new dictionary using
  567. the retain function of the original dictionary.
  568. The count of the new dictionary will be the same as the
  569. given dictionary. The new dictionary uses the same callbacks
  570. as the dictionary to be copied. If this parameter is
  571. not a valid CFDictionary, the behavior is undefined.
  572. @result A reference to the new mutable CFDictionary.
  573. }
  574. function CFDictionaryCreateMutableCopy( allocator: CFAllocatorRef; capacity: CFIndex; theDict: CFDictionaryRef ): CFMutableDictionaryRef; external name '_CFDictionaryCreateMutableCopy';
  575. {!
  576. @function CFDictionaryGetCount
  577. Returns the number of values currently in the dictionary.
  578. @param theDict The dictionary to be queried. If this parameter is
  579. not a valid CFDictionary, the behavior is undefined.
  580. @result The number of values in the dictionary.
  581. }
  582. function CFDictionaryGetCount( theDict: CFDictionaryRef ): CFIndex; external name '_CFDictionaryGetCount';
  583. {!
  584. @function CFDictionaryGetCountOfKey
  585. Counts the number of times the given key occurs in the dictionary.
  586. @param theDict The dictionary to be searched. If this parameter is
  587. not a valid CFDictionary, the behavior is undefined.
  588. @param key The key for which to find matches in the dictionary. The
  589. hash() and equal() key callbacks provided when the dictionary
  590. was created are used to compare. If the hash() key callback
  591. was NULL, the key is treated as a pointer and converted to
  592. an integer. If the equal() key callback was NULL, pointer
  593. equality (in C, ==) is used. If key, or any of the keys in
  594. the dictionary, are not understood by the equal() callback,
  595. the behavior is undefined.
  596. @result Returns 1 if a matching key is used by the dictionary,
  597. 0 otherwise.
  598. }
  599. function CFDictionaryGetCountOfKey( theDict: CFDictionaryRef; key: {const} UnivPtr ): CFIndex; external name '_CFDictionaryGetCountOfKey';
  600. {!
  601. @function CFDictionaryGetCountOfValue
  602. Counts the number of times the given value occurs in the dictionary.
  603. @param theDict The dictionary to be searched. If this parameter is
  604. not a valid CFDictionary, the behavior is undefined.
  605. @param value The value for which to find matches in the dictionary. The
  606. equal() callback provided when the dictionary was created is
  607. used to compare. If the equal() value callback was NULL, pointer
  608. equality (in C, ==) is used. If value, or any of the values in
  609. the dictionary, are not understood by the equal() callback,
  610. the behavior is undefined.
  611. @result The number of times the given value occurs in the dictionary.
  612. }
  613. function CFDictionaryGetCountOfValue( theDict: CFDictionaryRef; value: {const} UnivPtr ): CFIndex; external name '_CFDictionaryGetCountOfValue';
  614. {!
  615. @function CFDictionaryContainsKey
  616. Reports whether or not the key is in the dictionary.
  617. @param theDict The dictionary to be searched. If this parameter is
  618. not a valid CFDictionary, the behavior is undefined.
  619. @param key The key for which to find matches in the dictionary. The
  620. hash() and equal() key callbacks provided when the dictionary
  621. was created are used to compare. If the hash() key callback
  622. was NULL, the key is treated as a pointer and converted to
  623. an integer. If the equal() key callback was NULL, pointer
  624. equality (in C, ==) is used. If key, or any of the keys in
  625. the dictionary, are not understood by the equal() callback,
  626. the behavior is undefined.
  627. @result true, if the key is in the dictionary, otherwise false.
  628. }
  629. function CFDictionaryContainsKey( theDict: CFDictionaryRef; key: {const} UnivPtr ): Boolean; external name '_CFDictionaryContainsKey';
  630. {!
  631. @function CFDictionaryContainsValue
  632. Reports whether or not the value is in the dictionary.
  633. @param theDict The dictionary to be searched. If this parameter is
  634. not a valid CFDictionary, the behavior is undefined.
  635. @param value The value for which to find matches in the dictionary. The
  636. equal() callback provided when the dictionary was created is
  637. used to compare. If the equal() callback was NULL, pointer
  638. equality (in C, ==) is used. If value, or any of the values
  639. in the dictionary, are not understood by the equal() callback,
  640. the behavior is undefined.
  641. @result true, if the value is in the dictionary, otherwise false.
  642. }
  643. function CFDictionaryContainsValue( theDict: CFDictionaryRef; value: {const} UnivPtr ): Boolean; external name '_CFDictionaryContainsValue';
  644. {!
  645. @function CFDictionaryGetValue
  646. Retrieves the value associated with the given key.
  647. @param theDict The dictionary to be queried. If this parameter is
  648. not a valid CFDictionary, the behavior is undefined.
  649. @param key The key for which to find a match in the dictionary. The
  650. hash() and equal() key callbacks provided when the dictionary
  651. was created are used to compare. If the hash() key callback
  652. was NULL, the key is treated as a pointer and converted to
  653. an integer. If the equal() key callback was NULL, pointer
  654. equality (in C, ==) is used. If key, or any of the keys in
  655. the dictionary, are not understood by the equal() callback,
  656. the behavior is undefined.
  657. @result The value with the given key in the dictionary, or NULL if
  658. no key-value pair with a matching key exists. Since NULL
  659. can be a valid value in some dictionaries, the function
  660. CFDictionaryGetValueIfPresent() must be used to distinguish
  661. NULL-no-found from NULL-is-the-value.
  662. }
  663. function CFDictionaryGetValue( theDict: CFDictionaryRef; key: {const} UnivPtr ): UnivPtr; external name '_CFDictionaryGetValue';
  664. {!
  665. @function CFDictionaryGetValueIfPresent
  666. Retrieves the value associated with the given key.
  667. @param theDict The dictionary to be queried. If this parameter is
  668. not a valid CFDictionary, the behavior is undefined.
  669. @param key The key for which to find a match in the dictionary. The
  670. hash() and equal() key callbacks provided when the dictionary
  671. was created are used to compare. If the hash() key callback
  672. was NULL, the key is treated as a pointer and converted to
  673. an integer. If the equal() key callback was NULL, pointer
  674. equality (in C, ==) is used. If key, or any of the keys in
  675. the dictionary, are not understood by the equal() callback,
  676. the behavior is undefined.
  677. @param value A pointer to memory which should be filled with the
  678. pointer-sized value if a matching key is found. If no key
  679. match is found, the contents of the storage pointed to by
  680. this parameter are undefined. This parameter may be NULL,
  681. in which case the value from the dictionary is not returned
  682. (but the return value of this function still indicates
  683. whether or not the key-value pair was present).
  684. @result true, if a matching key was found, false otherwise.
  685. }
  686. function CFDictionaryGetValueIfPresent( theDict: CFDictionaryRef; key: {const} UnivPtr; {const} value: UnivPtrPtr ): Boolean; external name '_CFDictionaryGetValueIfPresent';
  687. {!
  688. @function CFDictionaryGetKeysAndValues
  689. Fills the two buffers with the keys and values from the dictionary.
  690. @param theDict The dictionary to be queried. If this parameter is
  691. not a valid CFDictionary, the behavior is undefined.
  692. @param keys A C array of pointer-sized values to be filled with keys
  693. from the dictionary. The keys and values C arrays are parallel
  694. to each other (that is, the items at the same indices form a
  695. key-value pair from the dictionary). This parameter may be NULL
  696. if the keys are not desired. If this parameter is not a valid
  697. pointer to a C array of at least CFDictionaryGetCount() pointers,
  698. or NULL, the behavior is undefined.
  699. @param values A C array of pointer-sized values to be filled with values
  700. from the dictionary. The keys and values C arrays are parallel
  701. to each other (that is, the items at the same indices form a
  702. key-value pair from the dictionary). This parameter may be NULL
  703. if the values are not desired. If this parameter is not a valid
  704. pointer to a C array of at least CFDictionaryGetCount() pointers,
  705. or NULL, the behavior is undefined.
  706. }
  707. procedure CFDictionaryGetKeysAndValues( theDict: CFDictionaryRef; {const} keys: UnivPtrPtr; {const} values: UnivPtrPtr ); external name '_CFDictionaryGetKeysAndValues';
  708. {!
  709. @function CFDictionaryApplyFunction
  710. Calls a function once for each value in the dictionary.
  711. @param theDict The dictionary to be queried. If this parameter is
  712. not a valid CFDictionary, the behavior is undefined.
  713. @param applier The callback function to call once for each value in
  714. the dictionary. If this parameter is not a
  715. pointer to a function of the correct prototype, the behavior
  716. is undefined. If there are keys or values which the
  717. applier function does not expect or cannot properly apply
  718. to, the behavior is undefined.
  719. @param context A pointer-sized user-defined value, which is passed
  720. as the third parameter to the applier function, but is
  721. otherwise unused by this function. If the context is not
  722. what is expected by the applier function, the behavior is
  723. undefined.
  724. }
  725. procedure CFDictionaryApplyFunction( theDict: CFDictionaryRef; applier: CFDictionaryApplierFunction; context: UnivPtr ); external name '_CFDictionaryApplyFunction';
  726. {!
  727. @function CFDictionaryAddValue
  728. Adds the key-value pair to the dictionary if no such key already exists.
  729. @param theDict The dictionary to which the value is to be added. If this
  730. parameter is not a valid mutable CFDictionary, the behavior is
  731. undefined.
  732. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  733. If the dictionary is a fixed-capacity dictionary and
  734. it is full before this operation, the behavior is undefined.
  735. #endif
  736. @param key The key of the value to add to the dictionary. The key is
  737. retained by the dictionary using the retain callback provided
  738. when the dictionary was created. If the key is not of the sort
  739. expected by the retain callback, the behavior is undefined. If
  740. a key which matches this key is already present in the dictionary,
  741. this function does nothing ("add if absent").
  742. @param value The value to add to the dictionary. The value is retained
  743. by the dictionary using the retain callback provided when the
  744. dictionary was created. If the value is not of the sort expected
  745. by the retain callback, the behavior is undefined.
  746. }
  747. procedure CFDictionaryAddValue( theDict: CFMutableDictionaryRef; key: {const} UnivPtr; value: {const} UnivPtr ); external name '_CFDictionaryAddValue';
  748. {!
  749. @function CFDictionarySetValue
  750. Sets the value of the key in the dictionary.
  751. @param theDict The dictionary to which the value is to be set. If this
  752. parameter is not a valid mutable CFDictionary, the behavior is
  753. undefined.
  754. #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
  755. If the dictionary is a fixed-capacity dictionary and
  756. it is full before this operation, and the key does not exist in
  757. the dictionary, the behavior is undefined.
  758. #endif
  759. @param key The key of the value to set into the dictionary. If a key
  760. which matches this key is already present in the dictionary, only
  761. the value is changed ("add if absent, replace if present"). If
  762. no key matches the given key, the key-value pair is added to the
  763. dictionary. If added, the key is retained by the dictionary,
  764. using the retain callback provided
  765. when the dictionary was created. If the key is not of the sort
  766. expected by the key retain callback, the behavior is undefined.
  767. @param value The value to add to or replace into the dictionary. The value
  768. is retained by the dictionary using the retain callback provided
  769. when the dictionary was created, and the previous value if any is
  770. released. If the value is not of the sort expected by the
  771. retain or release callbacks, the behavior is undefined.
  772. }
  773. procedure CFDictionarySetValue( theDict: CFMutableDictionaryRef; key: {const} UnivPtr; value: {const} UnivPtr ); external name '_CFDictionarySetValue';
  774. {!
  775. @function CFDictionaryReplaceValue
  776. Replaces the value of the key in the dictionary.
  777. @param theDict The dictionary to which the value is to be replaced. If this
  778. parameter is not a valid mutable CFDictionary, the behavior is
  779. undefined.
  780. @param key The key of the value to replace in the dictionary. If a key
  781. which matches this key is present in the dictionary, the value
  782. is changed to the given value, otherwise this function does
  783. nothing ("replace if present").
  784. @param value The value to replace into the dictionary. The value
  785. is retained by the dictionary using the retain callback provided
  786. when the dictionary was created, and the previous value is
  787. released. If the value is not of the sort expected by the
  788. retain or release callbacks, the behavior is undefined.
  789. }
  790. procedure CFDictionaryReplaceValue( theDict: CFMutableDictionaryRef; key: {const} UnivPtr; value: {const} UnivPtr ); external name '_CFDictionaryReplaceValue';
  791. {!
  792. @function CFDictionaryRemoveValue
  793. Removes the value of the key from the dictionary.
  794. @param theDict The dictionary from which the value is to be removed. If this
  795. parameter is not a valid mutable CFDictionary, the behavior is
  796. undefined.
  797. @param key The key of the value to remove from the dictionary. If a key
  798. which matches this key is present in the dictionary, the key-value
  799. pair is removed from the dictionary, otherwise this function does
  800. nothing ("remove if present").
  801. }
  802. procedure CFDictionaryRemoveValue( theDict: CFMutableDictionaryRef; key: {const} UnivPtr ); external name '_CFDictionaryRemoveValue';
  803. {!
  804. @function CFDictionaryRemoveAllValues
  805. Removes all the values from the dictionary, making it empty.
  806. @param theDict The dictionary from which all of the values are to be
  807. removed. If this parameter is not a valid mutable
  808. CFDictionary, the behavior is undefined.
  809. }
  810. procedure CFDictionaryRemoveAllValues( theDict: CFMutableDictionaryRef ); external name '_CFDictionaryRemoveAllValues';
  811. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  812. end.
  813. {$endc} {not MACOSALLINCLUDE}