Google Cloud Storage C++ Client 2.13.0
A C++ Client Library for Google Cloud Storage
Loading...
Searching...
No Matches
download_options.h
1// Copyright 2018 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_DOWNLOAD_OPTIONS_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_DOWNLOAD_OPTIONS_H
17
18#include "google/cloud/storage/internal/complex_option.h"
19#include "google/cloud/storage/version.h"
20#include <cstdint>
21#include <iostream>
22
23namespace google {
24namespace cloud {
25namespace storage {
26GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
27struct ReadRangeData {
28 std::int64_t begin;
29 std::int64_t end;
30};
31
32/**
33 * Request only a portion of the GCS object in a ReadObject operation.
34 *
35 * Note that the range is right-open, as it is customary in C++. That is, it
36 * excludes the `end` byte.
37 */
38struct ReadRange : public internal::ComplexOption<ReadRange, ReadRangeData> {
39 ReadRange() = default;
40 explicit ReadRange(std::int64_t begin, std::int64_t end)
41 : ComplexOption(ReadRangeData{begin, end}) {}
42 static char const* name() { return "read-range"; }
43};
44
45inline std::ostream& operator<<(std::ostream& os, ReadRangeData const& rhs) {
46 return os << "ReadRangeData={begin=" << rhs.begin << ", end=" << rhs.end
47 << "}";
48}
49
50/**
51 * Download all the data from the GCS object starting at the given offset.
52 */
53struct ReadFromOffset
54 : public internal::ComplexOption<ReadFromOffset, std::int64_t> {
55 using ComplexOption::ComplexOption;
56 // GCC <= 7.0 does not use the inherited default constructor, redeclare it
57 // explicitly
58 ReadFromOffset() = default;
59 static char const* name() { return "read-offset"; }
60};
61
62/**
63 * Read last N bytes from the GCS object.
64 */
65struct ReadLast : public internal::ComplexOption<ReadLast, std::int64_t> {
66 using ComplexOption::ComplexOption;
67 // GCC <= 7.0 does not use the inherited default constructor, redeclare it
68 // explicitly
69 ReadLast() = default;
70 static char const* name() { return "read-last"; }
71};
72
73GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
74} // namespace storage
75} // namespace cloud
76} // namespace google
77
78#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_DOWNLOAD_OPTIONS_H
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24
Download all the data from the GCS object starting at the given offset.
Definition: download_options.h:54
static char const * name()
Definition: download_options.h:59
Read last N bytes from the GCS object.
Definition: download_options.h:65
static char const * name()
Definition: download_options.h:70
Definition: download_options.h:27
std::int64_t begin
Definition: download_options.h:28
std::int64_t end
Definition: download_options.h:29
Request only a portion of the GCS object in a ReadObject operation.
Definition: download_options.h:38
ReadRange(std::int64_t begin, std::int64_t end)
Definition: download_options.h:40
static char const * name()
Definition: download_options.h:42