iterator GetNext()

in common/pagination_range.h [182:209]


  iterator GetNext() {
    static absl::Status const kPastTheEndError(absl::FailedPreconditionError(
        "Cannot iterating past the end of ListObjectReader"));
    if (current_page_.end() == current_) {
      if (on_last_page_) {
        return iterator(nullptr, kPastTheEndError);
      }
      request_.set_page_token(std::move(next_page_token_));
      auto response = next_page_loader_(request_);
      if (!response.ok()) {
        next_page_token_.clear();
        current_page_.clear();
        on_last_page_ = true;
        current_ = current_page_.begin();
        return iterator(this, std::move(response).status());
      }
      next_page_token_ = std::move(*response->mutable_next_page_token());
      current_page_ = get_items_(*std::move(response));
      current_ = current_page_.begin();
      if (next_page_token_.empty()) {
        on_last_page_ = true;
      }
      if (current_page_.end() == current_) {
        return iterator(nullptr, kPastTheEndError);
      }
    }
    return iterator(this, std::move(*current_++));
  }