Google Cloud Spanner C++ Client
A C++ Client Library for Google Cloud Spanner
database.cc
Go to the documentation of this file.
1 // Copyright 2019 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 
16 #include <array>
17 
18 namespace google {
19 namespace cloud {
20 namespace spanner {
21 inline namespace SPANNER_CLIENT_NS {
22 
23 Database::Database(Instance instance, std::string database_id)
24  : instance_(std::move(instance)), database_id_(std::move(database_id)) {}
25 
26 Database::Database(std::string project_id, std::string instance_id,
27  std::string database_id)
28  : Database(Instance(std::move(project_id), std::move(instance_id)),
29  std::move(database_id)) {}
30 
31 std::string Database::FullName() const {
32  return instance().FullName() + "/databases/" + database_id_;
33 }
34 
35 bool operator==(Database const& a, Database const& b) {
36  return a.instance_ == b.instance_ && a.database_id_ == b.database_id_;
37 }
38 
39 bool operator!=(Database const& a, Database const& b) { return !(a == b); }
40 
41 std::ostream& operator<<(std::ostream& os, Database const& dn) {
42  return os << dn.FullName();
43 }
44 
45 } // namespace SPANNER_CLIENT_NS
46 } // namespace spanner
47 } // namespace cloud
48 } // namespace google
bool operator!=(Backup const &a, Backup const &b)
Definition: backup.cc:33
Database(Instance instance, std::string database_id)
Constructs a Database object identified by the given database_id and instance.
Definition: database.cc:23
This class identifies a Cloud Spanner Instance.
Definition: instance.h:41
bool operator==(Backup const &a, Backup const &b)
Definition: backup.cc:29
Instance const & instance() const
Returns the Instance containing this database.
Definition: database.h:74
Contains all the Cloud Spanner C++ client types and functions.
#define SPANNER_CLIENT_NS
Definition: version.h:22
This class identifies a Cloud Spanner Database.
Definition: database.h:43
std::string FullName() const
Returns the fully qualified instance name as a string of the form: "projects/<project-id>/instances/<...
Definition: instance.cc:27
std::string FullName() const
Returns the fully qualified database name as a string of the form: "projects/<project-id>/instances/<...
Definition: database.cc:31
std::ostream & operator<<(std::ostream &os, Backup const &bn)
Definition: backup.cc:35