Google Cloud C++ Client  1.35.0
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 // https://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, Pa) v##Ma##_##Mi##_##Pa
31 #define GOOGLE_CLOUD_CPP_VEVAL(Ma, Mi, Pa) GOOGLE_CLOUD_CPP_VCONCAT(Ma, Mi, Pa)
32 #define GOOGLE_CLOUD_CPP_NS
33  GOOGLE_CLOUD_CPP_VEVAL(GOOGLE_CLOUD_CPP_VERSION_MAJOR,
34  GOOGLE_CLOUD_CPP_VERSION_MINOR,
35  GOOGLE_CLOUD_CPP_VERSION_PATCH)
36 
37 /**
38  * Versioned inline namespace that users should generally avoid spelling.
39  *
40  * The actual inline namespace name will change with each release, and if you
41  * use it your code will be tightly coupled to a specific release. Omitting the
42  * inline namespace name will make upgrading to newer releases easier.
43  *
44  * However, applications may need to link multiple versions of the Google Cloud
45  * C++ Libraries, for example, if they link a library that uses an older
46  * version of the libraries than they do. This namespace is inlined, so
47  * applications can use `google::cloud::Foo` in their source, but the symbols
48  * are versioned, i.e., the symbol becomes `google::cloud::vXYZ::Foo`.
49  */
50 #define GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
51  inline namespace GOOGLE_CLOUD_CPP_NS {
52 #define GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
53  } /* namespace GOOGLE_CLOUD_CPP_NS */
54 
55 // This preprocessor symbol is deprecated and should never be used anywhere. It
56 // exists solely for backward compatibility to avoid breaking anyone who may
57 // have been using it.
58 #define GOOGLE_CLOUD_CPP_GENERATED_NS GOOGLE_CLOUD_CPP_NS
59 
60 namespace google {
61 /**
62  * Contains all the Google Cloud C++ Library APIs.
63  */
64 namespace cloud {
66 /**
67  * The Google Cloud Storage C++ Client major version.
68  *
69  * @see https://semver.org/spec/v2.0.0.html for details.
70  */
71 int constexpr version_major() { return GOOGLE_CLOUD_CPP_VERSION_MAJOR; }
72 
73 /**
74  * The Google Cloud Storage C++ Client minor version.
75  *
76  * @see https://semver.org/spec/v2.0.0.html for details.
77  */
78 int constexpr version_minor() { return GOOGLE_CLOUD_CPP_VERSION_MINOR; }
79 
80 /**
81  * The Google Cloud Storage C++ Client patch version.
82  *
83  * @see https://semver.org/spec/v2.0.0.html for details.
84  */
85 int constexpr version_patch() { return GOOGLE_CLOUD_CPP_VERSION_PATCH; }
86 
87 namespace internal {
88 auto constexpr kMaxMinorVersions = 100;
89 auto constexpr kMaxPatchVersions = 100;
90 } // namespace internal
91 
92 /// A single integer representing the Major/Minor/Patch version.
93 int constexpr version() {
94  static_assert(version_minor() < internal::kMaxMinorVersions,
95  "version_minor() should be < kMaxMinorVersions");
96  static_assert(version_patch() < internal::kMaxPatchVersions,
97  "version_patch() should be < kMaxPatchVersions");
98  return internal::kMaxPatchVersions *
99  (internal::kMaxMinorVersions * version_major() + version_minor()) +
101 }
102 
103 /// The version as a string, in MAJOR.MINOR.PATCH+gitrev format.
104 std::string version_string();
105 
107 // TODO(#7463) - remove backwards compatibility namespaces
108 namespace v1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls)
109 namespace gcpcxxV1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls)
110 } // namespace cloud
111 } // namespace google
112 
113 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VERSION_H