Google Cloud C++ Client 2.10.1
C++ Client Library for Google Cloud Platform
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
google::cloud::StreamRange< T > Class Template Reference

A StreamRange<T> is a range of StatusOr<T> where the end-of-stream is indicated by a non-OK Status. More...

#include <google/cloud/stream_range.h>

Classes

class  IteratorImpl
 An input iterator for a StreamRange<T> – DO NOT USE DIRECTLY. More...
 

Public Types

using value_type = StatusOr< T >
 
using iterator = IteratorImpl< value_type >
 
using difference_type = typename iterator::difference_type
 
using reference = typename iterator::reference
 
using pointer = typename iterator::pointer
 
using const_reference = typename iterator::const_reference
 
using const_pointer = typename iterator::const_pointer
 

Public Member Functions

 StreamRange ()=default
 Default-constructs an empty range. More...
 
 ~StreamRange ()
 
iterator begin ()
 
iterator end ()
 
Move-only
 StreamRange (StreamRange const &)=delete
 
StreamRangeoperator= (StreamRange const &)=delete
 
 StreamRange (StreamRange &&)=default
 
StreamRangeoperator= (StreamRange &&)=default
 

Detailed Description

template<typename T>
class google::cloud::StreamRange< T >

A StreamRange<T> is a range of StatusOr<T> where the end-of-stream is indicated by a non-OK Status.

Callers can iterate the range using its begin() and end() members to access iterators that will work with any normal C++ constructs and algorithms that accept Input Iterators.

Callers should only consume/iterate this range.

Example: Iterating a range of 10 integers
// Some function that returns a StreamRange<int>
StreamRange<int> MakeRangeFromOneTo(int n);
StreamRange<int> sr = MakeRangeFromOneTo(10);
for (StatusOr<int> const& x : sr) {
if (!x) {
std::cerr << "Fail: " << x.status() << "\n";
} else {
std::cout << *x << "\n";
}
}
Holds a value or a Status indicating why there is no value.
Definition: status_or.h:89
A StreamRange<T> is a range of StatusOr<T> where the end-of-stream is indicated by a non-OK Status.
Definition: stream_range.h:96
Note
To construct a StreamRange<T> for testing (e.g. to mock a Connection::ListFoo call), see google::cloud::mocks::MakeStreamRange.

Member Typedef Documentation

◆ const_pointer

template<typename T >
using google::cloud::StreamRange< T >::const_pointer = typename iterator::const_pointer

◆ const_reference

template<typename T >
using google::cloud::StreamRange< T >::const_reference = typename iterator::const_reference

◆ difference_type

template<typename T >
using google::cloud::StreamRange< T >::difference_type = typename iterator::difference_type

◆ iterator

template<typename T >
using google::cloud::StreamRange< T >::iterator = IteratorImpl<value_type>

◆ pointer

template<typename T >
using google::cloud::StreamRange< T >::pointer = typename iterator::pointer

◆ reference

template<typename T >
using google::cloud::StreamRange< T >::reference = typename iterator::reference

◆ value_type

template<typename T >
using google::cloud::StreamRange< T >::value_type = StatusOr<T>

Constructor & Destructor Documentation

◆ StreamRange() [1/3]

template<typename T >
google::cloud::StreamRange< T >::StreamRange ( )
default

Default-constructs an empty range.

◆ ~StreamRange()

template<typename T >
google::cloud::StreamRange< T >::~StreamRange ( )
inline

◆ StreamRange() [2/3]

template<typename T >
google::cloud::StreamRange< T >::StreamRange ( StreamRange< T > const &  )
delete

◆ StreamRange() [3/3]

template<typename T >
google::cloud::StreamRange< T >::StreamRange ( StreamRange< T > &&  )
default

Member Function Documentation

◆ begin()

template<typename T >
iterator google::cloud::StreamRange< T >::begin ( )
inline

◆ end()

template<typename T >
iterator google::cloud::StreamRange< T >::end ( )
inline

◆ operator=() [1/2]

template<typename T >
StreamRange & google::cloud::StreamRange< T >::operator= ( StreamRange< T > &&  )
default

◆ operator=() [2/2]

template<typename T >
StreamRange & google::cloud::StreamRange< T >::operator= ( StreamRange< T > const &  )
delete