Framework | CoreFoundation/CoreFoundation.h |
Companion guide | |
Declared in | CFByteOrder.h |
When handling binary data transmitted or shared across platforms, you need be concerned with how each platform stores numerical values. A platform stores values either in big-endian or little-endian format. On big-endian machines, such as PowerPC machines, values are stored with the most-significant bytes first in memory; on little-endian machines, such as Pentium machines, values are stored with the least-significant bytes first. A multibyte value transmitted to a platform with a different format will be misinterpreted if it is not converted properly by one of the computers.
You identify the native format of the current platform using the CFByteOrderGetCurrent
function. Use functions such as CFSwapInt32BigToHost
and CFConvertFloat32HostToSwapped
to convert values between different byte order formats.
Returns the byte order of the current computer.
CFByteOrder CFByteOrderGetCurrent ( void );
The byte order of the current computer. See “Byte Order Flags” for the list of possible return values.
CFByteOrder.h
Converts a 64-bit double from the host’s native byte order to a platform-independent format.
CFSwappedFloat64 CFConvertDoubleHostToSwapped ( double arg );
The real value to convert.
A structure holding the real value in a canonical byte order.
CFByteOrder.h
Converts a 64-bit double from a platform-independent format to the host’s native byte order.
double CFConvertDoubleSwappedToHost ( CFSwappedFloat64 arg );
A structure holding the real value to convert.
The real value in the host’s native format.
CFByteOrder.h
Converts a 32-bit float from the host’s native byte order to a platform-independent format.
CFSwappedFloat32 CFConvertFloat32HostToSwapped ( Float32 arg );
The real value to convert.
A structure holding the real value in a canonical byte order.
CFByteOrder.h
Converts a 32-bit float from a platform-independent format to the host’s native byte order.
Float32 CFConvertFloat32SwappedToHost ( CFSwappedFloat32 arg );
A structure holding the real value to convert.
The real value in the host’s native format.
CFByteOrder.h
Converts a 64-bit float from the host’s native byte order to a platform-independent format.
CFSwappedFloat64 CFConvertFloat64HostToSwapped ( Float64 arg );
The real value to convert.
A structure holding the real value in a canonical byte order.
CFByteOrder.h
Converts a 64-bit float from a platform-independent format to the host’s native byte order.
Float64 CFConvertFloat64SwappedToHost ( CFSwappedFloat64 arg );
A structure holding the real value to convert.
The real value in the host’s native format.
CFByteOrder.h
Converts a 32-bit float from the host’s native byte order to a platform-independent format.
CFSwappedFloat32 CFConvertFloatHostToSwapped ( float arg );
The real value to convert.
A structure holding the real value in a canonical byte order.
CFByteOrder.h
Converts a 32-bit float from a platform-independent format to the host’s native byte order.
float CFConvertFloatSwappedToHost ( CFSwappedFloat32 arg );
A structure holding the real value to convert.
The real value in the host’s native format.
CFByteOrder.h
Swaps the bytes of a 16-bit integer.
uint16_t CFSwapInt16 ( uint16_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped.
CFByteOrder.h
Converts a 16-bit integer from big-endian format to the host’s native byte order.
uint16_t CFSwapInt16BigToHost ( uint16_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is big-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 16-bit integer from the host’s native byte order to big-endian format.
uint16_t CFSwapInt16HostToBig ( uint16_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is big-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 16-bit integer from the host’s native byte order to little-endian format.
uint16_t CFSwapInt16HostToLittle ( uint16_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is little-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 16-bit integer from little-endian format to the host’s native byte order.
uint16_t CFSwapInt16LittleToHost ( uint16_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is little-endian, this function returns arg unchanged.
CFByteOrder.h
Swaps the bytes of a 32-bit integer.
uint32_t CFSwapInt32 ( uint32_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped.
CFByteOrder.h
Converts a 32-bit integer from big-endian format to the host’s native byte order.
uint32_t CFSwapInt32BigToHost ( uint32_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is big-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 32-bit integer from the host’s native byte order to big-endian format.
uint32_t CFSwapInt32HostToBig ( uint32_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is big-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 32-bit integer from the host’s native byte order to little-endian format.
uint32_t CFSwapInt32HostToLittle ( uint32_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is little-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 32-bit integer from little-endian format to the host’s native byte order.
uint32_t CFSwapInt32LittleToHost ( uint32_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is little-endian, this function returns arg unchanged.
CFByteOrder.h
Swaps the bytes of a 64-bit integer.
uint64_t CFSwapInt64 ( uint64_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped.
CFByteOrder.h
Converts a 64-bit integer from big-endian format to the host’s native byte order.
uint64_t CFSwapInt64BigToHost ( uint64_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is big-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 64-bit integer from the host’s native byte order to big-endian format.
uint64_t CFSwapInt64HostToBig ( uint64_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is big-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 64-bit integer from the host’s native byte order to little-endian format.
uint64_t CFSwapInt64HostToLittle ( uint64_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is little-endian, this function returns arg unchanged.
CFByteOrder.h
Converts a 64-bit integer from little-endian format to the host’s native byte order.
uint64_t CFSwapInt64LittleToHost ( uint64_t arg );
The integer whose bytes should be swapped.
The integer with its bytes swapped. If the host is little-endian, this function returns arg unchanged.
CFByteOrder.h
Structure holding a 32-bit float value in a platform-independent byte order.
struct CFSwappedFloat32 { uint32_t v; }; typedef struct CFSwappedFloat32 CFSwappedFloat32;
v
A 32-bit float value stored with a platform-independent byte order.
CFByteOrder.h
Structure holding a 64-bit float value in a platform-independent byte order.
struct CFSwappedFloat64 { uint64_t v; }; typedef struct CFSwappedFloat64 CFSwappedFloat64;
v
A 64-bit float value stored with a platform-independent byte order.
CFByteOrder.h
Flags that identify byte order.
enum __CFByteOrder { CFByteOrderUnknown, CFByteOrderLittleEndian, CFByteOrderBigEndian }; typedef enum __CFByteOrder CFByteOrder;
CFByteOrderUnknown
The byte order is unknown.
Available in Mac OS X v10.0 and later.
Declared in CFByteOrder.h
.
CFByteOrderLittleEndian
Multi-byte values are stored with the least-significant bytes stored first. Pentium CPUs are little endian.
Available in Mac OS X v10.0 and later.
Declared in CFByteOrder.h
.
CFByteOrderBigEndian
Multi-byte values are stored with the most-significant bytes stored first. PowerPC CPUs are big endian.
Available in Mac OS X v10.0 and later.
Declared in CFByteOrder.h
.
© 2003, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)