16 #include "google/cloud/storage/internal/object_requests.h"
25 static_assert(std::is_move_assignable<ObjectReadStream>::value,
26 "storage::ObjectReadStream must be move assignable.");
27 static_assert(std::is_move_constructible<ObjectReadStream>::value,
28 "storage::ObjectReadStream must be move constructible.");
30 ObjectReadStream::~ObjectReadStream() {
34 #if GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS
37 }
catch (std::exception
const& ex) {
38 GCP_LOG(INFO) <<
"Ignored exception while trying to close stream: "
41 GCP_LOG(INFO) <<
"Ignored unknown exception while trying to close stream";
45 #endif // GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS
48 void ObjectReadStream::Close() {
54 setstate(std::ios_base::badbit);
58 ObjectWriteStream::ObjectWriteStream(
59 std::unique_ptr<internal::ObjectWriteStreambuf> buf)
60 : std::basic_ostream<char>(nullptr), buf_(std::move(buf)) {
64 if (!buf_->IsOpen()) {
75 exceptions(std::ios_base::goodbit);
86 void ObjectWriteStream::CloseBuf() {
87 auto response = buf_->Close();
89 metadata_ = std::move(response).status();
90 setstate(std::ios_base::badbit);
94 if (response->payload.has_value()) {
95 metadata_ = *std::move(response->payload);
97 if (metadata_ && !buf_->ValidateHash(*metadata_)) {
98 setstate(std::ios_base::badbit);