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/v1/gridfs/bucket-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/document/view-fwd.hpp>
#include <bsoncxx/v1/types/view-fwd.hpp>
#include <mongocxx/v1/client_session-fwd.hpp>
#include <mongocxx/v1/cursor-fwd.hpp>
#include <mongocxx/v1/gridfs/downloader-fwd.hpp>
#include <mongocxx/v1/gridfs/upload_result-fwd.hpp>
#include <mongocxx/v1/gridfs/uploader-fwd.hpp>
#include <mongocxx/v1/read_concern-fwd.hpp>
#include <mongocxx/v1/read_preference-fwd.hpp>
#include <mongocxx/v1/write_concern-fwd.hpp>
#include <bsoncxx/v1/stdx/optional.hpp>
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <mongocxx/v1/find_options.hpp>
#include <mongocxx/v1/gridfs/upload_options.hpp>
#include <cstddef>
#include <cstdint>
#include <istream>
#include <ostream>
#include <string>
#include <system_error>
#include <type_traits>
namespace mongocxx {
namespace v1 {
namespace gridfs {
class bucket {
private:
class impl;
void* _impl;
public:
class options;
MONGOCXX_ABI_EXPORT_CDECL() ~bucket();
MONGOCXX_ABI_EXPORT_CDECL() bucket(bucket&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(bucket&) operator=(bucket&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() bucket(bucket const& other);
MONGOCXX_ABI_EXPORT_CDECL(bucket&) operator=(bucket const& other);
MONGOCXX_ABI_EXPORT_CDECL() bucket();
explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::uploader) open_upload_stream(
bsoncxx::v1::stdx::string_view filename,
v1::gridfs::upload_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::uploader) open_upload_stream(
v1::client_session const& session,
bsoncxx::v1::stdx::string_view filename,
v1::gridfs::upload_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::uploader) open_upload_stream_with_id(
bsoncxx::v1::types::view id,
bsoncxx::v1::stdx::string_view filename,
v1::gridfs::upload_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::uploader) open_upload_stream_with_id(
v1::client_session const& session,
bsoncxx::v1::types::view id,
bsoncxx::v1::stdx::string_view filename,
v1::gridfs::upload_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::upload_result) upload_from_stream(
bsoncxx::v1::stdx::string_view filename,
std::istream& input,
v1::gridfs::upload_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::upload_result) upload_from_stream(
v1::client_session const& session,
bsoncxx::v1::stdx::string_view filename,
std::istream& input,
v1::gridfs::upload_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(void) upload_from_stream_with_id(
bsoncxx::v1::types::view id,
bsoncxx::v1::stdx::string_view filename,
std::istream& input,
v1::gridfs::upload_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(void) upload_from_stream_with_id(
v1::client_session const& session,
bsoncxx::v1::types::view id,
bsoncxx::v1::stdx::string_view filename,
std::istream& input,
v1::gridfs::upload_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::downloader) open_download_stream(bsoncxx::v1::types::view id);
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::downloader) open_download_stream(
v1::client_session const& session,
bsoncxx::v1::types::view id);
MONGOCXX_ABI_EXPORT_CDECL(void) download_to_stream(bsoncxx::v1::types::view id, std::ostream& output);
MONGOCXX_ABI_EXPORT_CDECL(void)
download_to_stream(v1::client_session const& session, bsoncxx::v1::types::view id, std::ostream& output);
MONGOCXX_ABI_EXPORT_CDECL(void)
download_to_stream(bsoncxx::v1::types::view id, std::ostream& output, std::size_t start, std::size_t end);
MONGOCXX_ABI_EXPORT_CDECL(void) download_to_stream(
v1::client_session const& session,
bsoncxx::v1::types::view id,
std::ostream& output,
std::size_t start,
std::size_t end);
MONGOCXX_ABI_EXPORT_CDECL(void) delete_file(bsoncxx::v1::types::view id);
MONGOCXX_ABI_EXPORT_CDECL(void) delete_file(v1::client_session const& session, bsoncxx::v1::types::view id);
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor) find(bsoncxx::v1::document::view filter, v1::find_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(v1::cursor)
find(v1::client_session const& session, bsoncxx::v1::document::view filter, v1::find_options const& opts = {});
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::string_view) bucket_name() const;
enum class errc {
zero,
invalid_bucket_name,
invalid_chunk_size_bytes,
not_found,
corrupt_data,
invalid_byte_range,
};
static MONGOCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
friend std::error_code make_error_code(errc v) {
return {static_cast<int>(v), error_category()};
}
class internal;
private:
/* explicit(false) */ bucket(void* impl);
};
class bucket::options {
private:
class impl;
void* _impl;
public:
MONGOCXX_ABI_EXPORT_CDECL() ~options();
MONGOCXX_ABI_EXPORT_CDECL() options(options&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL() options(options const& other);
MONGOCXX_ABI_EXPORT_CDECL(options&) operator=(options const& other);
MONGOCXX_ABI_EXPORT_CDECL() options();
MONGOCXX_ABI_EXPORT_CDECL(options&) bucket_name(std::string v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<bsoncxx::v1::stdx::string_view>) bucket_name() const;
MONGOCXX_ABI_EXPORT_CDECL(options&) chunk_size_bytes(std::int32_t v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<std::int32_t>) chunk_size_bytes() const;
MONGOCXX_ABI_EXPORT_CDECL(options&) read_concern(v1::read_concern v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::read_concern>) read_concern() const;
MONGOCXX_ABI_EXPORT_CDECL(options&) read_preference(v1::read_preference v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::read_preference>) read_preference() const;
MONGOCXX_ABI_EXPORT_CDECL(options&) write_concern(v1::write_concern v);
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v1::stdx::optional<v1::write_concern>) write_concern() const;
class internal;
private:
/* explicit(false) */ options(void* impl);
};
} // namespace gridfs
} // namespace v1
} // namespace mongocxx
namespace std {
template <>
struct is_error_code_enum<mongocxx::v1::gridfs::bucket::errc> : true_type {};
} // namespace std
#include <mongocxx/v1/detail/postlude.hpp>
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
bsoncxx::v1::types::view
A non-owning, read-only union of BSON type values.
Definition view.hpp:979
mongocxx::v1::client_session
A MongoDB client session.
Definition client_session.hpp:46
mongocxx::v1::cursor
A MongoDB cursor.
Definition cursor.hpp:39
mongocxx::v1::find_options
Options for a "find" command.
Definition find_options.hpp:72
mongocxx::v1::gridfs::bucket::options
Options for mongocxx::v1::gridfs::bucket.
Definition bucket.hpp:335
mongocxx::v1::gridfs::bucket::options::read_concern
options & read_concern(v1::read_concern v)
Set the "readConcern" field.
mongocxx::v1::gridfs::bucket::options::options
options(options &&other) noexcept
Move constructor.
mongocxx::v1::gridfs::bucket::options::~options
~options()
Destroy this object.
mongocxx::v1::gridfs::bucket::options::chunk_size_bytes
options & chunk_size_bytes(std::int32_t v)
Set the "chunkSizeBytes" field.
mongocxx::v1::gridfs::bucket::options::bucket_name
options & bucket_name(std::string v)
Set the "bucketName" field.
mongocxx::v1::gridfs::bucket::options::write_concern
options & write_concern(v1::write_concern v)
Set the "writeConcern" field.
mongocxx::v1::gridfs::bucket::options::read_preference
options & read_preference(v1::read_preference v)
Set the "readPreference" field.
mongocxx::v1::gridfs::bucket::~bucket
~bucket()
Destroy this object.
mongocxx::v1::gridfs::bucket::errc
errc
Errors codes which may be returned by mongocxx::v1::gridfs::bucket.
Definition bucket.hpp:294
mongocxx::v1::gridfs::bucket::errc::not_found
@ not_found
The requested GridFS file does not exist.
Definition bucket.hpp:298
mongocxx::v1::gridfs::bucket::errc::invalid_bucket_name
@ invalid_bucket_name
The "bucketName" field must not be empty.
Definition bucket.hpp:296
mongocxx::v1::gridfs::bucket::errc::corrupt_data
@ corrupt_data
The GridFS file is in an invalid or inconsistent state.
Definition bucket.hpp:299
mongocxx::v1::gridfs::bucket::errc::zero
@ zero
Zero.
Definition bucket.hpp:295
mongocxx::v1::gridfs::bucket::errc::invalid_byte_range
@ invalid_byte_range
[start, end) must be a valid range of byte indexes within the requested GridFS file.
Definition bucket.hpp:300
mongocxx::v1::gridfs::bucket::errc::invalid_chunk_size_bytes
@ invalid_chunk_size_bytes
The "chunkSizeBytes" field must be a positive value.
Definition bucket.hpp:297
mongocxx::v1::gridfs::bucket::find
v1::cursor find(bsoncxx::v1::document::view filter, v1::find_options const &opts={})
Find files within this bucket matching the given query filter.
mongocxx::v1::gridfs::bucket::bucket_name
bsoncxx::v1::stdx::string_view bucket_name() const
Return the name of this bucket.
mongocxx::v1::gridfs::bucket::open_download_stream
v1::gridfs::downloader open_download_stream(bsoncxx::v1::types::view id)
Return a downloader for the requested file from this bucket.
mongocxx::v1::gridfs::bucket::open_upload_stream_with_id
v1::gridfs::uploader open_upload_stream_with_id(v1::client_session const &session, bsoncxx::v1::types::view id, bsoncxx::v1::stdx::string_view filename, v1::gridfs::upload_options const &opts={})
Return an uploader for a new file to this bucket.
mongocxx::v1::gridfs::bucket::bucket
bucket(bucket &&other) noexcept
Move constructor.
mongocxx::v1::gridfs::bucket::upload_from_stream
v1::gridfs::upload_result upload_from_stream(bsoncxx::v1::stdx::string_view filename, std::istream &input, v1::gridfs::upload_options const &opts={})
Equivalent to upload_from_stream_with_id with a file ID generated using bsoncxx::v1::oid.
mongocxx::v1::gridfs::bucket::open_download_stream
v1::gridfs::downloader open_download_stream(v1::client_session const &session, bsoncxx::v1::types::view id)
Return a downloader for the requested file from this bucket.
mongocxx::v1::gridfs::bucket::upload_from_stream_with_id
void upload_from_stream_with_id(v1::client_session const &session, bsoncxx::v1::types::view id, bsoncxx::v1::stdx::string_view filename, std::istream &input, v1::gridfs::upload_options const &opts={})
Upload the contents of input as a new file to this bucket.
mongocxx::v1::gridfs::bucket::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition bucket.hpp:311
mongocxx::v1::gridfs::bucket::open_upload_stream
v1::gridfs::uploader open_upload_stream(v1::client_session const &session, bsoncxx::v1::stdx::string_view filename, v1::gridfs::upload_options const &opts={})
Equivalent to open_upload_stream_with_id with a file ID generated using bsoncxx::v1::oid.
mongocxx::v1::gridfs::bucket::delete_file
void delete_file(bsoncxx::v1::types::view id)
Delete the requested file from this bucket.
mongocxx::v1::gridfs::bucket::open_upload_stream
v1::gridfs::uploader open_upload_stream(bsoncxx::v1::stdx::string_view filename, v1::gridfs::upload_options const &opts={})
Equivalent to open_upload_stream_with_id with a file ID generated using bsoncxx::v1::oid.
mongocxx::v1::gridfs::bucket::download_to_stream
void download_to_stream(bsoncxx::v1::types::view id, std::ostream &output)
Download the entire contents of the requested file from this bucket into output.
mongocxx::v1::gridfs::bucket::open_upload_stream_with_id
v1::gridfs::uploader open_upload_stream_with_id(bsoncxx::v1::types::view id, bsoncxx::v1::stdx::string_view filename, v1::gridfs::upload_options const &opts={})
Return an uploader for a new file to this bucket.
mongocxx::v1::gridfs::bucket::bucket
bucket()
Default initialization.
mongocxx::v1::gridfs::bucket::upload_from_stream_with_id
void upload_from_stream_with_id(bsoncxx::v1::types::view id, bsoncxx::v1::stdx::string_view filename, std::istream &input, v1::gridfs::upload_options const &opts={})
Upload the contents of input as a new file to this bucket.
mongocxx::v1::gridfs::bucket::upload_from_stream
v1::gridfs::upload_result upload_from_stream(v1::client_session const &session, bsoncxx::v1::stdx::string_view filename, std::istream &input, v1::gridfs::upload_options const &opts={})
Equivalent to upload_from_stream_with_id with a file ID generated using bsoncxx::v1::oid.
mongocxx::v1::gridfs::bucket::error_category
static std::error_category const & error_category()
The error category for mongocxx::v1::gridfs::bucket::errc.
mongocxx::v1::gridfs::downloader
Support for downloading files from a GridFS bucket.
Definition downloader.hpp:42
mongocxx::v1::gridfs::upload_options
Options related to uploading a file to a GridFS bucket.
Definition upload_options.hpp:46
mongocxx::v1::gridfs::upload_result
Result of uploading a file to a GridFS bucket.
Definition upload_result.hpp:40
mongocxx::v1::gridfs::uploader
Support for uploading files to a GridFS bucket.
Definition uploader.hpp:42
find_options.hpp
Provides mongocxx::v1::find_options.
export.hpp
Provides macros to control the set of symbols exported in the ABI.
MONGOCXX_ABI_EXPORT_CDECL
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
postlude.hpp
The mongocxx v1 macro guard postlude header.
prelude.hpp
The mongocxx v1 macro guard prelude header.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
mongocxx::v1::gridfs
Declares entities related to GridFS.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
upload_options.hpp
Provides mongocxx::v1::gridfs::upload_options.
upload_result-fwd.hpp
Declares mongocxx::v1::gridfs::upload_result.
client_session-fwd.hpp
Declares mongocxx::v1::client_session.
cursor-fwd.hpp
Declares mongocxx::v1::cursor.
view-fwd.hpp
Declares bsoncxx::v1::document::view.
bucket-fwd.hpp
Declares mongocxx::v1::gridfs::bucket.
downloader-fwd.hpp
Declares mongocxx::v1::gridfs::downloader.
uploader-fwd.hpp
Declares mongocxx::v1::gridfs::uploader.
read_concern-fwd.hpp
Declares mongocxx::v1::read_concern.
read_preference-fwd.hpp
Declares mongocxx::v1::read_preference.
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-fwd.hpp
Declares non-owning, read-only entities representing a BSON type value.
write_concern-fwd.hpp
Declares mongocxx::v1::write_concern.