Google Cloud C++ Client  1.32.1
C++ Client Library for Google Cloud Platform
version.h
Go to the documentation of this file.
1 // Copyright 2018 Google LLC
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_VERSION_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VERSION_H
17 
18 #include "google/cloud/internal/attributes.h"
19 #include "google/cloud/internal/port_platform.h"
20 #include "google/cloud/internal/version_info.h"
21 #include <string>
22 
23 #define GOOGLE_CLOUD_CPP_IAM_DEPRECATED
24  GOOGLE_CLOUD_CPP_DEPRECATED(
25  "this type predates IAM conditions and does not work with policies "
26  "that include IAM conditions. The functions that use this type are "
27  "deprecated and will be be removed on 2022-04-01 or shortly "
28  "after. See GitHub issue #5929 for more information.")
29 
30 #define GOOGLE_CLOUD_CPP_VCONCAT(Ma, Mi) v##Ma
31 #define GOOGLE_CLOUD_CPP_VEVAL(Ma, Mi) GOOGLE_CLOUD_CPP_VCONCAT(Ma, Mi)
32 #define GOOGLE_CLOUD_CPP_NS
33  GOOGLE_CLOUD_CPP_VEVAL(GOOGLE_CLOUD_CPP_VERSION_MAJOR,
34  GOOGLE_CLOUD_CPP_VERSION_MINOR)
35 
36 #define GOOGLE_CLOUD_CPP_GENERATED_VCONCAT(Ma, Mi) gcpcxxV##Ma
37 #define GOOGLE_CLOUD_CPP_GENERATED_VEVAL(Ma, Mi)
39 #define GOOGLE_CLOUD_CPP_GENERATED_NS
40  GOOGLE_CLOUD_CPP_GENERATED_VEVAL(GOOGLE_CLOUD_CPP_VERSION_MAJOR,
41  GOOGLE_CLOUD_CPP_VERSION_MINOR)
42 
43 namespace google {
44 /**
45  * Contains all the Google Cloud C++ Library APIs.
46  */
47 namespace cloud {
48 /**
49  * The Google Cloud C++ Library inlined, versioned namespace.
50  *
51  * Applications may need to link multiple versions of the Google Cloud C++
52  * Libraries, for example, if they link a library that uses an older version of
53  * the libraries than they do. This namespace is inlined, so applications can
54  * use `google::cloud::Foo` in their source, but the symbols are versioned,
55  * i.e., the symbol becomes `google::cloud::v1::Foo`.
56  *
57  * Note that, consistent with the semver.org guidelines, the v0 version makes
58  * no guarantees with respect to backwards compatibility.
59  */
60 inline namespace GOOGLE_CLOUD_CPP_NS {
61 /**
62  * The Google Cloud Storage C++ Client major version.
63  *
64  * @see https://semver.org/spec/v2.0.0.html for details.
65  */
66 int constexpr version_major() { return GOOGLE_CLOUD_CPP_VERSION_MAJOR; }
67 
68 /**
69  * The Google Cloud Storage C++ Client minor version.
70  *
71  * @see https://semver.org/spec/v2.0.0.html for details.
72  */
73 int constexpr version_minor() { return GOOGLE_CLOUD_CPP_VERSION_MINOR; }
74 
75 /**
76  * The Google Cloud Storage C++ Client patch version.
77  *
78  * @see https://semver.org/spec/v2.0.0.html for details.
79  */
80 int constexpr version_patch() { return GOOGLE_CLOUD_CPP_VERSION_PATCH; }
81 
82 namespace internal {
83 auto constexpr kMaxMinorVersions = 100;
84 auto constexpr kMaxPatchVersions = 100;
85 } // namespace internal
86 
87 /// A single integer representing the Major/Minor/Patch version.
88 int constexpr version() {
89  static_assert(version_minor() < internal::kMaxMinorVersions,
90  "version_minor() should be < kMaxMinorVersions");
91  static_assert(version_patch() < internal::kMaxPatchVersions,
92  "version_patch() should be < kMaxPatchVersions");
93  return internal::kMaxPatchVersions *
94  (internal::kMaxMinorVersions * version_major() + version_minor()) +
96 }
97 
98 /// The version as a string, in MAJOR.MINOR.PATCH+gitrev format.
99 std::string version_string();
100 
101 } // namespace GOOGLE_CLOUD_CPP_NS
102 } // namespace cloud
103 } // namespace google
104 
105 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VERSION_H