Google Cloud Storage C++ Client  1.31.1
A C++ Client Library for Google Cloud Storage
Public Member Functions | List of all members
google::cloud::storage::v1::ObjectReadStream Class Reference

Defines a std::basic_istream<char> to read from a GCS Object. More...

#include <google/cloud/storage/object_read_stream.h>

Public Member Functions

 ObjectReadStream ()
 Creates a stream not associated with any buffer. More...
 
 ObjectReadStream (std::unique_ptr< internal::ObjectReadStreambuf > buf)
 Creates a stream associated with the given streambuf. More...
 
 ObjectReadStream (ObjectReadStream &&rhs) noexcept
 
ObjectReadStreamoperator= (ObjectReadStream &&rhs) noexcept
 
void swap (ObjectReadStream &rhs)
 
 ObjectReadStream (ObjectReadStream const &)=delete
 
ObjectReadStreamoperator= (ObjectReadStream const &)=delete
 
 ~ObjectReadStream () override
 Closes the stream (if necessary). More...
 
bool IsOpen () const
 
void Close ()
 Terminate the download, possibly before completing it. More...
 
Status const & status () const &
 Report any download errors. More...
 
std::string const & received_hash () const
 The received CRC32C checksum and the MD5 hash values as reported by GCS. More...
 
std::string const & computed_hash () const
 The locally computed checksum and hashes, as a string. More...
 
HeadersMap const & headers () const
 The headers (if any) returned by the service. More...
 

Detailed Description

Defines a std::basic_istream<char> to read from a GCS Object.

Definition at line 36 of file object_read_stream.h.

Constructor & Destructor Documentation

◆ ObjectReadStream() [1/4]

google::cloud::storage::v1::ObjectReadStream::ObjectReadStream ( )

Creates a stream not associated with any buffer.

Attempts to use this stream will result in failures.

Definition at line 36 of file object_read_stream.cc.

◆ ObjectReadStream() [2/4]

google::cloud::storage::v1::ObjectReadStream::ObjectReadStream ( std::unique_ptr< internal::ObjectReadStreambuf >  buf)
inlineexplicit

Creates a stream associated with the given streambuf.

Definition at line 48 of file object_read_stream.h.

◆ ObjectReadStream() [3/4]

google::cloud::storage::v1::ObjectReadStream::ObjectReadStream ( ObjectReadStream &&  rhs)
noexcept

Definition at line 38 of file object_read_stream.cc.

◆ ObjectReadStream() [4/4]

google::cloud::storage::v1::ObjectReadStream::ObjectReadStream ( ObjectReadStream const &  )
delete

◆ ~ObjectReadStream()

google::cloud::storage::v1::ObjectReadStream::~ObjectReadStream ( )
override

Closes the stream (if necessary).

Definition at line 55 of file object_read_stream.cc.

Member Function Documentation

◆ Close()

void google::cloud::storage::v1::ObjectReadStream::Close ( )

Terminate the download, possibly before completing it.

Definition at line 73 of file object_read_stream.cc.

◆ computed_hash()

std::string const& google::cloud::storage::v1::ObjectReadStream::computed_hash ( ) const
inline

The locally computed checksum and hashes, as a string.

This object computes the CRC32C checksum and MD5 hash of the downloaded data. Note that there are several cases where these values may be empty or irrelevant, for example:

  • When reading only a portion of a blob the hash of that portion is irrelevant, note that GCS only reports the hashes for the full blob.
  • The application may disable the CRC32C and/or the MD5 hash computation.

The string has the same format as the value returned by received_hash(). Note that the format of this string is also subject to change without notice.

See also
https://cloud.google.com/storage/docs/hashes-etags for more information on checksums and hashes in GCS.

Definition at line 125 of file object_read_stream.h.

◆ headers()

HeadersMap const& google::cloud::storage::v1::ObjectReadStream::headers ( ) const
inline

The headers (if any) returned by the service.

For debugging only.

Warning
the contents of these headers may change without notice. Unless documented in the API, headers may be removed or added by the service. Also note that the client library uses both the XML and JSON API, choosing between them based on the feature set (some functionality is only available through the JSON API), and performance. Consequently, the headers may be different on requests using different features. Likewise, the headers may change from one version of the library to the next, as we find more (or different) opportunities for optimization.

Definition at line 139 of file object_read_stream.h.

◆ IsOpen()

bool google::cloud::storage::v1::ObjectReadStream::IsOpen ( ) const
inline

Definition at line 75 of file object_read_stream.h.

◆ operator=() [1/2]

ObjectReadStream& google::cloud::storage::v1::ObjectReadStream::operator= ( ObjectReadStream &&  rhs)
inlinenoexcept

Definition at line 56 of file object_read_stream.h.

◆ operator=() [2/2]

ObjectReadStream& google::cloud::storage::v1::ObjectReadStream::operator= ( ObjectReadStream const &  )
delete

◆ received_hash()

std::string const& google::cloud::storage::v1::ObjectReadStream::received_hash ( ) const
inline

The received CRC32C checksum and the MD5 hash values as reported by GCS.

When the download is finalized (via Close() or the end of file) the GCS server reports the CRC32C checksum and, except for composite objects, the MD5 hash of the data. This class compares the locally computed and received hashes so applications can detect data download errors.

The values are reported as comma separated tag=value pairs, e.g. crc32c=AAAAAA==,md5=1B2M2Y8AsgTpgAmY7PhCfg==. The format of this string is subject to change without notice, they are provided for informational purposes only.

See also
https://cloud.google.com/storage/docs/hashes-etags for more information on checksums and hashes in GCS.

Definition at line 106 of file object_read_stream.h.

◆ status()

Status const& google::cloud::storage::v1::ObjectReadStream::status ( ) const &
inline

Report any download errors.

Note that errors may go undetected until the download completes.

Definition at line 88 of file object_read_stream.h.

◆ swap()

void google::cloud::storage::v1::ObjectReadStream::swap ( ObjectReadStream rhs)
inline

Definition at line 62 of file object_read_stream.h.