Loading...
Searching...
No Matches
uploader.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/uploader-fwd.hpp> // IWYU pragma: export
//
#include <mongocxx/v1/detail/prelude.hpp>
#include <mongocxx/v1/gridfs/upload_result-fwd.hpp>
#include <mongocxx/v1/config/export.hpp>
#include <cstddef>
#include <cstdint>
#include <system_error>
#include <type_traits>
namespace mongocxx {
namespace v1 {
namespace gridfs {
class uploader {
private:
class impl;
void* _impl;
public:
MONGOCXX_ABI_EXPORT_CDECL() ~uploader();
MONGOCXX_ABI_EXPORT_CDECL() uploader(uploader&& other) noexcept;
MONGOCXX_ABI_EXPORT_CDECL(uploader&) operator=(uploader&& other) noexcept;
uploader(uploader const& other) = delete;
uploader& operator=(uploader const& other) = delete;
MONGOCXX_ABI_EXPORT_CDECL() uploader();
explicit MONGOCXX_ABI_EXPORT_CDECL() operator bool() const;
MONGOCXX_ABI_EXPORT_CDECL(bool) is_open() const;
MONGOCXX_ABI_EXPORT_CDECL(v1::gridfs::upload_result) close();
MONGOCXX_ABI_EXPORT_CDECL(void) abort();
MONGOCXX_ABI_EXPORT_CDECL(std::int32_t) chunk_size() const;
MONGOCXX_ABI_EXPORT_CDECL(void) write(std::uint8_t const* data, std::size_t length);
MONGOCXX_ABI_EXPORT_CDECL(void) flush();
enum class errc {
zero,
is_closed,
too_many_chunks,
};
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) */ uploader(void* impl);
void save_chunk();
};
} // namespace gridfs
} // namespace v1
} // namespace mongocxx
namespace std {
template <>
struct is_error_code_enum<mongocxx::v1::gridfs::uploader::errc> : true_type {};
} // namespace std
#include <mongocxx/v1/detail/postlude.hpp>
mongocxx::v1::gridfs::upload_result
Result of uploading a file to a GridFS bucket.
Definition upload_result.hpp:40
mongocxx::v1::gridfs::uploader::abort
void abort()
Abort uploading this GridFS file.
mongocxx::v1::gridfs::uploader::close
v1::gridfs::upload_result close()
Complete the upload of this GridFS file.
mongocxx::v1::gridfs::uploader::error_category
static std::error_category const & error_category()
The error category for mongocxx::v1::gridfs::uploader::errc.
mongocxx::v1::gridfs::uploader::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition uploader.hpp:188
mongocxx::v1::gridfs::uploader::uploader
uploader(uploader &&other) noexcept
Move constructor.
mongocxx::v1::gridfs::uploader::~uploader
~uploader()
Destroy this object.
mongocxx::v1::gridfs::uploader::chunk_size
std::int32_t chunk_size() const
Return the chunk size (in bytes) of the associated GridFS file.
mongocxx::v1::gridfs::uploader::uploader
uploader()
Default initialization.
mongocxx::v1::gridfs::uploader::write
void write(std::uint8_t const *data, std::size_t length)
Write length bytes of the associated GridFS file.
mongocxx::v1::gridfs::uploader::is_open
bool is_open() const
Return true when the underlying GridFS file stream is open for writing.
mongocxx::v1::gridfs::uploader::flush
void flush()
Flush the internal buffer.
mongocxx::v1::gridfs::uploader::errc
errc
Errors codes which may be returned by mongocxx::v1::gridfs::uploader.
Definition uploader.hpp:174
mongocxx::v1::gridfs::uploader::errc::is_closed
@ is_closed
The GridFS file upload stream is not open.
Definition uploader.hpp:176
mongocxx::v1::gridfs::uploader::errc::zero
@ zero
Zero.
Definition uploader.hpp:175
mongocxx::v1::gridfs::uploader::errc::too_many_chunks
@ too_many_chunks
The total number of chunks must be less than INT32_MAX.
Definition uploader.hpp:177
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.
mongocxx::v1::gridfs
Declares entities related to GridFS.
mongocxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
mongocxx::v1::source_errc::mongocxx
@ mongocxx
From the mongocxx library.
Definition exception.hpp:40
mongocxx
The top-level namespace within which all mongocxx library entities are declared.
upload_result-fwd.hpp
Declares mongocxx::v1::gridfs::upload_result.
uploader-fwd.hpp
Declares mongocxx::v1::gridfs::uploader.