Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,31 @@ AlignConsecutiveAssignments:
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Expand All @@ -42,20 +46,23 @@ AlignConsecutiveTableGenBreakingDAGArgColons:
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveTableGenCondOperatorColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveTableGenDefinitionColons:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionDeclarations: false
AlignFunctionPointers: false
PadOperators: false
AlignEscapedNewlines: Left
Expand All @@ -75,6 +82,7 @@ AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AllowShortNamespacesOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AttributeMacros:
Expand All @@ -90,7 +98,7 @@ AttributeMacros:
- MONGOCXX_ABI_NO_EXPORT
- MONGOCXX_DEPRECATED
BinPackArguments: false
BinPackParameters: false
BinPackParameters: OnePerLine
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
Expand Down Expand Up @@ -121,6 +129,7 @@ BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakBinaryOperations: Never
BreakConstructorInitializers: BeforeColon
BreakFunctionDefinitionParameters: false
BreakInheritanceList: BeforeColon
Expand Down Expand Up @@ -197,6 +206,7 @@ IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExportBlock: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
Expand All @@ -219,6 +229,7 @@ KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: false
AtStartOfFile: false
KeepFormFeed: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
Expand All @@ -234,6 +245,7 @@ ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakBeforeMemberAccess: 150
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
Expand All @@ -248,8 +260,9 @@ PPIndentWidth: -1
QualifierAlignment: Right
RawStringFormats: []
ReferenceAlignment: Pointer
ReflowComments: true
ReflowComments: Always
RemoveBracesLLVM: false
RemoveEmptyLinesInUnwrappedLines: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
Expand Down Expand Up @@ -324,4 +337,5 @@ TypenameMacros:
UseTab: Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros: []
WrapNamespaceBodyWithEmptyLines: Leave
...
10 changes: 6 additions & 4 deletions benchmark/benchmark_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ benchmark_runner::benchmark_runner(std::set<benchmark_type> types) : _types{type
// Single doc microbenchmarks
_microbenches.push_back(std::make_unique<run_command>());
_microbenches.push_back(std::make_unique<find_one_by_id>("single_and_multi_document/tweet.json"));
_microbenches.push_back(std::make_unique<insert_one>(
"TestSmallDocInsertOne", 2.75, iterations, "single_and_multi_document/small_doc.json"));
_microbenches.push_back(
std::make_unique<insert_one>(
"TestSmallDocInsertOne", 2.75, iterations, "single_and_multi_document/small_doc.json"));
_microbenches.push_back(
std::make_unique<insert_one>("TestLargeDocInsertOne", 27.31, 10, "single_and_multi_document/large_doc.json"));

// Multi doc microbenchmarks
_microbenches.push_back(std::make_unique<find_many>("single_and_multi_document/tweet.json"));
_microbenches.push_back(std::make_unique<bulk_insert>(
"TestSmallDocBulkInsert", 2.75, iterations, "single_and_multi_document/small_doc.json"));
_microbenches.push_back(
std::make_unique<bulk_insert>(
"TestSmallDocBulkInsert", 2.75, iterations, "single_and_multi_document/small_doc.json"));
_microbenches.push_back(
std::make_unique<bulk_insert>("TestLargeDocBulkInsert", 27.31, 10, "single_and_multi_document/large_doc.json"));
// CXX-2794: Disable GridFS benchmarks due to long runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ void example(bsoncxx::document::view kms_providers) {

auto_encryption_opts.key_vault_namespace({"keyvault", "datakeys"});
auto_encryption_opts.kms_providers(kms_providers);
auto_encryption_opts.extra_options(bsoncxx::from_json(
R"({"mongocryptdURI": "mongodb://localhost:27027", "mongocryptdSpawnArgs": ["--port", "27027"]})"));
auto_encryption_opts.extra_options(
bsoncxx::from_json(
R"({"mongocryptdURI": "mongodb://localhost:27027", "mongocryptdSpawnArgs": ["--port", "27027"]})"));
// ... other automatic encryption options.

mongocxx::options::client client_opts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ void example(mongocxx::collection coll) {
auto result_opt =
coll.create_bulk_write(opts)
.append(mongocxx::model::insert_one{bsoncxx::from_json(R"({"x": 10})")})
.append(mongocxx::model::update_one{
bsoncxx::from_json(R"({"x": {"$exists": 1}})"), bsoncxx::from_json(R"({"$set": {"x": 20}})")})
.append(
mongocxx::model::update_one{
bsoncxx::from_json(R"({"x": {"$exists": 1}})"), bsoncxx::from_json(R"({"$set": {"x": 20}})")})
.execute();

EXPECT(result_opt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ void example(mongocxx::index_view indexes) {

// Index model.
{
auto result_opt = indexes.create_one(mongocxx::index_model{
bsoncxx::from_json(R"({"y": 1})"),
bsoncxx::from_json(R"({"name": "two"})"),
});
auto result_opt = indexes.create_one(
mongocxx::index_model{
bsoncxx::from_json(R"({"y": 1})"),
bsoncxx::from_json(R"({"name": "two"})"),
});

EXPECT(result_opt);
EXPECT(result_opt->compare("two") == 0);
Expand Down
11 changes: 6 additions & 5 deletions examples/api/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,12 @@ class runner_type {
if (verbose) {
std::vector<bsoncxx::stdx::string_view> names;

names.reserve(std::accumulate(
std::begin(all_components),
std::end(all_components),
std::size_t{0},
[](std::size_t n, std::vector<component> const* cptr) { return n + cptr->size(); }));
names.reserve(
std::accumulate(
std::begin(all_components),
std::end(all_components),
std::size_t{0},
[](std::size_t n, std::vector<component> const* cptr) { return n + cptr->size(); }));

for (auto cptr : all_components) {
for (auto c : *cptr) {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ apidocs = [

clang_format = [
# etc/clang-format-all.sh
"clang-format~=19.1",
"clang-format~=20.1.0",
]

config_generator = [
Expand Down
5 changes: 1 addition & 4 deletions src/bsoncxx/include/bsoncxx/v1/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,7 @@ static constexpr struct invoke_fn {
// @cond DOXYGEN_DISABLE "Found ';' while parsing initializer list!"
template <typename F, typename... Args, typename Fd = remove_cvref_t<F>>
constexpr auto operator()(F&& fn, Args&&... args) const
BSONCXX_PRIVATE_RETURNS(impl_invoke::invoker<
std::is_member_object_pointer<Fd>::value,
std::is_member_function_pointer<
Fd>::value>::apply(static_cast<F&&>(fn), static_cast<Args&&>(args)...));
BSONCXX_PRIVATE_RETURNS(impl_invoke::invoker<std::is_member_object_pointer<Fd>::value, std::is_member_function_pointer<Fd>::value>::apply(static_cast<F&&>(fn), static_cast<Args&&>(args)...));
// @endcond
} invoke;

Expand Down
25 changes: 15 additions & 10 deletions src/bsoncxx/test/v_noabi/bson_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,15 @@ TEST_CASE("document uninitialized element throws exceptions", "") {
REQUIRE_THROWS_WITH(
doc["doesnotexist"].get_string().value,

Catch::Matchers::ContainsSubstring("cannot get string from an uninitialized element with key "
"\"doesnotexist\": unset document::element"));
Catch::Matchers::ContainsSubstring(
"cannot get string from an uninitialized element with key "
"\"doesnotexist\": unset document::element"));

REQUIRE_THROWS_WITH(
doc["alsodoesnotexist"].get_value(),
Catch::Matchers::ContainsSubstring("cannot return the type of uninitialized element with key "
"\"alsodoesnotexist\": unset document::element"));
Catch::Matchers::ContainsSubstring(
"cannot return the type of uninitialized element with key "
"\"alsodoesnotexist\": unset document::element"));

// Ensure a non-existing element evaluates to false.
REQUIRE(!doc["doesnotexist"]);
Expand All @@ -387,8 +389,9 @@ TEST_CASE("document uninitialized element throws exceptions", "") {
// Ensure getting a key from a non-existing element results in an exception.
REQUIRE_THROWS_WITH(
doc["doesnotexist"].key(),
Catch::Matchers::ContainsSubstring("cannot return the key from an uninitialized element with key "
"\"doesnotexist\": unset document::element"));
Catch::Matchers::ContainsSubstring(
"cannot return the key from an uninitialized element with key "
"\"doesnotexist\": unset document::element"));
}

TEST_CASE("array uninitialized element throws exceptions", "") {
Expand All @@ -398,16 +401,18 @@ TEST_CASE("array uninitialized element throws exceptions", "") {

REQUIRE_THROWS_WITH(
arr.view()[3].get_string().value,
Catch::Matchers::ContainsSubstring("cannot get string from an uninitialized element with key "
"\"3\": unset document::element"));
Catch::Matchers::ContainsSubstring(
"cannot get string from an uninitialized element with key "
"\"3\": unset document::element"));
// Ensure a non-existing element evaluates to false.
REQUIRE(!arr.view()[3]);
// Ensure finding a non-existing element results in an end iterator.
REQUIRE(arr.view().find(3) == arr.view().cend());
// Ensure getting a key from a non-existing element results in an exception.
REQUIRE_THROWS_WITH(
arr.view()[3].key(),
Catch::Matchers::ContainsSubstring("cannot return the key from an uninitialized element with key "
"\"3\": unset document::element"));
Catch::Matchers::ContainsSubstring(
"cannot return the key from an uninitialized element with key "
"\"3\": unset document::element"));
}
} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ class aggregate {
/// @see
/// - https://www.mongodb.com/docs/manual/reference/command/aggregate/
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
comment() const;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ class bulk_write {
/// @return
/// The current comment option.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const)
comment() const;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ class change_stream {
/// @return
/// The current comment option.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
comment() const;

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class count {
/// @see
/// - https://www.mongodb.com/docs/manual/reference/command/aggregate/
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
comment() const;

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ class delete_options {
/// @return
/// The current comment option.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const)
comment() const;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ class distinct {
/// @see
/// - https://www.mongodb.com/docs/manual/reference/command/distinct/
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
comment() const;

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ class encrypt {
/// @return
/// An optional owning bson_value containing the key_id.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
key_id() const;

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ class estimated_document_count {
/// @see
/// - https://www.mongodb.com/docs/manual/reference/command/count/
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
comment() const;

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ class find {
/// @see
/// - https://www.mongodb.com/docs/manual/reference/command/find/
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const&)
comment_option() const;

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ class find_one_and_delete {
/// @return
/// The current comment option.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const)
comment() const;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ class find_one_and_replace {
/// @return
/// The current comment option.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const)
comment() const;

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ class find_one_and_update {
/// @return
/// The current comment option.
///
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<
bsoncxx::v_noabi::types::bson_value::view_or_value> const)
MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::types::bson_value::view_or_value> const)
comment() const;

///
Expand Down
Loading