CFLocale.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. { CFLocale.h
  2. Copyright (c) 2002-2005, Apple, Inc. All rights reserved.
  3. }
  4. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  5. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, September 2005 }
  6. {
  7. Modified for use with Free Pascal
  8. Version 200
  9. Please report any bugs to <[email protected]>
  10. }
  11. {$mode macpas}
  12. {$packenum 1}
  13. {$macro on}
  14. {$inline on}
  15. {$CALLING MWPASCAL}
  16. unit CFLocale;
  17. interface
  18. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  19. {$setc GAP_INTERFACES_VERSION := $0200}
  20. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  21. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  22. {$endc}
  23. {$ifc defined CPUPOWERPC and defined CPUI386}
  24. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  25. {$endc}
  26. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  27. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  28. {$endc}
  29. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  30. {$setc __ppc__ := 1}
  31. {$elsec}
  32. {$setc __ppc__ := 0}
  33. {$endc}
  34. {$ifc not defined __i386__ and defined CPUI386}
  35. {$setc __i386__ := 1}
  36. {$elsec}
  37. {$setc __i386__ := 0}
  38. {$endc}
  39. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  40. {$error Conflicting definitions for __ppc__ and __i386__}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__}
  43. {$setc TARGET_CPU_PPC := TRUE}
  44. {$setc TARGET_CPU_X86 := FALSE}
  45. {$elifc defined __i386__ and __i386__}
  46. {$setc TARGET_CPU_PPC := FALSE}
  47. {$setc TARGET_CPU_X86 := TRUE}
  48. {$elsec}
  49. {$error Neither __ppc__ nor __i386__ is defined.}
  50. {$endc}
  51. {$setc TARGET_CPU_PPC_64 := FALSE}
  52. {$ifc defined FPC_BIG_ENDIAN}
  53. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  54. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  55. {$elifc defined FPC_LITTLE_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  58. {$elsec}
  59. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  60. {$endc}
  61. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  62. {$setc CALL_NOT_IN_CARBON := FALSE}
  63. {$setc OLDROUTINENAMES := FALSE}
  64. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  65. {$setc OPAQUE_UPP_TYPES := TRUE}
  66. {$setc OTCARBONAPPLICATION := TRUE}
  67. {$setc OTKERNEL := FALSE}
  68. {$setc PM_USE_SESSION_APIS := TRUE}
  69. {$setc TARGET_API_MAC_CARBON := TRUE}
  70. {$setc TARGET_API_MAC_OS8 := FALSE}
  71. {$setc TARGET_API_MAC_OSX := TRUE}
  72. {$setc TARGET_CARBON := TRUE}
  73. {$setc TARGET_CPU_68K := FALSE}
  74. {$setc TARGET_CPU_MIPS := FALSE}
  75. {$setc TARGET_CPU_SPARC := FALSE}
  76. {$setc TARGET_OS_MAC := TRUE}
  77. {$setc TARGET_OS_UNIX := FALSE}
  78. {$setc TARGET_OS_WIN32 := FALSE}
  79. {$setc TARGET_RT_MAC_68881 := FALSE}
  80. {$setc TARGET_RT_MAC_CFM := FALSE}
  81. {$setc TARGET_RT_MAC_MACHO := TRUE}
  82. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  83. {$setc TYPE_BOOL := FALSE}
  84. {$setc TYPE_EXTENDED := FALSE}
  85. {$setc TYPE_LONGLONG := TRUE}
  86. uses MacTypes,CFBase,CFArray,CFDictionary;
  87. {$ALIGN POWER}
  88. {#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3}
  89. type
  90. CFLocaleRef = ^SInt32; { an opaque 32-bit type }
  91. function CFLocaleGetTypeID: CFTypeID; external name '_CFLocaleGetTypeID';
  92. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  93. function CFLocaleGetSystem: CFLocaleRef; external name '_CFLocaleGetSystem';
  94. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  95. // Returns the "root", canonical locale. Contains fixed "backstop" settings.
  96. function CFLocaleCopyCurrent: CFLocaleRef; external name '_CFLocaleCopyCurrent';
  97. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  98. // Returns the logical "user" locale for the current user.
  99. // [This is Copy in the sense that you get a retain you have to release,
  100. // but we may return the same cached object over and over.] Settings
  101. // you get from this locale do not change under you as CFPreferences
  102. // are changed (for safety and correctness). Generally you would not
  103. // grab this and hold onto it forever, but use it to do the operations
  104. // you need to do at the moment, then throw it away. (The non-changing
  105. // ensures that all the results of your operations are consistent.)
  106. function CFLocaleCopyAvailableLocaleIdentifiers: CFArrayRef; external name '_CFLocaleCopyAvailableLocaleIdentifiers';
  107. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  108. // Returns an array of CFStrings that represents all locales for
  109. // which locale data is available.
  110. function CFLocaleCopyISOLanguageCodes: CFArrayRef; external name '_CFLocaleCopyISOLanguageCodes';
  111. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  112. // Returns an array of CFStrings that represents all known legal ISO
  113. // language codes. Note: many of these will not have any supporting
  114. // locale data in Mac OS X.
  115. function CFLocaleCopyISOCountryCodes: CFArrayRef; external name '_CFLocaleCopyISOCountryCodes';
  116. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  117. // Returns an array of CFStrings that represents all known legal ISO
  118. // country codes. Note: many of these will not have any supporting
  119. // locale data in Mac OS X.
  120. function CFLocaleCopyISOCurrencyCodes: CFArrayRef; external name '_CFLocaleCopyISOCurrencyCodes';
  121. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  122. // Returns an array of CFStrings that represents all known legal ISO
  123. // currency codes. Note: some of these may not have any supporting
  124. // locale data in Mac OS X.
  125. function CFLocaleCreateCanonicalLanguageIdentifierFromString( allocator: CFAllocatorRef; localeIdentifier: CFStringRef ): CFStringRef; external name '_CFLocaleCreateCanonicalLanguageIdentifierFromString';
  126. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  127. // Map an arbitrary locale identification string (something close at
  128. // least) to a canonical language-only identifier.
  129. function CFLocaleCreateCanonicalLocaleIdentifierFromString( allocator: CFAllocatorRef; localeIdentifier: CFStringRef ): CFStringRef; external name '_CFLocaleCreateCanonicalLocaleIdentifierFromString';
  130. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  131. // Map an arbitrary locale identification string (something close at
  132. // least) to the canonical identifier.
  133. function CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes( allocator: CFAllocatorRef; lcode: LangCode; rcode: RegionCode ): CFStringRef; external name '_CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes';
  134. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  135. // Map a Mac OS LangCode and RegionCode to the canonical locale identifier.
  136. function CFLocaleCreateComponentsFromLocaleIdentifier( allocator: CFAllocatorRef; localeID: CFStringRef ): CFDictionaryRef; external name '_CFLocaleCreateComponentsFromLocaleIdentifier';
  137. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  138. // Parses a locale ID consisting of language, script, country, variant,
  139. // and keyword/value pairs into a dictionary. The keys are the constant
  140. // CFStrings corresponding to the locale ID components, and the values
  141. // will correspond to constants where available.
  142. // Example: "en_US@calendar=japanese" yields a dictionary with three
  143. // entries: kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US, and
  144. // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar.
  145. function CFLocaleCreateLocaleIdentifierFromComponents( allocator: CFAllocatorRef; dictionary: CFDictionaryRef ): CFStringRef; external name '_CFLocaleCreateLocaleIdentifierFromComponents';
  146. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  147. // Reverses the actions of CFLocaleCreateDictionaryFromLocaleIdentifier,
  148. // creating a single string from the data in the dictionary. The
  149. // dictionary {kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US,
  150. // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar} becomes
  151. // "en_US@calendar=japanese".
  152. function CFLocaleCreate( allocator: CFAllocatorRef; localeIdentifier: CFStringRef ): CFLocaleRef; external name '_CFLocaleCreate';
  153. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  154. // Returns a CFLocaleRef for the locale named by the "arbitrary" locale identifier.
  155. function CFLocaleCreateCopy( allocator: CFAllocatorRef; locale: CFLocaleRef ): CFLocaleRef; external name '_CFLocaleCreateCopy';
  156. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  157. // Having gotten a CFLocale from somebody, code should make a copy
  158. // if it is going to use it for several operations
  159. // or hold onto it. In the future, there may be mutable locales.
  160. function CFLocaleGetIdentifier( locale: CFLocaleRef ): CFStringRef; external name '_CFLocaleGetIdentifier';
  161. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  162. // Returns the locale's identifier. This may not be the same string
  163. // that the locale was created with (CFLocale may canonicalize it).
  164. function CFLocaleGetValue( locale: CFLocaleRef; key: CFStringRef ): CFTypeRef; external name '_CFLocaleGetValue';
  165. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  166. // Returns the value for the given key. This is how settings and state
  167. // are accessed via a CFLocale. Values might be of any CF type.
  168. function CFLocaleCopyDisplayNameForPropertyValue( displayLocale: CFLocaleRef; key: CFStringRef; value: CFStringRef ): CFStringRef; external name '_CFLocaleCopyDisplayNameForPropertyValue';
  169. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  170. // Returns the display name for the given value. The key tells what
  171. // the value is, and is one of the usual locale property keys, though
  172. // not all locale property keys have values with display name values.
  173. // Locale Keys
  174. var kCFLocaleIdentifier: CFStringRef; external name '_kCFLocaleIdentifier'; (* attribute const *)
  175. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  176. var kCFLocaleLanguageCode: CFStringRef; external name '_kCFLocaleLanguageCode'; (* attribute const *)
  177. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  178. var kCFLocaleCountryCode: CFStringRef; external name '_kCFLocaleCountryCode'; (* attribute const *)
  179. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  180. var kCFLocaleScriptCode: CFStringRef; external name '_kCFLocaleScriptCode'; (* attribute const *)
  181. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  182. var kCFLocaleVariantCode: CFStringRef; external name '_kCFLocaleVariantCode'; (* attribute const *)
  183. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  184. var kCFLocaleExemplarCharacterSet: CFStringRef; external name '_kCFLocaleExemplarCharacterSet'; (* attribute const *)
  185. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  186. var kCFLocaleCalendarIdentifier: CFStringRef; external name '_kCFLocaleCalendarIdentifier'; (* attribute const *)
  187. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  188. var kCFLocaleCalendar: CFStringRef; external name '_kCFLocaleCalendar'; (* attribute const *)
  189. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  190. var kCFLocaleCollationIdentifier: CFStringRef; external name '_kCFLocaleCollationIdentifier'; (* attribute const *)
  191. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  192. var kCFLocaleUsesMetricSystem: CFStringRef; external name '_kCFLocaleUsesMetricSystem'; (* attribute const *)
  193. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  194. var kCFLocaleMeasurementSystem: CFStringRef; external name '_kCFLocaleMeasurementSystem'; (* attribute const *)
  195. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *) // "Metric" or "U.S."
  196. var kCFLocaleDecimalSeparator: CFStringRef; external name '_kCFLocaleDecimalSeparator'; (* attribute const *)
  197. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  198. var kCFLocaleGroupingSeparator: CFStringRef; external name '_kCFLocaleGroupingSeparator'; (* attribute const *)
  199. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  200. var kCFLocaleCurrencySymbol: CFStringRef; external name '_kCFLocaleCurrencySymbol'; (* attribute const *)
  201. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  202. var kCFLocaleCurrencyCode: CFStringRef; external name '_kCFLocaleCurrencyCode'; (* attribute const *)
  203. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *) // ISO 3-letter currency code
  204. // Values for kCFLocaleCalendarIdentifier
  205. var kCFGregorianCalendar: CFStringRef; external name '_kCFGregorianCalendar'; (* attribute const *)
  206. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  207. var kCFBuddhistCalendar: CFStringRef; external name '_kCFBuddhistCalendar'; (* attribute const *)
  208. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  209. var kCFChineseCalendar: CFStringRef; external name '_kCFChineseCalendar'; (* attribute const *)
  210. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  211. var kCFHebrewCalendar: CFStringRef; external name '_kCFHebrewCalendar'; (* attribute const *)
  212. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  213. var kCFIslamicCalendar: CFStringRef; external name '_kCFIslamicCalendar'; (* attribute const *)
  214. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  215. var kCFIslamicCivilCalendar: CFStringRef; external name '_kCFIslamicCivilCalendar'; (* attribute const *)
  216. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  217. var kCFJapaneseCalendar: CFStringRef; external name '_kCFJapaneseCalendar'; (* attribute const *)
  218. (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  219. {#endif}
  220. end.