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