Google Cloud Spanner C++ Client  2.1.0
A C++ Client Library for Google Cloud Spanner
client_options.h
Go to the documentation of this file.
1 // Copyright 2020 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_SPANNER_CLIENT_OPTIONS_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_CLIENT_OPTIONS_H
17 
18 #include "google/cloud/spanner/query_options.h"
19 #include "google/cloud/spanner/version.h"
20 #include "google/cloud/options.h"
21 
22 namespace google {
23 namespace cloud {
24 namespace spanner {
26 
27 /**
28  * ClientOptions allows the caller to set a variety of options when
29  * constructing a `Client` instance.
30  */
32  public:
33  ClientOptions() = default;
34  ClientOptions(ClientOptions const&) = default;
35  ClientOptions& operator=(ClientOptions const&) = default;
38 
39  /**
40  * Convert the `ClientOptions` to the new, recommended way to represent
41  * options of all varieties, `google::cloud::Options`.
42  */
43  explicit operator Options() const { return Options(query_options_); }
44 
45  /// Returns the `QueryOptions`
46  QueryOptions const& query_options() const { return query_options_; }
47 
48  /// Sets the `QueryOptions`
50  query_options_ = std::move(qo);
51  return *this;
52  }
53 
54  friend bool operator==(ClientOptions const& a, ClientOptions const& b) {
55  return a.query_options_ == b.query_options_;
56  }
57 
58  friend bool operator!=(ClientOptions const& a, ClientOptions const& b) {
59  return !(a == b);
60  }
61 
62  private:
63  QueryOptions query_options_;
64 };
65 
67 } // namespace spanner
68 } // namespace cloud
69 } // namespace google
70 
71 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_CLIENT_OPTIONS_H