StringCompare.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:18k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       StringCompare.h
  3.  
  4.      Contains:   Public interfaces for String Comparison and related operations
  5.  
  6.      Version:    Technology: Mac OS 8
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1985-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __STRINGCOMPARE__
  18. #define __STRINGCOMPARE__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __TEXTCOMMON__
  23. #include "TextCommon.h"
  24. #endif
  25. #ifndef __SCRIPT__
  26. #include "Script.h"
  27. #endif
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37. #if PRAGMA_STRUCT_ALIGN
  38.     #pragma options align=mac68k
  39. #elif PRAGMA_STRUCT_PACKPUSH
  40.     #pragma pack(push, 2)
  41. #elif PRAGMA_STRUCT_PACK
  42.     #pragma pack(2)
  43. #endif
  44. /*
  45.     Here are the current System 7 routine names and the translations to the older forms.
  46.     Please use the newer forms in all new code and migrate the older names out of existing
  47.     code as maintenance permits.
  48.     
  49.     NEW NAME                    OLD NAME                    OBSOLETE FORM (no handle)
  50.     
  51.     CompareString (Str255)      IUCompPString (hp only)     IUCompString (hp only)
  52.     CompareText (ptr/len)       IUMagPString                IUMagString
  53.     IdenticalString (Str255)    IUEqualPString (hp only)    IUEqualString  (hp only)
  54.     IdenticalText (ptr/len)     IUMagIDPString              IUMagIDString
  55.     LanguageOrder               IULangOrder
  56.     ScriptOrder                 IUScriptOrder
  57.     StringOrder (Str255)        IUStringOrder (hp only)
  58.     TextOrder (ptr/len)         IUTextOrder
  59.     RelString
  60.     CmpString (a only)                  
  61.     EqualString (hp only)
  62.     
  63.     ReplaceText
  64.     Carbon only supports the new names.  The old names are undefined for Carbon targets.
  65.     InterfaceLib always has exported the old names.  For C macros have been defined to allow
  66.     the use of the new names.  For Pascal and Assembly using the new names will result
  67.     in link errors. 
  68.     
  69. */
  70. enum {
  71.                                                                 /* Special language code values for Language Order*/
  72.     systemCurLang               = -2,                           /* current (itlbLang) lang for system script*/
  73.     systemDefLang               = -3,                           /* default (table) lang for system script*/
  74.     currentCurLang              = -4,                           /* current (itlbLang) lang for current script*/
  75.     currentDefLang              = -5,                           /* default lang for current script*/
  76.     scriptCurLang               = -6,                           /* current (itlbLang) lang for specified script*/
  77.     scriptDefLang               = -7                            /* default language for a specified script*/
  78. };
  79. /* obsolete names*/
  80. enum {
  81.     iuSystemCurLang             = systemCurLang,
  82.     iuSystemDefLang             = systemDefLang,
  83.     iuCurrentCurLang            = currentCurLang,
  84.     iuCurrentDefLang            = currentDefLang,
  85.     iuScriptCurLang             = scriptCurLang,
  86.     iuScriptDefLang             = scriptDefLang
  87. };
  88. /*
  89.  *  Type Select Utils - now public in Carbon
  90.  */
  91. typedef SInt16 TSCode;
  92. enum {
  93.     tsPreviousSelectMode        = -1,
  94.     tsNormalSelectMode          = 0,
  95.     tsNextSelectMode            = 1
  96. };
  97. struct TypeSelectRecord {
  98.     unsigned long                   tsrLastKeyTime;
  99.     ScriptCode                      tsrScript;
  100.     Str63                           tsrKeyStrokes;
  101. };
  102. typedef struct TypeSelectRecord         TypeSelectRecord;
  103. typedef CALLBACK_API( Boolean , IndexToStringProcPtr )(short item, ScriptCode *itemsScript, StringPtr *itemsStringPtr, void *yourDataPtr);
  104. typedef STACK_UPP_TYPE(IndexToStringProcPtr)                    IndexToStringUPP;
  105. EXTERN_API( void )
  106. TypeSelectClear                 (TypeSelectRecord *     tsr)                                THREEWORDINLINE(0x3F3C, 0x0028, 0xA9ED);
  107. /*
  108.         Long ago the implementation of TypeSelectNewKey had a bug that
  109.         required the high word of D0 to be zero or the function did not work.
  110.         Although fixed now, we are continuing to clear the high word
  111.         just in case someone tries to run on an older system.
  112.     */
  113. EXTERN_API( Boolean )
  114. TypeSelectNewKey                (const EventRecord *    theEvent,
  115.                                  TypeSelectRecord *     tsr)                                FOURWORDINLINE(0x7000, 0x3F3C, 0x002A, 0xA9ED);
  116. EXTERN_API( short )
  117. TypeSelectFindItem              (const TypeSelectRecord * tsr,
  118.                                  short                  listSize,
  119.                                  TSCode                 selectMode,
  120.                                  IndexToStringUPP       getStringProc,
  121.                                  void *                 yourDataPtr)                        THREEWORDINLINE(0x3F3C, 0x002C, 0xA9ED);
  122. EXTERN_API( short )
  123. TypeSelectCompare               (const TypeSelectRecord * tsr,
  124.                                  ScriptCode             testStringScript,
  125.                                  StringPtr              testStringPtr)                      THREEWORDINLINE(0x3F3C, 0x002E, 0xA9ED);
  126. #if OPAQUE_UPP_TYPES
  127.     EXTERN_API(IndexToStringUPP)
  128.     NewIndexToStringUPP            (IndexToStringProcPtr    userRoutine);
  129.     EXTERN_API(void)
  130.     DisposeIndexToStringUPP        (IndexToStringUPP        userUPP);
  131.     EXTERN_API(Boolean)
  132.     InvokeIndexToStringUPP         (short                   item,
  133.                                     ScriptCode *            itemsScript,
  134.                                     StringPtr *             itemsStringPtr,
  135.                                     void *                  yourDataPtr,
  136.                                     IndexToStringUPP        userUPP);
  137. #else
  138.     enum { uppIndexToStringProcInfo = 0x00003F90 };                 /* pascal 1_byte Func(2_bytes, 4_bytes, 4_bytes, 4_bytes) */
  139.     #define NewIndexToStringUPP(userRoutine)                        (IndexToStringUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppIndexToStringProcInfo, GetCurrentArchitecture())
  140.     #define DisposeIndexToStringUPP(userUPP)                        DisposeRoutineDescriptor(userUPP)
  141.     #define InvokeIndexToStringUPP(item, itemsScript, itemsStringPtr, yourDataPtr, userUPP)  (Boolean)CALL_FOUR_PARAMETER_UPP((userUPP), uppIndexToStringProcInfo, (item), (itemsScript), (itemsStringPtr), (yourDataPtr))
  142. #endif
  143. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  144. #define NewIndexToStringProc(userRoutine)                       NewIndexToStringUPP(userRoutine)
  145. #define CallIndexToStringProc(userRoutine, item, itemsScript, itemsStringPtr, yourDataPtr) InvokeIndexToStringUPP(item, itemsScript, itemsStringPtr, yourDataPtr, userRoutine)
  146. /*
  147.  *  These routines are available in Carbon with the new names.
  148.  */
  149. #if TARGET_OS_MAC
  150.     #define MacReplaceText ReplaceText
  151. #endif
  152. EXTERN_API( short )
  153. MacReplaceText                  (Handle                 baseText,
  154.                                  Handle                 substitutionText,
  155.                                  Str15                  key)                                FOURWORDINLINE(0x2F3C, 0x820C, 0xFFDC, 0xA8B5);
  156. EXTERN_API( short )
  157. ScriptOrder                     (ScriptCode             script1,
  158.                                  ScriptCode             script2)                            THREEWORDINLINE(0x3F3C, 0x001E, 0xA9ED);
  159. #if TARGET_OS_MAC
  160.     #define MacCompareString CompareString
  161. #endif
  162. EXTERN_API( short )
  163. MacCompareString                (ConstStr255Param       aStr,
  164.                                  ConstStr255Param       bStr,
  165.                                  Handle                 itl2Handle);
  166. EXTERN_API( short )
  167. IdenticalString                 (ConstStr255Param       aStr,
  168.                                  ConstStr255Param       bStr,
  169.                                  Handle                 itl2Handle);
  170. EXTERN_API( short )
  171. StringOrder                     (ConstStr255Param       aStr,
  172.                                  ConstStr255Param       bStr,
  173.                                  ScriptCode             aScript,
  174.                                  ScriptCode             bScript,
  175.                                  LangCode               aLang,
  176.                                  LangCode               bLang);
  177. EXTERN_API( short )
  178. CompareText                     (const void *           aPtr,
  179.                                  const void *           bPtr,
  180.                                  short                  aLen,
  181.                                  short                  bLen,
  182.                                  Handle                 itl2Handle)                         THREEWORDINLINE(0x3F3C, 0x001A, 0xA9ED);
  183. EXTERN_API( short )
  184. IdenticalText                   (const void *           aPtr,
  185.                                  const void *           bPtr,
  186.                                  short                  aLen,
  187.                                  short                  bLen,
  188.                                  Handle                 itl2Handle)                         THREEWORDINLINE(0x3F3C, 0x001C, 0xA9ED);
  189. EXTERN_API( short )
  190. TextOrder                       (const void *           aPtr,
  191.                                  const void *           bPtr,
  192.                                  short                  aLen,
  193.                                  short                  bLen,
  194.                                  ScriptCode             aScript,
  195.                                  ScriptCode             bScript,
  196.                                  LangCode               aLang,
  197.                                  LangCode               bLang)                              THREEWORDINLINE(0x3F3C, 0x0022, 0xA9ED);
  198. EXTERN_API( short )
  199. LanguageOrder                   (LangCode               language1,
  200.                                  LangCode               language2)                          THREEWORDINLINE(0x3F3C, 0x0020, 0xA9ED);
  201. /*
  202.  *  These routines are available in InterfaceLib with old names.
  203.  *  Macros are provided for C to allow source code use to the new names.
  204.  */
  205. #if CALL_NOT_IN_CARBON
  206. EXTERN_API( short )
  207. IUMagPString                    (const void *           aPtr,
  208.                                  const void *           bPtr,
  209.                                  short                  aLen,
  210.                                  short                  bLen,
  211.                                  Handle                 itl2Handle)                         THREEWORDINLINE(0x3F3C, 0x001A, 0xA9ED);
  212. EXTERN_API( short )
  213. IUMagIDPString                  (const void *           aPtr,
  214.                                  const void *           bPtr,
  215.                                  short                  aLen,
  216.                                  short                  bLen,
  217.                                  Handle                 itl2Handle)                         THREEWORDINLINE(0x3F3C, 0x001C, 0xA9ED);
  218. EXTERN_API( short )
  219. IUTextOrder                     (const void *           aPtr,
  220.                                  const void *           bPtr,
  221.                                  short                  aLen,
  222.                                  short                  bLen,
  223.                                  ScriptCode             aScript,
  224.                                  ScriptCode             bScript,
  225.                                  LangCode               aLang,
  226.                                  LangCode               bLang)                              THREEWORDINLINE(0x3F3C, 0x0022, 0xA9ED);
  227. EXTERN_API( short )
  228. IULangOrder                     (LangCode               language1,
  229.                                  LangCode               language2)                          THREEWORDINLINE(0x3F3C, 0x0020, 0xA9ED);
  230. EXTERN_API( short )
  231. IUScriptOrder                   (ScriptCode             script1,
  232.                                  ScriptCode             script2)                            THREEWORDINLINE(0x3F3C, 0x001E, 0xA9ED);
  233. EXTERN_API( short )
  234. IUMagString                     (const void *           aPtr,
  235.                                  const void *           bPtr,
  236.                                  short                  aLen,
  237.                                  short                  bLen)                               THREEWORDINLINE(0x3F3C, 0x000A, 0xA9ED);
  238. EXTERN_API( short )
  239. IUMagIDString                   (const void *           aPtr,
  240.                                  const void *           bPtr,
  241.                                  short                  aLen,
  242.                                  short                  bLen)                               THREEWORDINLINE(0x3F3C, 0x000C, 0xA9ED);
  243. #endif  /* CALL_NOT_IN_CARBON */
  244. #if CALL_NOT_IN_CARBON
  245. EXTERN_API( short )
  246. IUCompPString                   (ConstStr255Param       aStr,
  247.                                  ConstStr255Param       bStr,
  248.                                  Handle                 itl2Handle);
  249. EXTERN_API( short )
  250. IUEqualPString                  (ConstStr255Param       aStr,
  251.                                  ConstStr255Param       bStr,
  252.                                  Handle                 itl2Handle);
  253. EXTERN_API( short )
  254. IUStringOrder                   (ConstStr255Param       aStr,
  255.                                  ConstStr255Param       bStr,
  256.                                  ScriptCode             aScript,
  257.                                  ScriptCode             bScript,
  258.                                  LangCode               aLang,
  259.                                  LangCode               bLang);
  260. EXTERN_API( short )
  261. IUCompString                    (ConstStr255Param       aStr,
  262.                                  ConstStr255Param       bStr);
  263. EXTERN_API( short )
  264. IUEqualString                   (ConstStr255Param       aStr,
  265.                                  ConstStr255Param       bStr);
  266. #endif  /* CALL_NOT_IN_CARBON */
  267. #if CALL_NOT_IN_CARBON
  268. #if TARGET_OS_MAC
  269.     #define CompareString(aStr, bStr, itl2Handle) 
  270.              IUCompPString(aStr, bStr, itl2Handle)
  271. #endif
  272. #ifdef MacCompareString
  273. #undef MacCompareString
  274. #endif
  275. #define MacCompareString(aStr, bStr, itl2Handle) 
  276.          IUCompPString(aStr, bStr, itl2Handle)
  277. #define CompareText(aPtr, bPtr, aLen, bLen, itl2Handle) 
  278.          IUMagPString(aPtr, bPtr, aLen, bLen, itl2Handle)
  279. #define IdenticalString(aStr, bStr, itl2Handle) 
  280.          IUEqualPString(aStr, bStr, itl2Handle)
  281. #define IdenticalText(aPtr, bPtr, aLen, bLen, itl2Handle) 
  282.          IUMagIDPString(aPtr, bPtr, aLen, bLen, itl2Handle)
  283. #define StringOrder(aStr, bStr, aScript, bScript, aLang, bLang) 
  284.          IUStringOrder(aStr, bStr, aScript, bScript, aLang, bLang)
  285. #define TextOrder(aPtr, bPtr, aLen, bLen, aScript, bScript, aLang, bLang) 
  286.          IUTextOrder(aPtr, bPtr, aLen, bLen, aScript, bScript, aLang, bLang)
  287. #define LanguageOrder(language1, language2) 
  288.          IULangOrder(language1, language2)
  289. #endif /* CALL_NOT_IN_CARBON */
  290. #if CALL_NOT_IN_CARBON
  291. EXTERN_API_C( short )
  292. iucomppstring                   (const char *           aStr,
  293.                                  const char *           bStr,
  294.                                  Handle                 intlHandle);
  295. EXTERN_API_C( short )
  296. iuequalpstring                  (const char *           aStr,
  297.                                  const char *           bStr,
  298.                                  Handle                 intlHandle);
  299. EXTERN_API_C( short )
  300. iustringorder                   (const char *           aStr,
  301.                                  const char *           bStr,
  302.                                  ScriptCode             aScript,
  303.                                  ScriptCode             bScript,
  304.                                  LangCode               aLang,
  305.                                  LangCode               bLang);
  306. EXTERN_API_C( short )
  307. iucompstring                    (const char *           aStr,
  308.                                  const char *           bStr);
  309. EXTERN_API_C( short )
  310. iuequalstring                   (const char *           aStr,
  311.                                  const char *           bStr);
  312. #endif  /* CALL_NOT_IN_CARBON */
  313. EXTERN_API( short )
  314. RelString                       (ConstStr255Param       str1,
  315.                                  ConstStr255Param       str2,
  316.                                  Boolean                caseSensitive,
  317.                                  Boolean                diacSensitive);
  318. EXTERN_API( Boolean )
  319. EqualString                     (ConstStr255Param       str1,
  320.                                  ConstStr255Param       str2,
  321.                                  Boolean                caseSensitive,
  322.                                  Boolean                diacSensitive);
  323. EXTERN_API_C( short )
  324. relstring                       (const char *           str1,
  325.                                  const char *           str2,
  326.                                  Boolean                caseSensitive,
  327.                                  Boolean                diacSensitive);
  328. #if CALL_NOT_IN_CARBON
  329. EXTERN_API_C( Boolean )
  330. equalstring                     (const char *           str1,
  331.                                  const char *           str2,
  332.                                  Boolean                caseSensitive,
  333.                                  Boolean                diacSensitive);
  334. #endif  /* CALL_NOT_IN_CARBON */
  335. #if PRAGMA_STRUCT_ALIGN
  336.     #pragma options align=reset
  337. #elif PRAGMA_STRUCT_PACKPUSH
  338.     #pragma pack(pop)
  339. #elif PRAGMA_STRUCT_PACK
  340.     #pragma pack()
  341. #endif
  342. #ifdef PRAGMA_IMPORT_OFF
  343. #pragma import off
  344. #elif PRAGMA_IMPORT
  345. #pragma import reset
  346. #endif
  347. #ifdef __cplusplus
  348. }
  349. #endif
  350. #endif /* __STRINGCOMPARE__ */