BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bblscm_version.h
Go to the documentation of this file.
1/// @file bblscm_version.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bblscm_version.h -*-C++-*-
8#ifndef INCLUDED_BBLSCM_VERSION
9#define INCLUDED_BBLSCM_VERSION
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bblscm_version bblscm_version
15/// @brief Provide source control management (versioning) information.
16/// @addtogroup bbl
17/// @{
18/// @addtogroup bblscm
19/// @{
20/// @addtogroup bblscm_version
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bblscm_version-purpose"> Purpose</a>
25/// * <a href="#bblscm_version-classes"> Classes </a>
26/// * <a href="#bblscm_version-description"> Description </a>
27/// * <a href="#bblscm_version-usage"> Usage </a>
28/// * <a href="#bblscm_version-example-1-embedding-version-information"> Example 1: Embedding Version Information </a>
29/// * <a href="#bblscm_version-example-2-accessing-the-embedded-version-information"> Example 2: Accessing the Embedded Version information </a>
30///
31/// # Purpose {#bblscm_version-purpose}
32/// Provide source control management (versioning) information.
33///
34/// # Classes {#bblscm_version-classes}
35///
36/// - bblscm::Version: namespace for RCS and SCCS versioning information for `bbl`
37///
38/// # Description {#bblscm_version-description}
39/// This component provides source control management (versioning)
40/// information for the `bbl` 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 `bbl` 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 `bblscm::Version` `struct` can be used to query version
46/// information for the `bbl` 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 `bbl` version information
51/// embedded in an executable. It is only necessary to use one or more `bbl`
52/// components (and, hence, link in the `bbl` library).
53///
54/// ## Usage {#bblscm_version-usage}
55///
56///
57/// This section illustrates intended use of this component.
58///
59/// ### Example 1: Embedding Version Information {#bblscm_version-example-1-embedding-version-information}
60///
61///
62/// The version of the `bbl` package group linked into a program can be
63/// obtained at runtime using the `version` `static` member function as follows:
64/// @code
65/// #include <bblscm_version.h>
66///
67/// assert(0 != bblscm::Version::version());
68///
69/// bsl::cout << "BBL version: " << bblscm::Version::version()
70/// << bsl::endl;
71/// @endcode
72/// Output similar to the following will be printed to `stdout`:
73/// @code
74/// BBL version: BLP_LIB_BDE_BBL_0.01.0
75/// @endcode
76/// The "0.01.0" portion of the string distinguishes different versions of the
77/// `bbl` package group.
78///
79/// ### Example 2: Accessing the Embedded Version information {#bblscm_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_BBL_0.01.0 $
88///
89/// $ what a.out | grep BBL
90/// BLP_LIB_BDE_BBL_0.01.0
91///
92/// $ strings a.out | grep BBL
93/// $Id: BLP_LIB_BDE_BBL_0.01.0 $
94/// @(#)BLP_LIB_BDE_BBL_0.01.0
95/// BLP_LIB_BDE_BBL_0.01.0
96/// @endcode
97/// Note that `ident` and `what` typically will display many version strings
98/// unrelated to `bbl` depending on the libraries used by `a.out`.
99/// @}
100/** @} */
101/** @} */
102
103/** @addtogroup bbl
104 * @{
105 */
106/** @addtogroup bblscm
107 * @{
108 */
109/** @addtogroup bblscm_version
110 * @{
111 */
112
113#include <bblscm_versiontag.h> // 'BBL_VERSION_MAJOR', 'BBL_VERSION_MINOR'
114
115#include <bslscm_version.h>
116
117#include <bsls_linkcoercion.h>
118
119
120
121namespace bblscm {
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 BBLSCM_CONCAT2(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
137#define BBLSCM_CONCAT(a,b,c,d,e,f) BBLSCM_CONCAT2(a,b,c,d,e,f)
138
139// 'BBLSCM_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 BBLSCM_D_VERSION BBLSCM_CONCAT(s_version_BBL_, \
144 BBL_VERSION_MAJOR, _, \
145 BBL_VERSION_MINOR, _, \
146 compiled_this_object)
147
148 static const char *BBLSCM_S_VERSION; // BDE-style version string
149
150 static const char *s_dependencies; // package-group dependency string
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 `bbl` 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 BBLSCM_S_VERSION;
175}
176
177} // close package namespace
178
180 bblscm_version_assertion,
182
183
184
185#endif
186
187// ----------------------------------------------------------------------------
188// Copyright 2015 Bloomberg Finance L.P.
189//
190// Licensed under the Apache License, Version 2.0 (the "License");
191// you may not use this file except in compliance with the License.
192// You may obtain a copy of the License at
193//
194// http://www.apache.org/licenses/LICENSE-2.0
195//
196// Unless required by applicable law or agreed to in writing, software
197// distributed under the License is distributed on an "AS IS" BASIS,
198// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199// See the License for the specific language governing permissions and
200// limitations under the License.
201// ----------------------------- END-OF-FILE ----------------------------------
202
203/** @} */
204/** @} */
205/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY(type, refName, referredSymbol)
Definition bsls_linkcoercion.h:194
Definition bblscm_version.h:121
Definition bblscm_version.h:130
static const char * s_buildInfo
Definition bblscm_version.h:151
static const char * s_ident
Definition bblscm_version.h:133
static const char * BBLSCM_S_VERSION
Definition bblscm_version.h:148
static const char * s_timestamp
Definition bblscm_version.h:152
static const char * s_dependencies
Definition bblscm_version.h:150
static const char * version()
Definition bblscm_version.h:172
static const char * s_sourceControlInfo
Definition bblscm_version.h:153
static const char * s_what
Definition bblscm_version.h:134