BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslx_typecode

Detailed Description

Outline

Purpose

Enumerate the fundamental types supported by BDEX.

Classes

Description

This component provides a namespace for the enum type bslx::TypeCode::Enum, which enumerates the set of fundamental types supported within bslx. A bslx::TypeCode is particularly important when testing bslx implementations (see bslx::TestOutStream and bslx::TestInStream).

Enumerators

Name Description
------------------ ---------------------------------------------------
e_INT8 Value is an 8-bit integer.
e_UINT8 Value is an unsigned 8-bit integer.
e_INT16 Value is a 16-bit integer.
e_UINT16 Value is an unsigned 16-bit integer.
e_INT24 Value is a 24-bit integer.
e_UINT24 Value is an unsigned 24-bit integer.
e_INT32 Value is a 32-bit integer.
e_UINT32 Value is an unsigned 32-bit integer.
e_INT40 Value is a 40-bit integer.
e_UINT40 Value is an unsigned 40-bit integer.
e_INT48 Value is a 48-bit integer.
e_UINT48 Value is an unsigned 48-bit integer.
e_INT56 Value is a 56-bit integer.
e_UINT56 Value is an unsigned 56-bit integer.
e_INT64 Value is a 64-bit integer.
e_UINT64 Value is an unsigned 64-bit integer.
e_FLOAT32 Value is a 32-bit floating-point number.
e_FLOAT64 Value is a 64-bit floating-point number.
e_INVALID Value is not valid.

Usage

This section illustrates intended use of this component.

Example 1: Basic Syntax

The following snippets of code provide a simple illustration of using bslx::TypeCode.

First, we create a variable value of type bslx::TypeCode::Enum and initialize it with the enumerator value bslx::TypeCode::e_INT32:

Enum
Definition bslx_typecode.h:156
@ e_INT32
Definition bslx_typecode.h:169

Now, we store the address of its ASCII representation in a pointer variable, asciiValue, of type const char *:

const char *asciiValue = bslx::TypeCode::toAscii(value);
assert(0 == bsl::strcmp(asciiValue, "INT32"));
static const char * toAscii(TypeCode::Enum value)

Finally, we print value to bsl::cout:

bsl::cout << value << bsl::endl;

This statement produces the following output on stdout:

INT32