Google Cloud C++ Client 2.10.1
C++ Client Library for Google Cloud Platform
Loading...
Searching...
No Matches
version.h
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
53namespace google {
54/**
55 * Contains all the Google Cloud C++ Library APIs.
56 */
57namespace cloud {
59
60/**
61 * The Google Cloud C++ Client major version.
62 *
63 * @see https://semver.org/spec/v2.0.0.html for details.
64 */
65int constexpr version_major() { return GOOGLE_CLOUD_CPP_VERSION_MAJOR; }
66
67/**
68 * The Google Cloud C++ Client minor version.
69 *
70 * @see https://semver.org/spec/v2.0.0.html for details.
71 */
72int constexpr version_minor() { return GOOGLE_CLOUD_CPP_VERSION_MINOR; }
73
74/**
75 * The Google Cloud C++ Client patch version.
76 *
77 * @see https://semver.org/spec/v2.0.0.html for details.
78 */
79int constexpr version_patch() { return GOOGLE_CLOUD_CPP_VERSION_PATCH; }
80
81/**
82 * The Google Cloud C++ Client pre-release version.
83 *
84 * @see https://semver.org/spec/v2.0.0.html for details.
85 */
86constexpr char const* version_pre_release() {
87 return GOOGLE_CLOUD_CPP_VERSION_PRE_RELEASE;
88}
89
90namespace internal {
91auto constexpr kMaxMinorVersions = 100;
92auto constexpr kMaxPatchVersions = 100;
93} // namespace internal
94
95/// A single integer representing the Major/Minor/Patch version.
96int constexpr version() {
97 static_assert(version_minor() < internal::kMaxMinorVersions,
98 "version_minor() should be < kMaxMinorVersions");
99 static_assert(version_patch() < internal::kMaxPatchVersions,
100 "version_patch() should be < kMaxPatchVersions");
101 return internal::kMaxPatchVersions *
102 (internal::kMaxMinorVersions * version_major() + version_minor()) +
104}
105
106/// The version as a string, in MAJOR.MINOR.PATCH[-PRE][+gitrev] format.
107std::string version_string();
108
110// TODO(#7463) - remove backwards compatibility namespaces
111namespace v1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls)
112namespace gcpcxxV1 = GOOGLE_CLOUD_CPP_NS; // NOLINT(misc-unused-alias-decls)
113} // namespace cloud
114} // namespace google
115
116#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_VERSION_H
Contains all the Google Cloud C++ Library APIs.
Definition: async_operation.h:23
std::string version_string()
The version as a string, in MAJOR.MINOR.PATCH[-PRE][+gitrev] format.
int constexpr version()
A single integer representing the Major/Minor/Patch version.
Definition: version.h:96
int constexpr version_minor()
The Google Cloud C++ Client minor version.
Definition: version.h:72
int constexpr version_major()
The Google Cloud C++ Client major version.
Definition: version.h:65
constexpr char const * version_pre_release()
The Google Cloud C++ Client pre-release version.
Definition: version.h:86
int constexpr version_patch()
The Google Cloud C++ Client patch version.
Definition: version.h:79
Definition: async_operation.h:22
#define GOOGLE_CLOUD_CPP_NS
Definition: version.h:25
#define GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
Definition: version.h:45
#define GOOGLE_CLOUD_CPP_VEVAL(Ma, Mi, Pa)
Definition: version.h:24
#define GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
Definition: version.h:43
#define GOOGLE_CLOUD_CPP_VCONCAT(Ma, Mi, Pa)
Definition: version.h:23