|
BDE 4.39.x Production Release
|
DEPRECATED: Provide consistent interface for platform-dependent functionality.
Provide consistent interface for platform-dependent functionality.
This component provides a namespace for a set of typedefs and functions that provide a stable, portable interface to platform-dependent functionality. In particular, this component supplies portable typenames for signed and unsigned 64-bit integers, and provides compile-time preprocessor macros that characterize the "endian-ness" of the underlying processor on the current platform. Runtime functionality to return the "endian-ness", and to round up to a multiple of the maximum required alignment for the processor, are also provided.
The following illustrates how some of the types and functions supplied by this component might be used.
bsls::PlatformUtil::Int64 and bsls::PlatformUtil::Uint64 identify the preferred fundamental types denoting signed and unsigned 64-bit integers, respectively:
Clients can use these types in the same way as an int. Clients can also mix usage with other fundamental integral types:
bsls::PlatformUtil::size_type identifies the preferred integral type denoting the number of elements in a container, and the number of bytes in a single block of memory supplied by an allocator. For example, a typical use is as a typedef in an STL container:
The functions:
encapsulate the capability of determining whether a machine is big- or little-endian across all supported platforms. In addition, certain compile-time constants are also provided as preprocessor macros to facilitate conditional compilation:
These functions and macros are useful for writing platform-independent code, such as a function that converts the bytes in a short to network byte order (which is consistent with big-endian):
Note that in the above usage example, either the macros or the functions can be used to test whether a platform is big- or little-endian.
Typedefs | |
| typedef bsls::PlatformUtil | bsls_PlatformUtil |
| #define BSLS_PLATFORMUTIL__HTONL | ( | x | ) | BSLS_PLATFORMUTIL_HTONL(x) |
| #define BSLS_PLATFORMUTIL__HTONS | ( | x | ) | BSLS_PLATFORMUTIL_HTONS(x) |
| #define BSLS_PLATFORMUTIL__IS_BIG_ENDIAN BSLS_PLATFORMUTIL_IS_BIG_ENDIAN |
| #define BSLS_PLATFORMUTIL__NTOHL | ( | x | ) | BSLS_PLATFORMUTIL_NTOHL(x) |
| #define BSLS_PLATFORMUTIL__NTOHS | ( | x | ) | BSLS_PLATFORMUTIL_NTOHS(x) |
| #define BSLS_PLATFORMUTIL_HTONL | ( | x | ) | (x) |
| #define BSLS_PLATFORMUTIL_HTONS | ( | x | ) | (x) |
| #define BSLS_PLATFORMUTIL_IS_BIG_ENDIAN BSLS_PLATFORM_IS_BIG_ENDIAN |
BSLS_PLATFORM_IS_BIG_ENDIAN defined in bsls_platform instead. | #define BSLS_PLATFORMUTIL_NTOHL | ( | x | ) | (x) |
| #define BSLS_PLATFORMUTIL_NTOHS | ( | x | ) | (x) |
| typedef bsls::PlatformUtil bsls_PlatformUtil |
This alias is defined for backward compatibility.