Loading...
Searching...
No Matches
bucket.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <mongocxx/gridfs/bucket-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/gridfs/bucket.hpp> // IWYU pragma: export
#include <cstddef>
#include <istream>
#include <memory> // IWYU pragma: keep: backward compatibility, to be removed.
#include <ostream>
#include <utility>
#include <mongocxx/database-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/document/view_or_value.hpp>
#include <bsoncxx/stdx/optional.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/stdx/string_view.hpp>
#include <bsoncxx/types/bson_value/view.hpp>
#include <mongocxx/client_session.hpp>
#include <mongocxx/cursor.hpp>
#include <mongocxx/gridfs/downloader.hpp>
#include <mongocxx/gridfs/uploader.hpp>
#include <mongocxx/options/find.hpp>
#include <mongocxx/options/gridfs/bucket.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <mongocxx/options/gridfs/upload.hpp>
#include <mongocxx/result/gridfs/upload.hpp>
#include <mongocxx/config/prelude.hpp>
namespace mongocxx {
namespace v_noabi {
namespace gridfs {
class bucket {
private:
v1::gridfs::bucket _bucket;
public:
bucket() noexcept {}
bucket(bucket&& other) noexcept = default;
bucket& operator=(bucket&& other) noexcept = default;
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE() bucket(bucket const& other);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bucket&) operator=(bucket const& other);
~bucket() = default;
/* explicit(false) */ bucket(v1::gridfs::bucket bucket) : _bucket{std::move(bucket)} {}
explicit operator v1::gridfs::bucket() && {
return std::move(_bucket);
}
explicit operator v1::gridfs::bucket() const& {
return _bucket;
}
explicit operator bool() const noexcept {
return _bucket.operator bool();
}
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::gridfs::uploader)
open_upload_stream(
bsoncxx::v_noabi::stdx::string_view filename,
v_noabi::options::gridfs::upload const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::gridfs::uploader)
open_upload_stream(
v_noabi::client_session const& session,
bsoncxx::v_noabi::stdx::string_view filename,
v_noabi::options::gridfs::upload const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(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 = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::gridfs::uploader)
open_upload_stream_with_id(
v_noabi::client_session const& session,
bsoncxx::v_noabi::types::view id,
bsoncxx::v_noabi::stdx::string_view filename,
v_noabi::options::gridfs::upload const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(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 = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::result::gridfs::upload)
upload_from_stream(
v_noabi::client_session const& session,
bsoncxx::v_noabi::stdx::string_view filename,
std::istream* source,
v_noabi::options::gridfs::upload const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(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 = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
upload_from_stream_with_id(
v_noabi::client_session const& session,
bsoncxx::v_noabi::types::view id,
bsoncxx::v_noabi::stdx::string_view filename,
std::istream* source,
v_noabi::options::gridfs::upload const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::gridfs::downloader)
open_download_stream(bsoncxx::v_noabi::types::view id);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::gridfs::downloader)
open_download_stream(v_noabi::client_session const& session, bsoncxx::v_noabi::types::view id);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
download_to_stream(bsoncxx::v_noabi::types::view id, std::ostream* destination);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
download_to_stream(bsoncxx::v_noabi::types::view id, std::ostream* destination, std::size_t start, std::size_t end);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
download_to_stream(
v_noabi::client_session const& session,
bsoncxx::v_noabi::types::view id,
std::ostream* destination);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
download_to_stream(
v_noabi::client_session const& session,
bsoncxx::v_noabi::types::view id,
std::ostream* destination,
std::size_t start,
std::size_t end);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void) delete_file(bsoncxx::v_noabi::types::view id);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(void)
delete_file(v_noabi::client_session const& session, bsoncxx::v_noabi::types::view id);
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
find(bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::cursor)
find(
v_noabi::client_session const& session,
bsoncxx::v_noabi::document::view_or_value filter,
v_noabi::options::find const& options = {});
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(bsoncxx::v_noabi::stdx::string_view) bucket_name() const;
};
} // namespace gridfs
} // namespace v_noabi
} // namespace mongocxx
namespace mongocxx {
namespace v_noabi {
inline v_noabi::gridfs::bucket from_v1(v1::gridfs::bucket v) {
return {std::move(v)};
}
inline v1::gridfs::bucket to_v1(v_noabi::gridfs::bucket v) {
return v1::gridfs::bucket{std::move(v)};
}
} // namespace v_noabi
} // namespace mongocxx
#include <mongocxx/config/postlude.hpp>
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
mongocxx::gridfs::bucket::bucket
bucket() noexcept
Default constructs a bucket object. The bucket is equivalent to the state of a moved from bucket....
Definition bucket.hpp:84
mongocxx::v1::gridfs::bucket
A GridFS bucket.
Definition bucket.hpp:60
mongocxx::v_noabi::client_session
Supports MongoDB client session operations.
Definition client_session.hpp:58
mongocxx::v_noabi::cursor
A cursor over the documents returned by a query to a MongoDB server.
Definition cursor.hpp:50
mongocxx::v_noabi::gridfs::bucket
A GridFS bucket.
Definition bucket.hpp:74
mongocxx::v_noabi::gridfs::bucket::upload_from_stream_with_id
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.
mongocxx::v_noabi::gridfs::bucket::bucket
bucket(bucket &&other) noexcept=default
Move constructs a bucket.
mongocxx::v_noabi::gridfs::bucket::open_download_stream
v_noabi::gridfs::downloader open_download_stream(bsoncxx::v_noabi::types::view id)
Opens a gridfs::downloader to read a GridFS file.
mongocxx::v_noabi::gridfs::bucket::open_upload_stream
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...
mongocxx::v_noabi::gridfs::bucket::bucket
bucket() noexcept
Default constructs a bucket object. The bucket is equivalent to the state of a moved from bucket....
Definition bucket.hpp:84
mongocxx::v_noabi::gridfs::bucket::delete_file
void delete_file(bsoncxx::v_noabi::types::view id)
Deletes a GridFS file from the bucket.
mongocxx::v_noabi::gridfs::bucket::download_to_stream
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.
mongocxx::v_noabi::gridfs::bucket::operator=
bucket & operator=(bucket &&other) noexcept=default
Move assigns a bucket.
mongocxx::v_noabi::gridfs::bucket::find
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.
mongocxx::v_noabi::gridfs::bucket::upload_from_stream
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...
mongocxx::v_noabi::gridfs::bucket::bucket_name
bsoncxx::v_noabi::stdx::string_view bucket_name() const
Gets the name of the GridFS bucket.
mongocxx::v_noabi::gridfs::bucket::open_upload_stream_with_id
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.
mongocxx::v_noabi::gridfs::downloader
Used to download a GridFS file.
Definition downloader.hpp:54
mongocxx::v_noabi::gridfs::uploader
Used to upload a GridFS file.
Definition uploader.hpp:49
mongocxx::v_noabi::result::gridfs::upload
The result of a GridFS upload operation.
Definition upload.hpp:37
view_or_value.hpp
Provides bsoncxx::v_noabi::document::view_or_value.
find.hpp
Provides mongocxx::v_noabi::options::find.
MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE
#define MONGOCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to MONGOCXX_ABI_EXPORT_UNSTABLE with MONGOCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The mongocxx v_noabi macro guard postlude header.
prelude.hpp
The mongocxx v_noabi macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v_noabi::gridfs
Declares entities related to GridFS.
mongocxx::v_noabi::options
Declares entities representing options to use with various commands.
mongocxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
mongocxx::v_noabi::to_v1
v1::bulk_write to_v1(v_noabi::bulk_write v)
Convert to the mongocxx::v1 equivalent of v.
Definition bulk_write.hpp:162
mongocxx::v_noabi::from_v1
v_noabi::bulk_write from_v1(v1::bulk_write v)
Convert to the mongocxx::v_noabi equivalent of v.
Definition bulk_write.hpp:155
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
upload.hpp
Provides mongocxx::v_noabi::options::gridfs::upload.
upload.hpp
Provides mongocxx::v_noabi::result::gridfs::upload.
bucket.hpp
Provides mongocxx::v1::gridfs::bucket.
optional.hpp
Provides std::optional-related polyfills for library API usage.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
view.hpp
Provides bsoncxx::v_noabi::types::bson_value::view.
client_session.hpp
Provides mongocxx::v_noabi::client_session.
cursor.hpp
Provides mongocxx::v_noabi::cursor.
database-fwd.hpp
Declares mongocxx::v_noabi::database.
bucket-fwd.hpp
Declares mongocxx::v_noabi::gridfs::bucket.
downloader.hpp
Provides utilities to download GridFS files.
uploader.hpp
Provides utilities to upload GridFS files.
bucket.hpp
Provides mongocxx::v_noabi::options::gridfs::bucket.