BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balscm_version.h
Go to the documentation of this file.
1/// @file balscm_version.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// balscm_version.h -*-C++-*-
8#ifndef INCLUDED_BALSCM_VERSION
9#define INCLUDED_BALSCM_VERSION
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup balscm_version balscm_version
15/// @brief Provide source control management (versioning) information.
16/// @addtogroup bal
17/// @{
18/// @addtogroup balscm
19/// @{
20/// @addtogroup balscm_version
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#balscm_version-purpose"> Purpose</a>
25/// * <a href="#balscm_version-classes"> Classes </a>
26/// * <a href="#balscm_version-description"> Description </a>
27/// * <a href="#balscm_version-usage"> Usage </a>
28/// * <a href="#balscm_version-example-1-embedding-version-information"> Example 1: Embedding Version Information </a>
29/// * <a href="#balscm_version-example-2-accessing-the-embedded-version-information"> Example 2: Accessing the Embedded Version information </a>
30///
31/// # Purpose {#balscm_version-purpose}
32/// Provide source control management (versioning) information.
33///
34/// # Classes {#balscm_version-classes}
35///
36/// - balscm::Version: namespace for versioning information for `bal`
37///
38/// # Description {#balscm_version-description}
39/// This component provides source control management (versioning)
40/// information for the `bal` package group. In particular, this component
41/// embeds RCS-style and SCCS-style version strings in binary executable files
42/// that use one or more components from the `bal` package group. This version
43/// information may be extracted from binary files using common UNIX utilities
44/// (e.g., `ident` and `what`). In addition, the `version` `static` member
45/// function in the `balscm::Version` struct can be used to query version
46/// information for the `bal` package group at runtime. The following {Usage}
47/// examples illustrate these two basic capabilities.
48///
49/// Note that unless the `version` method will be called, it is not necessary to
50/// "#include" this component header file to get `bal` version information
51/// embedded in an executable. It is only necessary to use one or more `bal`
52/// components (and, hence, link in the `bal` library).
53///
54/// ## Usage {#balscm_version-usage}
55///
56///
57/// This section illustrates intended use of this component.
58///
59/// ### Example 1: Embedding Version Information {#balscm_version-example-1-embedding-version-information}
60///
61///
62/// The version of the `bal` package group linked into a program can be
63/// obtained at runtime using the `version` `static` member function as follows:
64/// @code
65/// #include <balscm_version.h>
66///
67/// assert(0 != balscm::Version::version());
68///
69/// bsl::cout << "BAL version: " << balscm::Version::version()
70/// << bsl::endl;
71/// @endcode
72/// Output similar to the following will be printed to `stdout`:
73/// @code
74/// BAL version: BLP_LIB_BDE_BAL_0.01.0
75/// @endcode
76/// The "0.01.0" portion of the string distinguishes different versions of the
77/// `bal` package group.
78///
79/// ### Example 2: Accessing the Embedded Version information {#balscm_version-example-2-accessing-the-embedded-version-information}
80///
81///
82/// The versioning information embedded into a binary file by this component can
83/// be examined under UNIX using several well-known utilities. For example:
84/// @code
85/// $ ident a.out
86/// a.out:
87/// $Id: BLP_LIB_BDE_BAL_0.01.0 $
88///
89/// $ what a.out | grep BAL
90/// BLP_LIB_BDE_BAL_0.01.0
91///
92/// $ strings a.out | grep BAL
93/// $Id: BLP_LIB_BDE_BAL_0.01.0 $
94/// @(#)BLP_LIB_BDE_BAL_0.01.0
95/// BLP_LIB_BDE_BAL_0.01.0
96/// @endcode
97/// Note that `ident` and `what` typically will display many version strings
98/// unrelated to `bal` depending on the libraries used by `a.out`.
99/// @}
100/** @} */
101/** @} */
102
103/** @addtogroup bal
104 * @{
105 */
106/** @addtogroup balscm
107 * @{
108 */
109/** @addtogroup balscm_version
110 * @{
111 */
112
113#include <balscm_versiontag.h> // 'BAL_VERSION_MAJOR', 'BAL_VERSION_MINOR'
114
115#include <bslscm_version.h>
116
117#include <bsls_linkcoercion.h>
118
119
120
121namespace balscm {
122
123 // ==============
124 // struct Version
125 // ==============
126
127/// This struct provides a namespace for (1) source control management
128/// (versioning) information that is embedded in binary executable files,
129/// and (2) a facility to query that information at runtime.
130struct Version {
131
132 // CLASS DATA
133 static const char *s_ident; // RCS-style version string
134 static const char *s_what; // SCCS-style version string
135
136#define BALSCM_CONCAT2(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
137#define BALSCM_CONCAT(a,b,c,d,e,f) BALSCM_CONCAT2(a,b,c,d,e,f)
138
139// 'BALSCM_S_VERSION' is a symbol whose name warns users of version mismatch
140// linking errors. Note that the exact string "compiled_this_object" must be
141// present in this version coercion symbol. Tools may look for this pattern to
142// warn users of mismatches.
143#define BALSCM_S_VERSION BALSCM_CONCAT(s_version_BAL_, \
144 BAL_VERSION_MAJOR, _, \
145 BAL_VERSION_MINOR, _, \
146 compiled_this_object)
147
148 static const char *BALSCM_S_VERSION; // BDE-style version string
149
150 static const char *s_dependencies; // available for future use
151 static const char *s_buildInfo; // available for future use
152 static const char *s_timestamp; // available for future use
153 static const char *s_sourceControlInfo; // available for future use
154
155 // CLASS METHODS
156
157 /// Return the address of a character string that identifies the version
158 /// of the `bal` package group in use.
159 static const char *version();
160};
161
162// ============================================================================
163// INLINE DEFINITIONS
164// ============================================================================
165
166 // --------------
167 // struct Version
168 // --------------
169
170// CLASS METHODS
171inline
172const char *Version::version()
173{
174 return BALSCM_S_VERSION;
175}
176
177} // close package namespace
178
179// Force linker to pull in this component's object file.
180
182 balscm_version_assertion,
184
185
186
187#endif
188
189// ----------------------------------------------------------------------------
190// Copyright 2015 Bloomberg Finance L.P.
191//
192// Licensed under the Apache License, Version 2.0 (the "License");
193// you may not use this file except in compliance with the License.
194// You may obtain a copy of the License at
195//
196// http://www.apache.org/licenses/LICENSE-2.0
197//
198// Unless required by applicable law or agreed to in writing, software
199// distributed under the License is distributed on an "AS IS" BASIS,
200// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201// See the License for the specific language governing permissions and
202// limitations under the License.
203// ----------------------------- END-OF-FILE ----------------------------------
204
205/** @} */
206/** @} */
207/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY(type, refName, referredSymbol)
Definition bsls_linkcoercion.h:194
Definition balscm_version.h:121
Definition balscm_version.h:130
static const char * version()
Definition balscm_version.h:172
static const char * BALSCM_S_VERSION
Definition balscm_version.h:148
static const char * s_what
Definition balscm_version.h:134
static const char * s_buildInfo
Definition balscm_version.h:151
static const char * s_sourceControlInfo
Definition balscm_version.h:153
static const char * s_ident
Definition balscm_version.h:133
static const char * s_dependencies
Definition balscm_version.h:150
static const char * s_timestamp
Definition balscm_version.h:152