15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_READ_STREAM_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OBJECT_READ_STREAM_H
18#include "google/cloud/storage/headers_map.h"
19#include "google/cloud/storage/internal/object_read_streambuf.h"
20#include "google/cloud/storage/version.h"
28GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
31
32
36
37
38
39
43
44
45 explicit ObjectReadStream(std::unique_ptr<internal::ObjectReadStreambuf> buf)
46 : std::basic_istream<
char>(
nullptr), buf_(std::move(buf)) {
60 std::basic_istream<
char>::swap(rhs);
61 std::swap(buf_, rhs.buf_);
62 rhs.set_rdbuf(rhs.buf_.get());
63 set_rdbuf(buf_.get());
72 bool IsOpen()
const {
return static_cast<
bool>(buf_) && buf_->IsOpen(); }
75
76
80
81
82
83
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 std::string
const&
received_hash()
const {
return buf_->received_hash(); }
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121 std::string
const&
computed_hash()
const {
return buf_->computed_hash(); }
124
125
126
127
128
129
130
131
132 HeadersMap
const&
headers()
const {
return buf_->headers(); }
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
154 return buf_->generation();
159 return buf_->metageneration();
164 return buf_->storage_class();
168
169
170
171
172
173
174
175
176 absl::optional<std::
uint64_t>
const&
size()
const {
return buf_->size(); }
180 std::unique_ptr<internal::ObjectReadStreambuf> buf_;
183GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
Defines a std::basic_istream<char> to read from a GCS Object.
Definition: object_read_stream.h:33
std::string const & computed_hash() const
The locally computed checksum and hashes, as a string.
Definition: object_read_stream.h:121
ObjectReadStream()
Creates a stream not associated with any buffer.
void swap(ObjectReadStream &rhs)
Definition: object_read_stream.h:59
bool IsOpen() const
Definition: object_read_stream.h:72
std::string const & received_hash() const
The received CRC32C checksum and the MD5 hash values as reported by GCS.
Definition: object_read_stream.h:102
void Close()
Terminate the download, possibly before completing it.
HeadersMap const & headers() const
The headers (if any) returned by the service.
Definition: object_read_stream.h:132
ObjectReadStream(ObjectReadStream &&rhs) noexcept
absl::optional< std::string > const & storage_class() const
The object's storage class at the time of the download, if known.
Definition: object_read_stream.h:163
Status const & status() const &
Report any download errors.
Definition: object_read_stream.h:84
ObjectReadStream & operator=(ObjectReadStream &&rhs) noexcept
Definition: object_read_stream.h:53
absl::optional< std::int64_t > const & metageneration() const
The object's metageneration at the time of the download, if known.
Definition: object_read_stream.h:158
~ObjectReadStream() override
Closes the stream (if necessary).
ObjectReadStream(ObjectReadStream const &)=delete
absl::optional< std::int64_t > const & generation() const
The object's generation at the time of the download, if known.
Definition: object_read_stream.h:153
absl::optional< std::uint64_t > const & size() const
The object's size at the time of the download, if known.
Definition: object_read_stream.h:176
ObjectReadStream(std::unique_ptr< internal::ObjectReadStreambuf > buf)
Creates a stream associated with the given streambuf.
Definition: object_read_stream.h:45
ObjectReadStream & operator=(ObjectReadStream const &)=delete
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24