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

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       NumberFormatting.h
  3.  
  4.      Contains:   Utilites for formatting numbers
  5.  
  6.      Version:    Technology: 
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1996-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 __NUMBERFORMATTING__
  18. #define __NUMBERFORMATTING__
  19. #ifndef __CONDITIONALMACROS__
  20. #include "ConditionalMacros.h"
  21. #endif
  22. #ifndef __MACTYPES__
  23. #include "MacTypes.h"
  24. #endif
  25. #ifndef __INTLRESOURCES__
  26. #include "IntlResources.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 maintainance permits.
  48.     
  49.     New Name                    Old Name(s)
  50.     
  51.     ExtendedToString            FormatX2Str
  52.     FormatRecToString           Format2Str
  53.     NumToString             
  54.     StringToExtended            FormatStr2X
  55.     StringToFormatRec           Str2Format
  56.     StringToNum             
  57. */
  58. struct NumFormatString {
  59.     UInt8                           fLength;
  60.     UInt8                           fVersion;
  61.     char                            data[254];                  /* private data */
  62. };
  63. typedef struct NumFormatString          NumFormatString;
  64. typedef NumFormatString                 NumFormatStringRec;
  65. typedef short                           FormatStatus;
  66. enum {
  67.     fVNumber                    = 0                             /* first version of NumFormatString */
  68. };
  69. typedef SInt8                           FormatClass;
  70. enum {
  71.     fPositive                   = 0,
  72.     fNegative                   = 1,
  73.     fZero                       = 2
  74. };
  75. typedef SInt8                           FormatResultType;
  76. enum {
  77.     fFormatOK                   = 0,
  78.     fBestGuess                  = 1,
  79.     fOutOfSynch                 = 2,
  80.     fSpuriousChars              = 3,
  81.     fMissingDelimiter           = 4,
  82.     fExtraDecimal               = 5,
  83.     fMissingLiteral             = 6,
  84.     fExtraExp                   = 7,
  85.     fFormatOverflow             = 8,
  86.     fFormStrIsNAN               = 9,
  87.     fBadPartsTable              = 10,
  88.     fExtraPercent               = 11,
  89.     fExtraSeparator             = 12,
  90.     fEmptyFormatString          = 13
  91. };
  92. struct FVector {
  93.     short                           start;
  94.     short                           length;
  95. };
  96. typedef struct FVector                  FVector;
  97. /* index by [fPositive..fZero] */
  98. typedef FVector                         TripleInt[3];
  99. #if CALL_NOT_IN_CARBON
  100. EXTERN_API_C( void )
  101. stringtonum                     (const char *           theString,
  102.                                  long *                 theNum);
  103. EXTERN_API_C( void )
  104. numtostring                     (long                   theNum,
  105.                                  char *                 theString);
  106. #endif  /* CALL_NOT_IN_CARBON */
  107. EXTERN_API( void )
  108. StringToNum                     (ConstStr255Param       theString,
  109.                                  long *                 theNum);
  110. EXTERN_API( void )
  111. NumToString                     (long                   theNum,
  112.                                  Str255                 theString);
  113. EXTERN_API( FormatStatus )
  114. ExtendedToString                (const extended80 *     x,
  115.                                  const NumFormatString * myCanonical,
  116.                                  const NumberParts *    partsTable,
  117.                                  Str255                 outString)                          FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE8, 0xA8B5);
  118. EXTERN_API( FormatStatus )
  119. StringToExtended                (ConstStr255Param       source,
  120.                                  const NumFormatString * myCanonical,
  121.                                  const NumberParts *    partsTable,
  122.                                  extended80 *           x)                                  FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE6, 0xA8B5);
  123. EXTERN_API( FormatStatus )
  124. StringToFormatRec               (ConstStr255Param       inString,
  125.                                  const NumberParts *    partsTable,
  126.                                  NumFormatString *      outString)                          FOURWORDINLINE(0x2F3C, 0x820C, 0xFFEC, 0xA8B5);
  127. EXTERN_API( FormatStatus )
  128. FormatRecToString               (const NumFormatString * myCanonical,
  129.                                  const NumberParts *    partsTable,
  130.                                  Str255                 outString,
  131.                                  TripleInt              positions)                          FOURWORDINLINE(0x2F3C, 0x8210, 0xFFEA, 0xA8B5);
  132. #if OLDROUTINENAMES
  133. #define FormatX2Str(x, myCanonical, partsTable, outString)  
  134.          ExtendedToString( x, myCanonical, partsTable, outString)
  135. #define FormatStr2X(source, myCanonical, partsTable, x)  
  136.          StringToExtended( source, myCanonical, partsTable, x)
  137. #define Str2Format(inString, partsTable, outString)  
  138.          StringToFormatRec(inString, partsTable, outString)
  139. #define Format2Str(myCanonical, partsTable, outString, positions)  
  140.          FormatRecToString(myCanonical, partsTable, outString, positions)
  141. #endif  /* OLDROUTINENAMES */
  142. #if PRAGMA_STRUCT_ALIGN
  143.     #pragma options align=reset
  144. #elif PRAGMA_STRUCT_PACKPUSH
  145.     #pragma pack(pop)
  146. #elif PRAGMA_STRUCT_PACK
  147.     #pragma pack()
  148. #endif
  149. #ifdef PRAGMA_IMPORT_OFF
  150. #pragma import off
  151. #elif PRAGMA_IMPORT
  152. #pragma import reset
  153. #endif
  154. #ifdef __cplusplus
  155. }
  156. #endif
  157. #endif /* __NUMBERFORMATTING__ */