Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bdlde_byteorder
[Package bdlde]

Provide an enumeration of the set of possible byte orders. More...

Namespaces

namespace  bdlde

Detailed Description

Outline
Purpose:
Provide an enumeration of the set of possible byte orders.
Classes:
bdlde::ByteOrder namespace for a byte order enum
See also:
Component bdlde_charconvertutf16
Description:
This component provides a namespace for the enum type bdlde::ByteOrder::Enum, which enumerates the set of possible byte orders.
Enumerators:
  Name              Description
  ---------------   ---------------------------------------------------
  e_LITTLE_ENDIAN   little-endian
  e_BIG_ENDIAN      big-endian
  e_NETWORK         network byte order (aliased to 'e_BIG_ENDIAN')
  e_HOST            aliased to 'e_LITTLE_ENDIAN' or 'e_BIG_ENDIAN' (depending
                    on platform)
Usage:
In this section we show intended use of this component.
Example 1: Basic Syntax:
The following snippets of code provide a simple illustration of bdlde::ByteOrder usage.
First, we create a variable value of type bdlde::ByteOrder::Enum and initialize it with the enumerator value bdlde::ByteOrder::e_LITTLE_ENDIAN:
  bdlde::ByteOrder::Enum value = bdlde::ByteOrder::e_LITTLE_ENDIAN;
Next, we store a pointer to its ASCII representation in a variable asciiValue of type const char *:
  const char *asciiValue = bdlde::ByteOrder::toAscii(value);
  assert(0 == bsl::strcmp(asciiValue, "LITTLE_ENDIAN"));
Then, we try one of the aliased identifiers, and we get a string corresponding to the value it is aliased to:
  value      = bdlde::ByteOrder::e_NETWORK;
  asciiValue = bdlde::ByteOrder::toAscii(value);

  assert(0 == bsl::strcmp(asciiValue, "BIG_ENDIAN"));
Finally, we print value to bsl::cout:
  bsl::cout << value << bsl::endl;
This statement produces the following output on stdout:
  BIG_ENDIAN