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_STORAGE_VERSION_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_VERSION_H
17
18 #include "google/cloud/storage/version_info.h"
19 #include "google/cloud/version.h"
20 #include <string>
21
22 #define STORAGE_CLIENT_NS \
23 GOOGLE_CLOUD_CPP_VEVAL(STORAGE_CLIENT_VERSION_MAJOR, \
24 STORAGE_CLIENT_VERSION_MINOR)
25
26 namespace google {
27 namespace cloud {
28 /**
29 * Contains all the Google Cloud Storage C++ client APIs.
30 */
31 namespace storage {
32 /**
33 * The Google Cloud Storage C++ client APIs inlined, versioned namespace.
34 *
35 * Applications may need to link multiple versions of the Google Cloud Storage
36 * C++ 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 * `storage::Foo` in their source, but the symbols are versioned, i.e., the
39 * symbol becomes `storage::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 STORAGE_CLIENT_NS {
45 /**
46 * Returns the Google Cloud Storage 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 STORAGE_CLIENT_VERSION_MAJOR; }
51
52 /**
53 * Returns the Google Cloud Storage 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 STORAGE_CLIENT_VERSION_MINOR; }
58
59 /**
60 * Returns the Google Cloud Storage 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 STORAGE_CLIENT_VERSION_PATCH; }
65
66 /// Returns 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 /// Returns the version as a string, in MAJOR.MINOR.PATCH+gitrev format.
78 std::string version_string();
79
80 /// Returns the value for x-goog-api-client header.
81 std::string x_goog_api_client();
82
83 } // namespace STORAGE_CLIENT_NS
84 } // namespace storage
85 } // namespace cloud
86 } // namespace google
87
88 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_VERSION_H
89