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

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       CFNumber.h
  3.  
  4.      Contains:   CoreFoundation numbers
  5.  
  6.      Version:    Technology: Mac OS X
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1999-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 __CFNUMBER__
  18. #define __CFNUMBER__
  19. #ifndef __CFBASE__
  20. #include "CFBase.h"
  21. #endif
  22. #if PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #if PRAGMA_IMPORT
  29. #pragma import on
  30. #endif
  31. #if PRAGMA_STRUCT_ALIGN
  32.     #pragma options align=mac68k
  33. #elif PRAGMA_STRUCT_PACKPUSH
  34.     #pragma pack(push, 2)
  35. #elif PRAGMA_STRUCT_PACK
  36.     #pragma pack(2)
  37. #endif
  38. #if PRAGMA_ENUM_ALWAYSINT
  39.     #if defined(__fourbyteints__) && !__fourbyteints__ 
  40.         #define __CFNUMBER__RESTORE_TWOBYTEINTS
  41.         #pragma fourbyteints on
  42.     #endif
  43.     #pragma enumsalwaysint on
  44. #elif PRAGMA_ENUM_OPTIONS
  45.     #pragma option enum=int
  46. #elif PRAGMA_ENUM_PACK
  47.     #if __option(pack_enums)
  48.         #define __CFNUMBER__RESTORE_PACKED_ENUMS
  49.         #pragma options(!pack_enums)
  50.     #endif
  51. #endif
  52. typedef const struct __CFBoolean * CFBooleanRef;
  53. extern const CFBooleanRef kCFBooleanTrue;
  54. extern const CFBooleanRef kCFBooleanFalse;
  55. EXTERN_API_C( CFTypeID )
  56. CFBooleanGetTypeID              (void);
  57. /* Returns the value of the given CFBoolean instance. */
  58. EXTERN_API_C( Boolean )
  59. CFBooleanGetValue               (CFBooleanRef           boolean);
  60. enum CFNumberType {
  61.                                                                 /* Types from MacTypes.h */
  62.     kCFNumberSInt8Type          = 1,
  63.     kCFNumberSInt16Type         = 2,
  64.     kCFNumberSInt32Type         = 3,
  65.     kCFNumberSInt64Type         = 4,
  66.     kCFNumberFloat32Type        = 5,
  67.     kCFNumberFloat64Type        = 6,                            /* 64-bit IEEE 754 */
  68.                                                                 /* Basic C types */
  69.     kCFNumberCharType           = 7,
  70.     kCFNumberShortType          = 8,
  71.     kCFNumberIntType            = 9,
  72.     kCFNumberLongType           = 10,
  73.     kCFNumberLongLongType       = 11,
  74.     kCFNumberFloatType          = 12,
  75.     kCFNumberDoubleType         = 13,                           /* Other */
  76.     kCFNumberCFIndexType        = 14,
  77.     kCFNumberMaxType            = 14
  78. };
  79. typedef enum CFNumberType CFNumberType;
  80. typedef const struct __CFNumber * CFNumberRef;
  81. extern const CFNumberRef kCFNumberPositiveInfinity;
  82. extern const CFNumberRef kCFNumberNegativeInfinity;
  83. extern const CFNumberRef kCFNumberNaN;
  84. EXTERN_API_C( CFTypeID )
  85. CFNumberGetTypeID               (void);
  86. /* Creates a CFNumber with the given value. The type of number pointed
  87. to by the valuePtr is specified by type. If type is a floating point
  88. type and the value represents one of the infinities or NaN, the
  89. well-defined CFNumber for that value is returned. If either of valuePtr
  90. or type is an invalid value, the result it undefined. */
  91. EXTERN_API_C( CFNumberRef )
  92. CFNumberCreate                  (CFAllocatorRef         allocator,
  93.                                  CFNumberType           theType,
  94.                                  const void *           valuePtr);
  95. /* Returns the storage format of the CFNumber's value.  Note that
  96. this is not necessarily the type provided in CFNumberCreate(). */
  97. EXTERN_API_C( CFNumberType )
  98. CFNumberGetType                 (CFNumberRef            number);
  99. /* Returns the size in bytes of the type of the number. */
  100. EXTERN_API_C( CFIndex )
  101. CFNumberGetByteSize             (CFNumberRef            number);
  102. /* Returns TRUE if the type of the CFNumber's value is one of the defined floating point types. */
  103. EXTERN_API_C( Boolean )
  104. CFNumberIsFloatType             (CFNumberRef            number);
  105. /* Copies the CFNumber's value into the space pointed to by
  106. valuePtr, as the specified type. If conversion needs to take
  107. place, the conversion rules follow human expectation and not
  108. C's promotion and truncation rules.  If the conversion is
  109. lossy, or the value is out of range, FALSE is returned. Best
  110. attempt at conversion will still be in *valuePtr.  */
  111. EXTERN_API_C( Boolean )
  112. CFNumberGetValue                (CFNumberRef            number,
  113.                                  CFNumberType           numType,
  114.                                  void *                 valuePtr);
  115. /* Compares the two CFNumber instances. If conversion of the
  116. types of the values is needed, the conversion and comparison
  117. follow human expectations and not C's promotion and comparison
  118. rules. Negative zero compares less than positive zero.
  119. Positive infinity compares greater than everything except
  120. itself, to which it compares equal. Negative infinity compares
  121. less than everything except itself, to which it compares equal.
  122. Unlike standard practice, if both numbers are NaN, then they
  123. compare equal; if only one of the numbers is NaN, then the NaN
  124. compares greater than the other number if it is negative, and
  125. smaller than the other number if it is positive. [Note that in
  126. CFEqual() with two CFNumbers, if either or both of the numbers
  127. is NaN, FALSE is returned.] */
  128. EXTERN_API_C( CFComparisonResult )
  129. CFNumberCompare                 (CFNumberRef            number,
  130.                                  CFNumberRef            otherNumber,
  131.                                  void *                 context);
  132. #if PRAGMA_ENUM_ALWAYSINT
  133.     #pragma enumsalwaysint reset
  134.     #ifdef __CFNUMBER__RESTORE_TWOBYTEINTS
  135.         #pragma fourbyteints off
  136.     #endif
  137. #elif PRAGMA_ENUM_OPTIONS
  138.     #pragma option enum=reset
  139. #elif defined(__CFNUMBER__RESTORE_PACKED_ENUMS)
  140.     #pragma options(pack_enums)
  141. #endif
  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 /* __CFNUMBER__ */