15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_KEYS_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_KEYS_H
18#include "google/cloud/spanner/value.h"
19#include "google/cloud/spanner/version.h"
20#include <google/spanner/v1/keys.pb.h>
26namespace spanner_internal {
27GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
28struct KeySetInternals;
29GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
33GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
36
37
38
39
40
41
42using Key = std::vector<
Value>;
45
46
47
48
49
50template <
typename... Ts>
52 return Key{
Value(std::forward<Ts>(ts))...};
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
84 KeyBound(Key key,
Bound bound) : key_(std::move(key)), bound_(bound) {}
95 Key
const&
key()
const& {
return key_; }
98 Key&&
key() && {
return std::move(key_); }
117
118
119
120
121
122
123template <
typename... Ts>
129
130
131
132
133
134
135template <
typename... Ts>
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
160
161
162
163
164
167 ks.proto_.set_all(
true);
181
182
183
184
185
189
190
191
192
193
203 friend struct spanner_internal::KeySetInternals;
204 explicit KeySet(
google::spanner::v1::KeySet proto)
205 : proto_(std::move(proto)) {}
207 google::spanner::v1::KeySet proto_;
210GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
213namespace spanner_internal {
214GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
215struct KeySetInternals {
217 return std::move(ks.proto_);
226 return KeySetInternals::ToProto(std::move(ks));
230 return KeySetInternals::FromProto(std::move(ks));
233GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
The KeyBound class is a regular type that represents an open or closed endpoint for a range of keys.
Definition: keys.h:74
KeyBound(KeyBound const &)=default
Key const & key() const &
Returns the Key.
Definition: keys.h:95
KeyBound & operator=(KeyBound const &)=default
Bound bound() const
Returns the Bound.
Definition: keys.h:101
KeyBound()=delete
Not default constructible.
KeyBound & operator=(KeyBound &&)=default
friend bool operator==(KeyBound const &a, KeyBound const &b)
Bound
An enum indicating whether the Key is included (closed) or excluded (open).
Definition: keys.h:78
friend bool operator!=(KeyBound const &a, KeyBound const &b)
Definition: keys.h:106
KeyBound(KeyBound &&)=default
KeyBound(Key key, Bound bound)
Constructs an instance with the given key and bound.
Definition: keys.h:84
Key && key() &&
Returns the Key (by move).
Definition: keys.h:98
The KeySet class is a regular type that represents a collection of Keys.
Definition: keys.h:157
KeySet & AddKey(Key key)
Adds the given key to the KeySet.
KeySet & operator=(KeySet &&)=default
static KeySet All()
Returns a KeySet that represents the set of "All" keys for the index.
Definition: keys.h:165
friend bool operator!=(KeySet const &a, KeySet const &b)
Definition: keys.h:199
KeySet()=default
Constructs an empty KeySet.
KeySet & operator=(KeySet const &)=default
KeySet & AddRange(KeyBound start, KeyBound end)
Adds a range of keys defined by the given KeyBounds.
KeySet(KeySet const &)=default
friend bool operator==(KeySet const &a, KeySet const &b)
KeySet(KeySet &&)=default
The Value class represents a type-safe, nullable Spanner value.
Definition: value.h:170
Contains all the Cloud Spanner C++ client types and functions.
Definition: backoff_policy.h:23
KeyBound MakeKeyBoundClosed(Ts &&... ts)
Returns a "closed" KeyBound with a Key constructed from the given arguments.
Definition: keys.h:124
KeyBound MakeKeyBoundOpen(Ts &&... ts)
Returns an "open" KeyBound with a Key constructed from the given arguments.
Definition: keys.h:136
Key MakeKey(Ts &&... ts)
Constructs a Key from the given arguments.
Definition: keys.h:51