Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
6.6 KiB

  1. /*
  2. File: NumberFormatting.h
  3. Contains: Utilites for formatting numbers
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1996-2001 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __NUMBERFORMATTING__
  11. #define __NUMBERFORMATTING__
  12. #ifndef __CONDITIONALMACROS__
  13. #include <ConditionalMacros.h>
  14. #endif
  15. #ifndef __MACTYPES__
  16. #include <MacTypes.h>
  17. #endif
  18. #ifndef __INTLRESOURCES__
  19. #include <IntlResources.h>
  20. #endif
  21. #if PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #if PRAGMA_IMPORT
  28. #pragma import on
  29. #endif
  30. #if PRAGMA_STRUCT_ALIGN
  31. #pragma options align=mac68k
  32. #elif PRAGMA_STRUCT_PACKPUSH
  33. #pragma pack(push, 2)
  34. #elif PRAGMA_STRUCT_PACK
  35. #pragma pack(2)
  36. #endif
  37. /*
  38. Here are the current System 7 routine names and the translations to the older forms.
  39. Please use the newer forms in all new code and migrate the older names out of existing
  40. code as maintainance permits.
  41. New Name Old Name(s)
  42. ExtendedToString FormatX2Str
  43. FormatRecToString Format2Str
  44. NumToString
  45. StringToExtended FormatStr2X
  46. StringToFormatRec Str2Format
  47. StringToNum
  48. */
  49. struct NumFormatString {
  50. UInt8 fLength;
  51. UInt8 fVersion;
  52. char data[254]; /* private data */
  53. };
  54. typedef struct NumFormatString NumFormatString;
  55. typedef NumFormatString NumFormatStringRec;
  56. typedef short FormatStatus;
  57. enum {
  58. fVNumber = 0 /* first version of NumFormatString */
  59. };
  60. typedef SInt8 FormatClass;
  61. enum {
  62. fPositive = 0,
  63. fNegative = 1,
  64. fZero = 2
  65. };
  66. typedef SInt8 FormatResultType;
  67. enum {
  68. fFormatOK = 0,
  69. fBestGuess = 1,
  70. fOutOfSynch = 2,
  71. fSpuriousChars = 3,
  72. fMissingDelimiter = 4,
  73. fExtraDecimal = 5,
  74. fMissingLiteral = 6,
  75. fExtraExp = 7,
  76. fFormatOverflow = 8,
  77. fFormStrIsNAN = 9,
  78. fBadPartsTable = 10,
  79. fExtraPercent = 11,
  80. fExtraSeparator = 12,
  81. fEmptyFormatString = 13
  82. };
  83. struct FVector {
  84. short start;
  85. short length;
  86. };
  87. typedef struct FVector FVector;
  88. /* index by [fPositive..fZero] */
  89. typedef FVector TripleInt[3];
  90. #if CALL_NOT_IN_CARBON
  91. /*
  92. * stringtonum()
  93. *
  94. * Availability:
  95. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  96. * CarbonLib: not available
  97. * Mac OS X: not available
  98. */
  99. EXTERN_API_C( void )
  100. stringtonum(
  101. const char * theString,
  102. long * theNum);
  103. /*
  104. * numtostring()
  105. *
  106. * Availability:
  107. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  108. * CarbonLib: not available
  109. * Mac OS X: not available
  110. */
  111. EXTERN_API_C( void )
  112. numtostring(
  113. long theNum,
  114. char * theString);
  115. #endif /* CALL_NOT_IN_CARBON */
  116. /*
  117. * StringToNum()
  118. *
  119. * Availability:
  120. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  121. * CarbonLib: in CarbonLib 1.0 and later
  122. * Mac OS X: in version 10.0 and later
  123. */
  124. EXTERN_API( void )
  125. StringToNum(
  126. ConstStr255Param theString,
  127. long * theNum);
  128. /*
  129. * NumToString()
  130. *
  131. * Availability:
  132. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  133. * CarbonLib: in CarbonLib 1.0 and later
  134. * Mac OS X: in version 10.0 and later
  135. */
  136. EXTERN_API( void )
  137. NumToString(
  138. long theNum,
  139. Str255 theString);
  140. /*
  141. * ExtendedToString()
  142. *
  143. * Availability:
  144. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  145. * CarbonLib: in CarbonLib 1.0 and later
  146. * Mac OS X: in version 10.0 and later
  147. */
  148. EXTERN_API( FormatStatus )
  149. ExtendedToString(
  150. const extended80 * x,
  151. const NumFormatString * myCanonical,
  152. const NumberParts * partsTable,
  153. Str255 outString) FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE8, 0xA8B5);
  154. /*
  155. * StringToExtended()
  156. *
  157. * Availability:
  158. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  159. * CarbonLib: in CarbonLib 1.0 and later
  160. * Mac OS X: in version 10.0 and later
  161. */
  162. EXTERN_API( FormatStatus )
  163. StringToExtended(
  164. ConstStr255Param source,
  165. const NumFormatString * myCanonical,
  166. const NumberParts * partsTable,
  167. extended80 * x) FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE6, 0xA8B5);
  168. /*
  169. * StringToFormatRec()
  170. *
  171. * Availability:
  172. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  173. * CarbonLib: in CarbonLib 1.0 and later
  174. * Mac OS X: in version 10.0 and later
  175. */
  176. EXTERN_API( FormatStatus )
  177. StringToFormatRec(
  178. ConstStr255Param inString,
  179. const NumberParts * partsTable,
  180. NumFormatString * outString) FOURWORDINLINE(0x2F3C, 0x820C, 0xFFEC, 0xA8B5);
  181. /*
  182. * FormatRecToString()
  183. *
  184. * Availability:
  185. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  186. * CarbonLib: in CarbonLib 1.0 and later
  187. * Mac OS X: in version 10.0 and later
  188. */
  189. EXTERN_API( FormatStatus )
  190. FormatRecToString(
  191. const NumFormatString * myCanonical,
  192. const NumberParts * partsTable,
  193. Str255 outString,
  194. TripleInt positions) FOURWORDINLINE(0x2F3C, 0x8210, 0xFFEA, 0xA8B5);
  195. #if OLDROUTINENAMES
  196. #define FormatX2Str(x, myCanonical, partsTable, outString) \
  197. ExtendedToString( x, myCanonical, partsTable, outString)
  198. #define FormatStr2X(source, myCanonical, partsTable, x) \
  199. StringToExtended( source, myCanonical, partsTable, x)
  200. #define Str2Format(inString, partsTable, outString) \
  201. StringToFormatRec(inString, partsTable, outString)
  202. #define Format2Str(myCanonical, partsTable, outString, positions) \
  203. FormatRecToString(myCanonical, partsTable, outString, positions)
  204. #endif /* OLDROUTINENAMES */
  205. #if PRAGMA_STRUCT_ALIGN
  206. #pragma options align=reset
  207. #elif PRAGMA_STRUCT_PACKPUSH
  208. #pragma pack(pop)
  209. #elif PRAGMA_STRUCT_PACK
  210. #pragma pack()
  211. #endif
  212. #ifdef PRAGMA_IMPORT_OFF
  213. #pragma import off
  214. #elif PRAGMA_IMPORT
  215. #pragma import reset
  216. #endif
  217. #ifdef __cplusplus
  218. }
  219. #endif
  220. #endif /* __NUMBERFORMATTING__ */