1 // Copyright 2017 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_VERSION_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_VERSION_H
17 
18 #include "google/cloud/bigtable/version_info.h"
19 #include "google/cloud/version.h"
20 #include <string>
21 
22 #define BIGTABLE_CLIENT_NS                              \
23   GOOGLE_CLOUD_CPP_VEVAL(BIGTABLE_CLIENT_VERSION_MAJOR, \
24                          BIGTABLE_CLIENT_VERSION_MINOR)
25 
26 namespace google {
27 namespace cloud {
28 /**
29  * Contains all the Cloud Bigtable C++ client APIs.
30  */
31 namespace bigtable {
32 /**
33  * The inlined, versioned namespace for the Cloud Bigtable C++ client APIs.
34  *
35  * Applications may need to link multiple versions of the Cloud Bigtable C++
36  * client, for example, if they link a library that uses an older version of
37  * the client than they do.  This namespace is inlined, so applications can use
38  * `bigtable::Foo` in their source, but the symbols are versioned, i.e., the
39  * symbol becomes `bigtable::v1::Foo`.
40  *
41  * Note that, consistent with the semver.org guidelines, the v0 version makes
42  * no guarantees with respect to backwards compatibility.
43  */
44 inline namespace BIGTABLE_CLIENT_NS {
45 /**
46  * The Cloud Bigtable C++ Client major version.
47  *
48  * @see https://semver.org/spec/v2.0.0.html for details.
49  */
version_major()50 int constexpr version_major() { return BIGTABLE_CLIENT_VERSION_MAJOR; }
51 
52 /**
53  * The Cloud Bigtable C++ Client minor version.
54  *
55  * @see https://semver.org/spec/v2.0.0.html for details.
56  */
version_minor()57 int constexpr version_minor() { return BIGTABLE_CLIENT_VERSION_MINOR; }
58 
59 /**
60  * The Cloud Bigtable C++ Client patch version.
61  *
62  * @see https://semver.org/spec/v2.0.0.html for details.
63  */
version_patch()64 int constexpr version_patch() { return BIGTABLE_CLIENT_VERSION_PATCH; }
65 
66 /// A single integer representing the Major/Minor/Patch version.
version()67 int constexpr version() {
68   static_assert(::google::cloud::version_major() == version_major(),
69                 "Mismatched major version");
70   static_assert(::google::cloud::version_minor() == version_minor(),
71                 "Mismatched minor version");
72   static_assert(::google::cloud::version_patch() == version_patch(),
73                 "Mismatched patch version");
74   return ::google::cloud::version();
75 }
76 
77 /// The version as a string, in MAJOR.MINOR.PATCH+gitrev format.
78 std::string version_string();
79 
80 }  // namespace BIGTABLE_CLIENT_NS
81 }  // namespace bigtable
82 }  // namespace cloud
83 }  // namespace google
84 
85 #endif  // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_VERSION_H
86