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

Detailed Description

Outline

Purpose

Provide functions to return BDEX version information for types.

Classes

Description

This component provides a namespace, bslx::VersionFunctions, that contains functions for determining the BDEX version number for types.

This namespace defines the maxSupportedBdexVersion function, which is overloaded to return a predetermined value, k_NO_VERSION, also defined in this namespace, for each of the fundamental types, enum types, and bsl::string. For bsl::vector, the maxSupportedBdexVersion function returns 1 if the vector is parameterized on one of the three types mentioned above. Otherwise, the version number returned is the same as that returned for bsl::vector::value_type. For BDEX-compliant types, the function returns the BDEX version number returned by the maxSupportedBdexVersion method provided by that type.

In general, this component is used by higher-level bslx components to query the version number for types.

Usage

This section illustrates intended use of this component.

Example 1: Querying BDEX Version

This component may be used by clients to query the version number for types in a convenient manner. First, define an enum, my_Enum:

enum my_Enum {
ENUM_VALUE1,
ENUM_VALUE2,
ENUM_VALUE3,
ENUM_VALUE4
};

Then, define a BDEX-compliant class, my_Class:

class my_Class {
public:
enum {
VERSION = 1
};
// CLASS METHODS
static int maxSupportedBdexVersion(int) {
return VERSION;
}
// ...
};

Finally, verify the value returned by maxSupportedBdexVersion for some fundamental types, my_Enum, and my_Class with an arbitrary versionSelector:

assert(k_NO_VERSION ==
maxSupportedBdexVersion(reinterpret_cast<char *>(0), 20131127));
assert(k_NO_VERSION ==
maxSupportedBdexVersion(reinterpret_cast<int *>(0), 20131127));
assert(k_NO_VERSION ==
maxSupportedBdexVersion(reinterpret_cast<double *>(0), 20131127));
assert(k_NO_VERSION ==
maxSupportedBdexVersion(reinterpret_cast<bsl::string *>(0), 20131127));
assert(k_NO_VERSION ==
maxSupportedBdexVersion(reinterpret_cast<my_Enum *>(0), 20131127));
assert(my_Class::VERSION ==
maxSupportedBdexVersion(reinterpret_cast<my_Class *>(0), 20131127));
Definition bslstl_string.h:1281
int maxSupportedBdexVersion(const TYPE *, int versionSelector)
Definition bslx_versionfunctions.h:519
@ k_NO_VERSION
Definition bslx_versionfunctions.h:334