CFDictionary.pas 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. { CFDictionary.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 CFDictionary;
  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;
  86. {$ALIGN POWER}
  87. {!
  88. @header CFDictionary
  89. CFDictionary implements a container which pairs pointer-sized keys
  90. with pointer-sized values. Values are accessed via arbitrary
  91. user-defined keys. A CFDictionary differs from a CFArray in that
  92. the key used to access a particular value in the dictionary remains
  93. the same as values are added to or removed from the dictionary,
  94. unless a value associated with its particular key is replaced or
  95. removed. In a CFArray, the key (or index) used to retrieve a
  96. particular value can change over time as values are added to or
  97. deleted from the array. Also unlike an array, there is no ordering
  98. among values in a dictionary. To enable later retrieval of a value,
  99. the key of the key-value pair should be constant (or treated as
  100. constant); if the key changes after being used to put a value in
  101. the dictionary, the value may not be retrievable. The keys of a
  102. dictionary form a set; that is, no two keys which are equal to
  103. one another are present in the dictionary at any time.
  104. Dictionaries come in two flavors, immutable, which cannot have
  105. values added to them or removed from them after the dictionary is
  106. created, and mutable, to which you can add values or from which
  107. remove values. Mutable dictionaries have two subflavors,
  108. fixed-capacity, for which there is a maximum number set at creation
  109. time of values which can be put into the dictionary, and variable
  110. capacity, which can have an unlimited number of values (or rather,
  111. limited only by constraints external to CFDictionary, like the
  112. amount of available memory). Fixed-capacity dictionaries can be
  113. somewhat higher performing, if you can put a definate upper limit
  114. on the number of values that might be put into the dictionary.
  115. As with all CoreFoundation collection types, dictionaries maintain
  116. hard references on the values you put in them, but the retaining and
  117. releasing functions are user-defined callbacks that can actually do
  118. whatever the user wants (for example, nothing).
  119. Although a particular implementation of CFDictionary may not use
  120. hashing and a hash table for storage of the values, the keys have
  121. a hash-code generating function defined for them, and a function
  122. to test for equality of two keys. These two functions together
  123. must maintain the invariant that if equal(X, Y), then hash(X) ==
  124. hash(Y). Note that the converse will not generally be true (but
  125. the contrapositive, if hash(X) != hash(Y), then !equal(X, Y),
  126. will be as required by Boolean logic). If the hash() and equal()
  127. key callbacks are NULL, the key is used as a pointer-sized integer,
  128. and pointer equality is used. Care should be taken to provide a
  129. hash() callback which will compute sufficiently dispersed hash
  130. codes for the key set for best performance.
  131. Computational Complexity
  132. The access time for a value in the dictionary is guaranteed to be at
  133. worst O(lg N) for any implementation, current and future, but will
  134. often be O(1) (constant time). Insertion or deletion operations
  135. will typically be constant time as well, but are O(N*lg N) in the
  136. worst case in some implementations. Access of values through a key
  137. is faster than accessing values directly (if there are any such
  138. operations). Dictionaries will tend to use significantly more memory
  139. than a array with the same number of values.
  140. }
  141. {!
  142. @typedef CFDictionaryKeyCallBacks
  143. Structure containing the callbacks for keys of a CFDictionary.
  144. @field version The version number of the structure type being passed
  145. in as a parameter to the CFDictionary creation functions.
  146. This structure is version 0.
  147. @field retain The callback used to add a retain for the dictionary
  148. on keys as they are used to put values into the dictionary.
  149. This callback returns the value to use as the key in the
  150. dictionary, which is usually the value parameter passed to
  151. this callback, but may be a different value if a different
  152. value should be used as the key. The dictionary's allocator
  153. is passed as the first argument.
  154. @field release The callback used to remove a retain previously added
  155. for the dictionary from keys as their values are removed from
  156. the dictionary. The dictionary's allocator is passed as the
  157. first argument.
  158. @field copyDescription The callback used to create a descriptive
  159. string representation of each key in the dictionary. This
  160. is used by the CFCopyDescription() function.
  161. @field equal The callback used to compare keys in the dictionary for
  162. equality.
  163. @field hash The callback used to compute a hash code for keys as they
  164. are used to access, add, or remove values in the dictionary.
  165. }
  166. type
  167. CFDictionaryRetainCallBack = function( allocator: CFAllocatorRef; value: {const} UnivPtr ): UnivPtr;
  168. CFDictionaryReleaseCallBack = procedure( allocator: CFAllocatorRef; value: {const} UnivPtr );
  169. CFDictionaryCopyDescriptionCallBack = function( value: {const} UnivPtr ): CFStringRef;
  170. CFDictionaryEqualCallBack = function( value1: {const} UnivPtr; value2: {const} UnivPtr ): Boolean;
  171. CFDictionaryHashCallBack = function( value: {const} UnivPtr ): CFHashCode;
  172. CFDictionaryKeyCallBacks = record
  173. version: CFIndex;
  174. retain: CFDictionaryRetainCallBack;
  175. release: CFDictionaryReleaseCallBack;
  176. copyDescription: CFDictionaryCopyDescriptionCallBack;
  177. equal: CFDictionaryEqualCallBack;
  178. hash: CFDictionaryHashCallBack;
  179. end;
  180. CFDictionaryKeyCallBacksPtr = ^CFDictionaryKeyCallBacks;
  181. {!
  182. @constant kCFTypeDictionaryKeyCallBacks
  183. Predefined CFDictionaryKeyCallBacks structure containing a
  184. set of callbacks appropriate for use when the keys of a
  185. CFDictionary are all CFTypes.
  186. }
  187. var kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; external name '_kCFTypeDictionaryKeyCallBacks'; (* attribute const *)
  188. {!
  189. @constant kCFCopyStringDictionaryKeyCallBacks
  190. Predefined CFDictionaryKeyCallBacks structure containing a
  191. set of callbacks appropriate for use when the keys of a
  192. CFDictionary are all CFStrings, which may be mutable and
  193. need to be copied in order to serve as constant keys for
  194. the values in the dictionary.
  195. }
  196. var kCFCopyStringDictionaryKeyCallBacks: CFDictionaryKeyCallBacks; external name '_kCFCopyStringDictionaryKeyCallBacks'; (* attribute const *)
  197. {!
  198. @typedef CFDictionaryValueCallBacks
  199. Structure containing the callbacks for values of a CFDictionary.
  200. @field version The version number of the structure type being passed
  201. in as a parameter to the CFDictionary creation functions.
  202. This structure is version 0.
  203. @field retain The callback used to add a retain for the dictionary
  204. on values as they are put into the dictionary.
  205. This callback returns the value to use as the value in the
  206. dictionary, which is usually the value parameter passed to
  207. this callback, but may be a different value if a different
  208. value should be added to the dictionary. The dictionary's
  209. allocator is passed as the first argument.
  210. @field release The callback used to remove a retain previously added
  211. for the dictionary from values as they are removed from
  212. the dictionary. The dictionary's allocator is passed as the
  213. first argument.
  214. @field copyDescription The callback used to create a descriptive
  215. string representation of each value in the dictionary. This
  216. is used by the CFCopyDescription() function.
  217. @field equal The callback used to compare values in the dictionary for
  218. equality in some operations.
  219. }
  220. type
  221. CFDictionaryValueCallBacks = record
  222. version: CFIndex;
  223. retain: CFDictionaryRetainCallBack;
  224. release: CFDictionaryReleaseCallBack;
  225. copyDescription: CFDictionaryCopyDescriptionCallBack;
  226. equal: CFDictionaryEqualCallBack;
  227. end;
  228. CFDictionaryValueCallBacksPtr = ^CFDictionaryValueCallBacks;
  229. {!
  230. @constant kCFTypeDictionaryValueCallBacks
  231. Predefined CFDictionaryValueCallBacks structure containing a set
  232. of callbacks appropriate for use when the values in a CFDictionary
  233. are all CFTypes.
  234. }
  235. var kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks; external name '_kCFTypeDictionaryValueCallBacks'; (* attribute const *)
  236. {!
  237. @typedef CFDictionaryApplierFunction
  238. Type of the callback function used by the apply functions of
  239. CFDictionarys.
  240. @param key The current key for the value.
  241. @param value The current value from the dictionary.
  242. @param context The user-defined context parameter given to the apply
  243. function.
  244. }
  245. type
  246. CFDictionaryApplierFunction = procedure( key: {const} UnivPtr; value: {const} UnivPtr; context: UnivPtr );
  247. {!
  248. @typedef CFDictionaryRef
  249. This is the type of a reference to immutable CFDictionarys.
  250. }
  251. type
  252. CFDictionaryRef = ^SInt32; { an opaque 32-bit type }
  253. CFDictionaryRefPtr = ^CFDictionaryRef;
  254. {!
  255. @typedef CFMutableDictionaryRef
  256. This is the type of a reference to mutable CFDictionarys.
  257. }
  258. type
  259. CFMutableDictionaryRef = CFDictionaryRef;
  260. CFMutableDictionaryRefPtr = ^CFMutableDictionaryRef;
  261. {!
  262. @function CFDictionaryGetTypeID
  263. Returns the type identifier of all CFDictionary instances.
  264. }
  265. function CFDictionaryGetTypeID: CFTypeID; external name '_CFDictionaryGetTypeID';
  266. {!
  267. @function CFDictionaryCreate
  268. Creates a new immutable dictionary with the given values.
  269. @param allocator The CFAllocator which should be used to allocate
  270. memory for the dictionary and its storage for values. This
  271. parameter may be NULL in which case the current default
  272. CFAllocator is used. If this reference is not a valid
  273. CFAllocator, the behavior is undefined.
  274. @param keys A C array of the pointer-sized keys to be used for
  275. the parallel C array of values to be put into the dictionary.
  276. This parameter may be NULL if the numValues parameter is 0.
  277. This C array is not changed or freed by this function. If
  278. this parameter is not a valid pointer to a C array of at
  279. least numValues pointers, the behavior is undefined.
  280. @param values A C array of the pointer-sized values to be in the
  281. dictionary. This parameter may be NULL if the numValues
  282. parameter is 0. This C array is not changed or freed by
  283. this function. If this parameter is not a valid pointer to
  284. a C array of at least numValues pointers, the behavior is
  285. undefined.
  286. @param numValues The number of values to copy from the keys and
  287. values C arrays into the CFDictionary. This number will be
  288. the count of the dictionary. If this parameter is
  289. negative, or greater than the number of values actually
  290. in the keys or values C arrays, the behavior is undefined.
  291. @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure
  292. initialized with the callbacks for the dictionary to use on
  293. each key in the dictionary. The retain callback will be used
  294. within this function, for example, to retain all of the new
  295. keys from the keys C array. A copy of the contents of the
  296. callbacks structure is made, so that a pointer to a structure
  297. on the stack can be passed in, or can be reused for multiple
  298. dictionary creations. If the version field of this
  299. callbacks structure is not one of the defined ones for
  300. CFDictionary, the behavior is undefined. The retain field may
  301. be NULL, in which case the CFDictionary will do nothing to add
  302. a retain to the keys of the contained values. The release field
  303. may be NULL, in which case the CFDictionary will do nothing
  304. to remove the dictionary's retain (if any) on the keys when the
  305. dictionary is destroyed or a key-value pair is removed. If the
  306. copyDescription field is NULL, the dictionary will create a
  307. simple description for a key. If the equal field is NULL, the
  308. dictionary will use pointer equality to test for equality of
  309. keys. If the hash field is NULL, a key will be converted from
  310. a pointer to an integer to compute the hash code. This callbacks
  311. parameter itself may be NULL, which is treated as if a valid
  312. structure of version 0 with all fields NULL had been passed in.
  313. Otherwise, if any of the fields are not valid pointers to
  314. functions of the correct type, or this parameter is not a
  315. valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
  316. the behavior is undefined. If any of the keys put into the
  317. dictionary is not one understood by one of the callback functions
  318. the behavior when that callback function is used is undefined.
  319. @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure
  320. initialized with the callbacks for the dictionary to use on
  321. each value in the dictionary. The retain callback will be used
  322. within this function, for example, to retain all of the new
  323. values from the values C array. A copy of the contents of the
  324. callbacks structure is made, so that a pointer to a structure
  325. on the stack can be passed in, or can be reused for multiple
  326. dictionary creations. If the version field of this callbacks
  327. structure is not one of the defined ones for CFDictionary, the
  328. behavior is undefined. The retain field may be NULL, in which
  329. case the CFDictionary will do nothing to add a retain to values
  330. as they are put into the dictionary. The release field may be
  331. NULL, in which case the CFDictionary will do nothing to remove
  332. the dictionary's retain (if any) on the values when the
  333. dictionary is destroyed or a key-value pair is removed. If the
  334. copyDescription field is NULL, the dictionary will create a
  335. simple description for a value. If the equal field is NULL, the
  336. dictionary will use pointer equality to test for equality of
  337. values. This callbacks parameter itself may be NULL, which is
  338. treated as if a valid structure of version 0 with all fields
  339. NULL had been passed in. Otherwise,
  340. if any of the fields are not valid pointers to functions
  341. of the correct type, or this parameter is not a valid
  342. pointer to a CFDictionaryValueCallBacks callbacks structure,
  343. the behavior is undefined. If any of the values put into the
  344. dictionary is not one understood by one of the callback functions
  345. the behavior when that callback function is used is undefined.
  346. @result A reference to the new immutable CFDictionary.
  347. }
  348. 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';
  349. {!
  350. @function CFDictionaryCreateCopy
  351. Creates a new immutable dictionary with the key-value pairs from
  352. the given dictionary.
  353. @param allocator The CFAllocator which should be used to allocate
  354. memory for the dictionary and its storage for values. This
  355. parameter may be NULL in which case the current default
  356. CFAllocator is used. If this reference is not a valid
  357. CFAllocator, the behavior is undefined.
  358. @param theDict The dictionary which is to be copied. The keys and values
  359. from the dictionary are copied as pointers into the new
  360. dictionary (that is, the values themselves are copied, not
  361. that which the values point to, if anything). However, the
  362. keys and values are also retained by the new dictionary using
  363. the retain function of the original dictionary.
  364. The count of the new dictionary will be the same as the
  365. given dictionary. The new dictionary uses the same callbacks
  366. as the dictionary to be copied. If this parameter is
  367. not a valid CFDictionary, the behavior is undefined.
  368. @result A reference to the new immutable CFDictionary.
  369. }
  370. function CFDictionaryCreateCopy( allocator: CFAllocatorRef; theDict: CFDictionaryRef ): CFDictionaryRef; external name '_CFDictionaryCreateCopy';
  371. {!
  372. @function CFDictionaryCreateMutable
  373. Creates a new mutable dictionary.
  374. @param allocator The CFAllocator which should be used to allocate
  375. memory for the dictionary and its storage for values. This
  376. parameter may be NULL in which case the current default
  377. CFAllocator is used. If this reference is not a valid
  378. CFAllocator, the behavior is undefined.
  379. @param capacity The maximum number of values that can be contained by
  380. the CFDictionary. The dictionary starts empty, and can grow
  381. to this number of values (and it can have less). If this
  382. parameter is 0, the dictionary's maximum capacity is unlimited
  383. (or rather, only limited by address space and available memory
  384. constraints). If this parameter is negative, the behavior is
  385. undefined.
  386. @param keyCallBacks A pointer to a CFDictionaryKeyCallBacks structure
  387. initialized with the callbacks for the dictionary to use on
  388. each key in the dictionary. A copy of the contents of the
  389. callbacks structure is made, so that a pointer to a structure
  390. on the stack can be passed in, or can be reused for multiple
  391. dictionary creations. If the version field of this
  392. callbacks structure is not one of the defined ones for
  393. CFDictionary, the behavior is undefined. The retain field may
  394. be NULL, in which case the CFDictionary will do nothing to add
  395. a retain to the keys of the contained values. The release field
  396. may be NULL, in which case the CFDictionary will do nothing
  397. to remove the dictionary's retain (if any) on the keys when the
  398. dictionary is destroyed or a key-value pair is removed. If the
  399. copyDescription field is NULL, the dictionary will create a
  400. simple description for a key. If the equal field is NULL, the
  401. dictionary will use pointer equality to test for equality of
  402. keys. If the hash field is NULL, a key will be converted from
  403. a pointer to an integer to compute the hash code. This callbacks
  404. parameter itself may be NULL, which is treated as if a valid
  405. structure of version 0 with all fields NULL had been passed in.
  406. Otherwise, if any of the fields are not valid pointers to
  407. functions of the correct type, or this parameter is not a
  408. valid pointer to a CFDictionaryKeyCallBacks callbacks structure,
  409. the behavior is undefined. If any of the keys put into the
  410. dictionary is not one understood by one of the callback functions
  411. the behavior when that callback function is used is undefined.
  412. @param valueCallBacks A pointer to a CFDictionaryValueCallBacks structure
  413. initialized with the callbacks for the dictionary to use on
  414. each value in the dictionary. The retain callback will be used
  415. within this function, for example, to retain all of the new
  416. values from the values C array. A copy of the contents of the
  417. callbacks structure is made, so that a pointer to a structure
  418. on the stack can be passed in, or can be reused for multiple
  419. dictionary creations. If the version field of this callbacks
  420. structure is not one of the defined ones for CFDictionary, the
  421. behavior is undefined. The retain field may be NULL, in which
  422. case the CFDictionary will do nothing to add a retain to values
  423. as they are put into the dictionary. The release field may be
  424. NULL, in which case the CFDictionary will do nothing to remove
  425. the dictionary's retain (if any) on the values when the
  426. dictionary is destroyed or a key-value pair is removed. If the
  427. copyDescription field is NULL, the dictionary will create a
  428. simple description for a value. If the equal field is NULL, the
  429. dictionary will use pointer equality to test for equality of
  430. values. This callbacks parameter itself may be NULL, which is
  431. treated as if a valid structure of version 0 with all fields
  432. NULL had been passed in. Otherwise,
  433. if any of the fields are not valid pointers to functions
  434. of the correct type, or this parameter is not a valid
  435. pointer to a CFDictionaryValueCallBacks callbacks structure,
  436. the behavior is undefined. If any of the values put into the
  437. dictionary is not one understood by one of the callback functions
  438. the behavior when that callback function is used is undefined.
  439. @result A reference to the new mutable CFDictionary.
  440. }
  441. function CFDictionaryCreateMutable( allocator: CFAllocatorRef; capacity: CFIndex; {const} keyCallBacks: CFDictionaryKeyCallBacksPtr { can be NULL }; {const} valueCallBacks: CFDictionaryValueCallBacksPtr { can be NULL } ): CFMutableDictionaryRef; external name '_CFDictionaryCreateMutable';
  442. {!
  443. @function CFDictionaryCreateMutableCopy
  444. Creates a new mutable dictionary with the key-value pairs from
  445. the given dictionary.
  446. @param allocator The CFAllocator which should be used to allocate
  447. memory for the dictionary and its storage for values. This
  448. parameter may be NULL in which case the current default
  449. CFAllocator is used. If this reference is not a valid
  450. CFAllocator, the behavior is undefined.
  451. @param capacity The maximum number of values that can be contained
  452. by the CFDictionary. The dictionary starts empty, and can grow
  453. to this number of values (and it can have less). If this
  454. parameter is 0, the dictionary's maximum capacity is unlimited
  455. (or rather, only limited by address space and available memory
  456. constraints). This parameter must be greater than or equal
  457. to the count of the dictionary which is to be copied, or the
  458. behavior is undefined. If this parameter is negative, the
  459. behavior is undefined.
  460. @param theDict The dictionary which is to be copied. The keys and values
  461. from the dictionary are copied as pointers into the new
  462. dictionary (that is, the values themselves are copied, not
  463. that which the values point to, if anything). However, the
  464. keys and values are also retained by the new dictionary using
  465. the retain function of the original dictionary.
  466. The count of the new dictionary will be the same as the
  467. given dictionary. The new dictionary uses the same callbacks
  468. as the dictionary to be copied. If this parameter is
  469. not a valid CFDictionary, the behavior is undefined.
  470. @result A reference to the new mutable CFDictionary.
  471. }
  472. function CFDictionaryCreateMutableCopy( allocator: CFAllocatorRef; capacity: CFIndex; theDict: CFDictionaryRef ): CFMutableDictionaryRef; external name '_CFDictionaryCreateMutableCopy';
  473. {!
  474. @function CFDictionaryGetCount
  475. Returns the number of values currently in the dictionary.
  476. @param theDict The dictionary to be queried. If this parameter is
  477. not a valid CFDictionary, the behavior is undefined.
  478. @result The number of values in the dictionary.
  479. }
  480. function CFDictionaryGetCount( theDict: CFDictionaryRef ): CFIndex; external name '_CFDictionaryGetCount';
  481. {!
  482. @function CFDictionaryGetCountOfKey
  483. Counts the number of times the given key occurs in the dictionary.
  484. @param theDict The dictionary to be searched. If this parameter is
  485. not a valid CFDictionary, the behavior is undefined.
  486. @param key The key for which to find matches in the dictionary. The
  487. hash() and equal() key callbacks provided when the dictionary
  488. was created are used to compare. If the hash() key callback
  489. was NULL, the key is treated as a pointer and converted to
  490. an integer. If the equal() key callback was NULL, pointer
  491. equality (in C, ==) is used. If key, or any of the keys in
  492. the dictionary, are not understood by the equal() callback,
  493. the behavior is undefined.
  494. @result Returns 1 if a matching key is used by the dictionary,
  495. 0 otherwise.
  496. }
  497. function CFDictionaryGetCountOfKey( theDict: CFDictionaryRef; key: {const} UnivPtr ): CFIndex; external name '_CFDictionaryGetCountOfKey';
  498. {!
  499. @function CFDictionaryGetCountOfValue
  500. Counts the number of times the given value occurs in the dictionary.
  501. @param theDict The dictionary to be searched. If this parameter is
  502. not a valid CFDictionary, the behavior is undefined.
  503. @param value The value for which to find matches in the dictionary. The
  504. equal() callback provided when the dictionary was created is
  505. used to compare. If the equal() value callback was NULL, pointer
  506. equality (in C, ==) is used. If value, or any of the values in
  507. the dictionary, are not understood by the equal() callback,
  508. the behavior is undefined.
  509. @result The number of times the given value occurs in the dictionary.
  510. }
  511. function CFDictionaryGetCountOfValue( theDict: CFDictionaryRef; value: {const} UnivPtr ): CFIndex; external name '_CFDictionaryGetCountOfValue';
  512. {!
  513. @function CFDictionaryContainsKey
  514. Reports whether or not the key is in the dictionary.
  515. @param theDict The dictionary to be searched. If this parameter is
  516. not a valid CFDictionary, the behavior is undefined.
  517. @param key The key for which to find matches in the dictionary. The
  518. hash() and equal() key callbacks provided when the dictionary
  519. was created are used to compare. If the hash() key callback
  520. was NULL, the key is treated as a pointer and converted to
  521. an integer. If the equal() key callback was NULL, pointer
  522. equality (in C, ==) is used. If key, or any of the keys in
  523. the dictionary, are not understood by the equal() callback,
  524. the behavior is undefined.
  525. @result true, if the key is in the dictionary, otherwise false.
  526. }
  527. function CFDictionaryContainsKey( theDict: CFDictionaryRef; key: {const} UnivPtr ): Boolean; external name '_CFDictionaryContainsKey';
  528. {!
  529. @function CFDictionaryContainsValue
  530. Reports whether or not the value is in the dictionary.
  531. @param theDict The dictionary to be searched. If this parameter is
  532. not a valid CFDictionary, the behavior is undefined.
  533. @param value The value for which to find matches in the dictionary. The
  534. equal() callback provided when the dictionary was created is
  535. used to compare. If the equal() callback was NULL, pointer
  536. equality (in C, ==) is used. If value, or any of the values
  537. in the dictionary, are not understood by the equal() callback,
  538. the behavior is undefined.
  539. @result true, if the value is in the dictionary, otherwise false.
  540. }
  541. function CFDictionaryContainsValue( theDict: CFDictionaryRef; value: {const} UnivPtr ): Boolean; external name '_CFDictionaryContainsValue';
  542. {!
  543. @function CFDictionaryGetValue
  544. Retrieves the value associated with the given key.
  545. @param theDict The dictionary to be queried. If this parameter is
  546. not a valid CFDictionary, the behavior is undefined.
  547. @param key The key for which to find a match in the dictionary. The
  548. hash() and equal() key callbacks provided when the dictionary
  549. was created are used to compare. If the hash() key callback
  550. was NULL, the key is treated as a pointer and converted to
  551. an integer. If the equal() key callback was NULL, pointer
  552. equality (in C, ==) is used. If key, or any of the keys in
  553. the dictionary, are not understood by the equal() callback,
  554. the behavior is undefined.
  555. @result The value with the given key in the dictionary, or NULL if
  556. no key-value pair with a matching key exists. Since NULL
  557. can be a valid value in some dictionaries, the function
  558. CFDictionaryGetValueIfPresent() must be used to distinguish
  559. NULL-no-found from NULL-is-the-value.
  560. }
  561. function CFDictionaryGetValue( theDict: CFDictionaryRef; key: {const} UnivPtr ): UnivPtr; external name '_CFDictionaryGetValue';
  562. {!
  563. @function CFDictionaryGetValueIfPresent
  564. Retrieves the value associated with the given key.
  565. @param theDict The dictionary to be queried. If this parameter is
  566. not a valid CFDictionary, the behavior is undefined.
  567. @param key The key for which to find a match in the dictionary. The
  568. hash() and equal() key callbacks provided when the dictionary
  569. was created are used to compare. If the hash() key callback
  570. was NULL, the key is treated as a pointer and converted to
  571. an integer. If the equal() key callback was NULL, pointer
  572. equality (in C, ==) is used. If key, or any of the keys in
  573. the dictionary, are not understood by the equal() callback,
  574. the behavior is undefined.
  575. @param value A pointer to memory which should be filled with the
  576. pointer-sized value if a matching key is found. If no key
  577. match is found, the contents of the storage pointed to by
  578. this parameter are undefined. This parameter may be NULL,
  579. in which case the value from the dictionary is not returned
  580. (but the return value of this function still indicates
  581. whether or not the key-value pair was present).
  582. @result true, if a matching key was found, false otherwise.
  583. }
  584. function CFDictionaryGetValueIfPresent( theDict: CFDictionaryRef; key: {const} UnivPtr; {const} value: UnivPtrPtr ): Boolean; external name '_CFDictionaryGetValueIfPresent';
  585. {!
  586. @function CFDictionaryGetKeysAndValues
  587. Fills the two buffers with the keys and values from the dictionary.
  588. @param theDict The dictionary to be queried. If this parameter is
  589. not a valid CFDictionary, the behavior is undefined.
  590. @param keys A C array of pointer-sized values to be filled with keys
  591. from the dictionary. The keys and values C arrays are parallel
  592. to each other (that is, the items at the same indices form a
  593. key-value pair from the dictionary). This parameter may be NULL
  594. if the keys are not desired. If this parameter is not a valid
  595. pointer to a C array of at least CFDictionaryGetCount() pointers,
  596. or NULL, the behavior is undefined.
  597. @param values A C array of pointer-sized values to be filled with values
  598. from the dictionary. The keys and values C arrays are parallel
  599. to each other (that is, the items at the same indices form a
  600. key-value pair from the dictionary). This parameter may be NULL
  601. if the values are not desired. If this parameter is not a valid
  602. pointer to a C array of at least CFDictionaryGetCount() pointers,
  603. or NULL, the behavior is undefined.
  604. }
  605. procedure CFDictionaryGetKeysAndValues( theDict: CFDictionaryRef; {const} keys: UnivPtrPtr; {const} values: UnivPtrPtr ); external name '_CFDictionaryGetKeysAndValues';
  606. {!
  607. @function CFDictionaryApplyFunction
  608. Calls a function once for each value in the dictionary.
  609. @param theDict The dictionary to be queried. If this parameter is
  610. not a valid CFDictionary, the behavior is undefined.
  611. @param applier The callback function to call once for each value in
  612. the dictionary. If this parameter is not a
  613. pointer to a function of the correct prototype, the behavior
  614. is undefined. If there are keys or values which the
  615. applier function does not expect or cannot properly apply
  616. to, the behavior is undefined.
  617. @param context A pointer-sized user-defined value, which is passed
  618. as the third parameter to the applier function, but is
  619. otherwise unused by this function. If the context is not
  620. what is expected by the applier function, the behavior is
  621. undefined.
  622. }
  623. procedure CFDictionaryApplyFunction( theDict: CFDictionaryRef; applier: CFDictionaryApplierFunction; context: UnivPtr ); external name '_CFDictionaryApplyFunction';
  624. {!
  625. @function CFDictionaryAddValue
  626. Adds the key-value pair to the dictionary if no such key already exists.
  627. @param theDict The dictionary to which the value is to be added. If this
  628. parameter is not a valid mutable CFDictionary, the behavior is
  629. undefined. If the dictionary is a fixed-capacity dictionary and
  630. it is full before this operation, the behavior is undefined.
  631. @param key The key of the value to add to the dictionary. The key is
  632. retained by the dictionary using the retain callback provided
  633. when the dictionary was created. If the key is not of the sort
  634. expected by the retain callback, the behavior is undefined. If
  635. a key which matches this key is already present in the dictionary,
  636. this function does nothing ("add if absent").
  637. @param value The value to add to the dictionary. The value is retained
  638. by the dictionary using the retain callback provided when the
  639. dictionary was created. If the value is not of the sort expected
  640. by the retain callback, the behavior is undefined.
  641. }
  642. procedure CFDictionaryAddValue( theDict: CFMutableDictionaryRef; key: {const} UnivPtr; value: {const} UnivPtr ); external name '_CFDictionaryAddValue';
  643. {!
  644. @function CFDictionarySetValue
  645. Sets the value of the key in the dictionary.
  646. @param theDict The dictionary to which the value is to be set. If this
  647. parameter is not a valid mutable CFDictionary, the behavior is
  648. undefined. If the dictionary is a fixed-capacity dictionary and
  649. it is full before this operation, and the key does not exist in
  650. the dictionary, the behavior is undefined.
  651. @param key The key of the value to set into the dictionary. If a key
  652. which matches this key is already present in the dictionary, only
  653. the value is changed ("add if absent, replace if present"). If
  654. no key matches the given key, the key-value pair is added to the
  655. dictionary. If added, the key is retained by the dictionary,
  656. using the retain callback provided
  657. when the dictionary was created. If the key is not of the sort
  658. expected by the key retain callback, the behavior is undefined.
  659. @param value The value to add to or replace into the dictionary. The value
  660. is retained by the dictionary using the retain callback provided
  661. when the dictionary was created, and the previous value if any is
  662. released. If the value is not of the sort expected by the
  663. retain or release callbacks, the behavior is undefined.
  664. }
  665. procedure CFDictionarySetValue( theDict: CFMutableDictionaryRef; key: {const} UnivPtr; value: {const} UnivPtr ); external name '_CFDictionarySetValue';
  666. {!
  667. @function CFDictionaryReplaceValue
  668. Replaces the value of the key in the dictionary.
  669. @param theDict The dictionary to which the value is to be replaced. If this
  670. parameter is not a valid mutable CFDictionary, the behavior is
  671. undefined.
  672. @param key The key of the value to replace in the dictionary. If a key
  673. which matches this key is present in the dictionary, the value
  674. is changed to the given value, otherwise this function does
  675. nothing ("replace if present").
  676. @param value The value to replace into the dictionary. The value
  677. is retained by the dictionary using the retain callback provided
  678. when the dictionary was created, and the previous value is
  679. released. If the value is not of the sort expected by the
  680. retain or release callbacks, the behavior is undefined.
  681. }
  682. procedure CFDictionaryReplaceValue( theDict: CFMutableDictionaryRef; key: {const} UnivPtr; value: {const} UnivPtr ); external name '_CFDictionaryReplaceValue';
  683. {!
  684. @function CFDictionaryRemoveValue
  685. Removes the value of the key from the dictionary.
  686. @param theDict The dictionary from which the value is to be removed. If this
  687. parameter is not a valid mutable CFDictionary, the behavior is
  688. undefined.
  689. @param key The key of the value to remove from the dictionary. If a key
  690. which matches this key is present in the dictionary, the key-value
  691. pair is removed from the dictionary, otherwise this function does
  692. nothing ("remove if present").
  693. }
  694. procedure CFDictionaryRemoveValue( theDict: CFMutableDictionaryRef; key: {const} UnivPtr ); external name '_CFDictionaryRemoveValue';
  695. {!
  696. @function CFDictionaryRemoveAllValues
  697. Removes all the values from the dictionary, making it empty.
  698. @param theDict The dictionary from which all of the values are to be
  699. removed. If this parameter is not a valid mutable
  700. CFDictionary, the behavior is undefined.
  701. }
  702. procedure CFDictionaryRemoveAllValues( theDict: CFMutableDictionaryRef ); external name '_CFDictionaryRemoveAllValues';
  703. end.