15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_BYTES_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_BYTES_H
18 #include "google/cloud/spanner/version.h"
19 #include "google/cloud/internal/base64_transforms.h"
20 #include "google/cloud/status_or.h"
28 namespace spanner_internal {
30 struct BytesInternals;
50 template <
typename InputIt>
51 Bytes(InputIt first, InputIt last) {
53 while (first != last) encoder.PushBack(*first++);
54 base64_rep_ = std::move(encoder).FlushAndPad();
56 template <
typename Container>
57 explicit Bytes(Container
const& c) :
Bytes(std::begin(c), std::end(c)) {}
62 template <
typename Container>
63 Container
get()
const {
64 google::
cloud::internal::Base64Decoder decoder(base64_rep_);
65 return Container(decoder.begin(), decoder.end());
71 return a.base64_rep_ == b.base64_rep_;
82 friend std::ostream& operator<<(std::ostream& os,
Bytes const& bytes);
87 std::string base64_rep_;
93 namespace spanner_internal {
95 StatusOr<
spanner::
Bytes> BytesFromBase64(std::string input);