MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
bucket.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
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// http://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#pragma once
16
17#include <mongocxx/gridfs/bucket-fwd.hpp> // IWYU pragma: export
18
19//
20
21#include <mongocxx/v1/gridfs/bucket.hpp> // IWYU pragma: export
22
23#include <cstddef>
24#include <istream>
25#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
26#include <ostream>
27#include <utility>
28
29#include <mongocxx/database-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
30
32#include <bsoncxx/stdx/optional.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
35
37#include <mongocxx/cursor.hpp>
41#include <mongocxx/options/gridfs/bucket.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
44
46
47namespace mongocxx {
48namespace v_noabi {
49namespace gridfs {
50
74class bucket {
75 private:
76 v1::gridfs::bucket _bucket;
77
78 public:
84 bucket() noexcept {}
85
89 bucket(bucket&& other) noexcept = default;
90
94 bucket& operator=(bucket&& other) noexcept = default;
95
100
104 MONGOCXX_ABI_EXPORT_CDECL(bucket&) operator=(bucket const& other);
105
109 ~bucket() = default;
110
114 /* explicit(false) */ bucket(v1::gridfs::bucket bucket) : _bucket{std::move(bucket)} {}
115
124 explicit operator v1::gridfs::bucket() && {
125 return std::move(_bucket);
126 }
127
131 explicit operator v1::gridfs::bucket() const& {
132 return _bucket;
133 }
134
138 explicit operator bool() const noexcept {
139 return _bucket.operator bool();
140 }
141
170 bsoncxx::v_noabi::stdx::string_view filename,
171 v_noabi::options::gridfs::upload const& options = {});
172
205 v_noabi::client_session const& session,
206 bsoncxx::v_noabi::stdx::string_view filename,
207 v_noabi::options::gridfs::upload const& options = {});
208
239 bsoncxx::v_noabi::types::view id,
240 bsoncxx::v_noabi::stdx::string_view filename,
241 v_noabi::options::gridfs::upload const& options = {});
242
277 v_noabi::client_session const& session,
278 bsoncxx::v_noabi::types::view id,
279 bsoncxx::v_noabi::stdx::string_view filename,
280 v_noabi::options::gridfs::upload const& options = {});
281
325 bsoncxx::v_noabi::stdx::string_view filename,
326 std::istream* source,
327 v_noabi::options::gridfs::upload const& options = {});
328
375 v_noabi::client_session const& session,
376 bsoncxx::v_noabi::stdx::string_view filename,
377 std::istream* source,
378 v_noabi::options::gridfs::upload const& options = {});
379
423 bsoncxx::v_noabi::types::view id,
424 bsoncxx::v_noabi::stdx::string_view filename,
425 std::istream* source,
426 v_noabi::options::gridfs::upload const& options = {});
427
474 v_noabi::client_session const& session,
475 bsoncxx::v_noabi::types::view id,
476 bsoncxx::v_noabi::stdx::string_view filename,
477 std::istream* source,
478 v_noabi::options::gridfs::upload const& options = {});
479
497
518 open_download_stream(v_noabi::client_session const& session, bsoncxx::v_noabi::types::view id);
519
541 download_to_stream(bsoncxx::v_noabi::types::view id, std::ostream* destination);
542
550 download_to_stream(bsoncxx::v_noabi::types::view id, std::ostream* destination, std::size_t start, std::size_t end);
551
577 v_noabi::client_session const& session,
578 bsoncxx::v_noabi::types::view id,
579 std::ostream* destination);
580
589 v_noabi::client_session const& session,
590 bsoncxx::v_noabi::types::view id,
591 std::ostream* destination,
592 std::size_t start,
593 std::size_t end);
594
607
623 delete_file(v_noabi::client_session const& session, bsoncxx::v_noabi::types::view id);
624
645 find(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const& options = {});
646
672 v_noabi::client_session const& session,
673 bsoncxx::v_noabi::document::view_or_value filter,
674 v_noabi::options::find const& options = {});
675
683};
684
685} // namespace gridfs
686} // namespace v_noabi
687} // namespace mongocxx
688
689namespace mongocxx {
690namespace v_noabi {
691
696 return {std::move(v)};
697}
698
703 return v1::gridfs::bucket{std::move(v)};
704}
705
706} // namespace v_noabi
707} // namespace mongocxx
708
710
A polyfill for std::string_view.
Definition string_view.hpp:412
bucket() noexcept
Default constructs a bucket object. The bucket is equivalent to the state of a moved from bucket....
Definition bucket.hpp:84
A GridFS bucket.
Definition bucket.hpp:62
Supports MongoDB client session operations.
Definition client_session.hpp:58
A cursor over the documents returned by a query to a MongoDB server.
Definition cursor.hpp:50
A GridFS bucket.
Definition bucket.hpp:74
void upload_from_stream_with_id(bsoncxx::v_noabi::types::view id, bsoncxx::v_noabi::stdx::string_view filename, std::istream *source, v_noabi::options::gridfs::upload const &options={})
Creates a new GridFS file with a user-supplied unique id by uploading bytes from an input stream.
bucket(bucket &&other) noexcept=default
Move constructs a bucket.
v_noabi::gridfs::downloader open_download_stream(bsoncxx::v_noabi::types::view id)
Opens a gridfs::downloader to read a GridFS file.
v_noabi::gridfs::uploader open_upload_stream(bsoncxx::v_noabi::stdx::string_view filename, v_noabi::options::gridfs::upload const &options={})
Opens a gridfs::uploader to create a new GridFS file. The id of the file will be automatically genera...
bucket() noexcept
Default constructs a bucket object. The bucket is equivalent to the state of a moved from bucket....
Definition bucket.hpp:84
void delete_file(bsoncxx::v_noabi::types::view id)
Deletes a GridFS file from the bucket.
void download_to_stream(bsoncxx::v_noabi::types::view id, std::ostream *destination)
Downloads the contents of a stored GridFS file from the bucket and writes it to a stream.
bucket & operator=(bucket &&other) noexcept=default
Move assigns a bucket.
v_noabi::cursor find(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const &options={})
Finds the documents in the files collection of the bucket which match the provided filter.
v_noabi::result::gridfs::upload upload_from_stream(bsoncxx::v_noabi::stdx::string_view filename, std::istream *source, v_noabi::options::gridfs::upload const &options={})
Creates a new GridFS file by uploading bytes from an input stream. The id of the file will be automat...
bsoncxx::v_noabi::stdx::string_view bucket_name() const
Gets the name of the GridFS bucket.
v_noabi::gridfs::uploader open_upload_stream_with_id(bsoncxx::v_noabi::types::view id, bsoncxx::v_noabi::stdx::string_view filename, v_noabi::options::gridfs::upload const &options={})
Opens a gridfs::uploader to create a new GridFS file.
Used to download a GridFS file.
Definition downloader.hpp:54
Used to upload a GridFS file.
Definition uploader.hpp:49
The result of a GridFS upload operation.
Definition upload.hpp:35
Provides bsoncxx::v_noabi::document::view_or_value.
Provides mongocxx::v_noabi::options::find.
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities whose ABI stability is guaranteed for documented symbols.
Declares entities related to GridFS.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
The top-level namespace within which all mongocxx library entities are declared.
Provides mongocxx::v_noabi::options::gridfs::upload.
Provides mongocxx::v_noabi::result::gridfs::upload.
Provides mongocxx::v1::gridfs::bucket.
Provides std::optional-related polyfills for library API usage.
Provides std::string_view-related polyfills for library API usage.
Provides bsoncxx::v_noabi::types::bson_value::view.
Provides mongocxx::v_noabi::client_session.
Provides mongocxx::v_noabi::cursor.
Declares mongocxx::v_noabi::database.
Declares mongocxx::v_noabi::gridfs::bucket.
Provides utilities to download GridFS files.
Provides utilities to upload GridFS files.
Provides mongocxx::v_noabi::options::gridfs::bucket.