From 5f2dbbd56b8066cdf176088339f35a6aa3729170 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 30 Dec 2024 09:07:05 -0600 Subject: [PATCH 1/9] format: set ColumnLimit: 120 --- .clang-format | 2 +- benchmark/benchmark_runner.cpp | 41 +- benchmark/bson/bson_decoding.hpp | 4 +- benchmark/bson/bson_encoding.hpp | 4 +- benchmark/microbench.cpp | 6 +- benchmark/multi_doc/bulk_insert.hpp | 3 +- benchmark/multi_doc/find_many.hpp | 3 +- benchmark/multi_doc/gridfs_download.hpp | 6 +- benchmark/multi_doc/gridfs_upload.hpp | 3 +- benchmark/parallel/gridfs_multi_export.hpp | 13 +- benchmark/parallel/gridfs_multi_import.hpp | 13 +- benchmark/parallel/json_multi_export.hpp | 18 +- benchmark/parallel/json_multi_import.hpp | 13 +- benchmark/score_recorder.cpp | 9 +- benchmark/single_doc/find_one_by_id.hpp | 3 +- benchmark/single_doc/insert_one.hpp | 3 +- benchmark/single_doc/run_command.hpp | 4 +- .../access_array/algorithms.cpp | 7 +- .../bson_documents/access_doc/algorithms.cpp | 9 +- .../create_array/builder_bson_value.cpp | 3 +- .../create_array/builder_make_document.cpp | 3 +- .../builder_sub_document_append.cpp | 11 +- .../create_array/builder_value_type.cpp | 3 +- .../create_doc/builder_bson_type.cpp | 3 +- .../create_doc/builder_bson_value.cpp | 4 +- .../create_doc/builder_make_document.cpp | 4 +- .../create_doc/builder_sub_array_append.cpp | 4 +- .../builder_sub_document_append.cpp | 4 +- .../create_doc/builder_value_type.cpp | 4 +- .../examples/bson_documents/json/array.cpp | 10 +- .../examples/bson_documents/json/document.cpp | 14 +- .../api/bsoncxx/examples/oid/basic_usage.cpp | 6 +- .../examples/validation/basic_usage.cpp | 3 +- examples/api/db_lock.cpp | 3 +- .../examples/change_streams/with_pipeline.cpp | 6 +- .../client_sessions/use/transactions.cpp | 6 +- .../create/single/options/auto_encryption.cpp | 4 +- .../create/single/options/stable_api.cpp | 3 +- .../clients/errors/auto_encryption.cpp | 25 +- .../mongocxx/examples/clients/errors/tls.cpp | 5 +- .../clients/errors/wait_queue_timeout.cpp | 3 +- .../examples/collections/aggregate.cpp | 4 +- .../collections/bulk_write_with_options.cpp | 11 +- .../collections/create_index_with_options.cpp | 6 +- .../collections/index_views/create.cpp | 3 +- .../examples/collections/index_views/drop.cpp | 3 +- .../collections/index_views/drop_all.cpp | 3 +- .../examples/collections/update_one.cpp | 5 +- examples/api/runner.cpp | 26 +- examples/api/runner.hh | 31 +- examples/bsoncxx/builder_basic.cpp | 7 +- examples/bsoncxx/builder_stream.cpp | 6 +- .../bsoncxx/builder_stream_customization.cpp | 15 +- examples/bsoncxx/getting_values.cpp | 3 +- examples/bsoncxx/view_and_value.cpp | 10 +- examples/macros.hh | 16 +- examples/mongocxx/aggregate.cpp | 6 +- ...tic_client_side_field_level_encryption.cpp | 32 +- examples/mongocxx/causal_consistency.cpp | 3 +- examples/mongocxx/change_streams.cpp | 6 +- examples/mongocxx/client_session.cpp | 5 +- examples/mongocxx/create.cpp | 14 +- examples/mongocxx/document_validation.cpp | 10 +- examples/mongocxx/explicit_encryption.cpp | 17 +- .../explicit_encryption_auto_decryption.cpp | 14 +- .../mongocxx/get_values_from_documents.cpp | 9 +- examples/mongocxx/gridfs.cpp | 3 +- examples/mongocxx/index.cpp | 3 +- examples/mongocxx/instance_management.cpp | 12 +- .../mongodb.com/aggregation_examples.cpp | 43 +- .../mongodb.com/documentation_examples.cpp | 487 +++++----- .../mongocxx/mongodb.com/index_examples.cpp | 3 +- .../mongocxx/mongodb.com/usage_overview.cpp | 35 +- examples/mongocxx/pool.cpp | 3 +- examples/mongocxx/query.cpp | 16 +- examples/mongocxx/query_projection.cpp | 3 +- ...ide_field_level_encryption_enforcement.cpp | 27 +- examples/mongocxx/tutorial.cpp | 30 +- examples/mongocxx/update.cpp | 22 +- .../bsoncxx/v_noabi/bsoncxx/array/element.hpp | 5 +- .../v_noabi/bsoncxx/builder/basic/impl.hpp | 9 +- .../bsoncxx/v_noabi/bsoncxx/builder/core.hpp | 3 +- .../bsoncxx/v_noabi/bsoncxx/builder/list.hpp | 3 +- .../bsoncxx/builder/stream/array_context.hpp | 6 +- .../bsoncxx/builder/stream/value_context.hpp | 5 +- .../bsoncxx/v_noabi/bsoncxx/config/util.hpp | 14 +- .../v_noabi/bsoncxx/document/element.hpp | 5 +- .../include/bsoncxx/v_noabi/bsoncxx/json.hpp | 6 +- .../v_noabi/bsoncxx/stdx/operators.hpp | 47 +- .../bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp | 127 ++- .../v_noabi/bsoncxx/stdx/string_view.hpp | 46 +- .../v_noabi/bsoncxx/stdx/type_traits.hpp | 32 +- .../v_noabi/bsoncxx/string/to_string.hpp | 12 +- .../include/bsoncxx/v_noabi/bsoncxx/types.hpp | 14 +- .../bsoncxx/types/bson_value/value.hpp | 23 +- .../v_noabi/bsoncxx/types/bson_value/view.hpp | 27 +- .../bsoncxx/v_noabi/bsoncxx/validate.hpp | 3 +- .../bsoncxx/v_noabi/bsoncxx/view_or_value.hpp | 15 +- .../bsoncxx/v_noabi/bsoncxx/array/element.cpp | 5 +- .../bsoncxx/v_noabi/bsoncxx/array/value.cpp | 6 +- .../bsoncxx/v_noabi/bsoncxx/array/view.cpp | 15 +- .../bsoncxx/v_noabi/bsoncxx/builder/core.cpp | 71 +- .../v_noabi/bsoncxx/document/element.cpp | 29 +- .../v_noabi/bsoncxx/document/value.cpp | 6 +- .../bsoncxx/v_noabi/bsoncxx/document/view.cpp | 13 +- .../lib/bsoncxx/v_noabi/bsoncxx/json.cpp | 5 +- .../v_noabi/bsoncxx/private/b64_ntop.hh | 5 +- .../v_noabi/bsoncxx/private/helpers.hh | 3 +- .../v_noabi/bsoncxx/private/make_unique.hh | 45 +- .../bsoncxx/v_noabi/bsoncxx/private/stack.hh | 8 +- .../private/suppress_deprecation_warnings.hh | 6 +- .../bsoncxx/types/bson_value/value.cpp | 26 +- .../v_noabi/bsoncxx/types/bson_value/view.cpp | 16 +- .../v_noabi/bsoncxx/types/private/convert.hh | 9 +- src/bsoncxx/test/bson_builder.cpp | 54 +- src/bsoncxx/test/bson_get_values.cpp | 27 +- src/bsoncxx/test/bson_serialization.cpp | 12 +- src/bsoncxx/test/bson_types.cpp | 49 +- src/bsoncxx/test/bson_validate.cpp | 10 +- src/bsoncxx/test/bson_value.cpp | 8 +- src/bsoncxx/test/catch.cpp | 37 +- src/bsoncxx/test/json.cpp | 45 +- src/bsoncxx/test/optional.test.cpp | 23 +- src/bsoncxx/test/to_string.hh | 7 +- src/bsoncxx/test/type_traits.test.cpp | 54 +- .../mongocxx/v_noabi/mongocxx/bulk_write.hpp | 4 +- .../mongocxx/v_noabi/mongocxx/client.hpp | 29 +- .../v_noabi/mongocxx/client_encryption.hpp | 21 +- .../v_noabi/mongocxx/client_session.hpp | 3 +- .../mongocxx/v_noabi/mongocxx/collection.hpp | 189 ++-- .../mongocxx/v_noabi/mongocxx/cursor.hpp | 3 +- .../mongocxx/v_noabi/mongocxx/database.hpp | 40 +- .../mongocxx/events/server_description.hpp | 3 +- .../exception/operation_exception.hpp | 3 +- .../v_noabi/mongocxx/gridfs/bucket.hpp | 6 +- .../v_noabi/mongocxx/gridfs/uploader.hpp | 15 +- .../mongocxx/v_noabi/mongocxx/hint.hpp | 3 +- .../mongocxx/v_noabi/mongocxx/index_view.hpp | 12 +- .../v_noabi/mongocxx/model/delete_many.hpp | 6 +- .../v_noabi/mongocxx/model/delete_one.hpp | 3 +- .../v_noabi/mongocxx/model/replace_one.hpp | 3 +- .../v_noabi/mongocxx/model/update_many.hpp | 12 +- .../v_noabi/mongocxx/model/update_one.hpp | 12 +- .../v_noabi/mongocxx/options/aggregate.hpp | 15 +- .../mongocxx/v_noabi/mongocxx/options/apm.hpp | 84 +- .../mongocxx/options/auto_encryption.hpp | 18 +- .../v_noabi/mongocxx/options/bulk_write.hpp | 6 +- .../mongocxx/options/change_stream.hpp | 18 +- .../v_noabi/mongocxx/options/client.hpp | 3 +- .../mongocxx/options/client_encryption.hpp | 6 +- .../v_noabi/mongocxx/options/count.hpp | 6 +- .../v_noabi/mongocxx/options/data_key.hpp | 3 +- .../v_noabi/mongocxx/options/delete.hpp | 9 +- .../v_noabi/mongocxx/options/distinct.hpp | 6 +- .../options/estimated_document_count.hpp | 3 +- .../v_noabi/mongocxx/options/find.hpp | 27 +- .../mongocxx/options/find_one_and_delete.hpp | 15 +- .../mongocxx/options/find_one_and_replace.hpp | 18 +- .../mongocxx/options/find_one_and_update.hpp | 21 +- .../mongocxx/options/gridfs/bucket.hpp | 9 +- .../mongocxx/options/gridfs/upload.hpp | 3 +- .../v_noabi/mongocxx/options/index.hpp | 24 +- .../v_noabi/mongocxx/options/index_view.hpp | 6 +- .../v_noabi/mongocxx/options/insert.hpp | 3 +- .../v_noabi/mongocxx/options/replace.hpp | 9 +- .../mongocxx/options/rewrap_many_datakey.hpp | 3 +- .../v_noabi/mongocxx/options/server_api.hpp | 3 +- .../mongocxx/v_noabi/mongocxx/options/tls.hpp | 15 +- .../v_noabi/mongocxx/options/update.hpp | 12 +- .../mongocxx/v_noabi/mongocxx/pipeline.hpp | 3 +- .../mongocxx/v_noabi/mongocxx/pool.hpp | 9 +- .../v_noabi/mongocxx/read_preference.hpp | 13 +- .../mongocxx/result/rewrap_many_datakey.hpp | 3 +- .../v_noabi/mongocxx/search_index_model.hpp | 6 +- .../v_noabi/mongocxx/search_index_view.hpp | 9 +- .../v_noabi/mongocxx/validation_criteria.hpp | 6 +- .../mongocxx/v_noabi/mongocxx/bulk_write.cpp | 13 +- .../v_noabi/mongocxx/change_stream.cpp | 6 +- .../lib/mongocxx/v_noabi/mongocxx/client.cpp | 49 +- .../v_noabi/mongocxx/client_encryption.cpp | 36 +- .../v_noabi/mongocxx/client_session.cpp | 6 +- .../mongocxx/v_noabi/mongocxx/collection.cpp | 477 +++++----- .../lib/mongocxx/v_noabi/mongocxx/cursor.cpp | 7 +- .../mongocxx/v_noabi/mongocxx/database.cpp | 124 +-- .../mongocxx/events/command_failed_event.cpp | 22 +- .../mongocxx/events/command_started_event.cpp | 14 +- .../events/command_succeeded_event.cpp | 3 +- .../mongocxx/events/server_changed_event.cpp | 15 +- .../mongocxx/events/server_closed_event.cpp | 11 +- .../mongocxx/events/server_description.cpp | 12 +- .../mongocxx/events/server_opening_event.cpp | 11 +- .../events/topology_changed_event.cpp | 11 +- .../mongocxx/events/topology_closed_event.cpp | 3 +- .../mongocxx/events/topology_description.cpp | 36 +- .../events/topology_opening_event.cpp | 3 +- .../exception/operation_exception.cpp | 7 +- .../exception/private/mongoc_error.hh | 7 +- .../v_noabi/mongocxx/gridfs/bucket.cpp | 105 +-- .../v_noabi/mongocxx/gridfs/downloader.cpp | 28 +- .../v_noabi/mongocxx/gridfs/private/bucket.hh | 5 +- .../mongocxx/gridfs/private/downloader.hh | 5 +- .../v_noabi/mongocxx/gridfs/uploader.cpp | 48 +- .../lib/mongocxx/v_noabi/mongocxx/hint.cpp | 6 +- .../mongocxx/v_noabi/mongocxx/index_view.cpp | 27 +- .../mongocxx/v_noabi/mongocxx/instance.cpp | 9 +- .../v_noabi/mongocxx/model/delete_many.cpp | 6 +- .../v_noabi/mongocxx/model/delete_one.cpp | 6 +- .../v_noabi/mongocxx/model/insert_one.cpp | 3 +- .../v_noabi/mongocxx/model/replace_one.cpp | 3 +- .../v_noabi/mongocxx/model/update_many.cpp | 9 +- .../v_noabi/mongocxx/model/update_one.cpp | 9 +- .../mongocxx/v_noabi/mongocxx/model/write.cpp | 18 +- .../v_noabi/mongocxx/options/aggregate.cpp | 18 +- .../mongocxx/v_noabi/mongocxx/options/apm.cpp | 58 +- .../mongocxx/options/auto_encryption.cpp | 35 +- .../v_noabi/mongocxx/options/bulk_write.cpp | 9 +- .../mongocxx/options/change_stream.cpp | 31 +- .../mongocxx/options/client_encryption.cpp | 19 +- .../mongocxx/options/client_session.cpp | 3 +- .../v_noabi/mongocxx/options/count.cpp | 6 +- .../v_noabi/mongocxx/options/data_key.cpp | 9 +- .../v_noabi/mongocxx/options/delete.cpp | 16 +- .../v_noabi/mongocxx/options/distinct.cpp | 9 +- .../v_noabi/mongocxx/options/encrypt.cpp | 61 +- .../options/estimated_document_count.cpp | 9 +- .../v_noabi/mongocxx/options/find.cpp | 28 +- .../mongocxx/options/find_one_and_delete.cpp | 32 +- .../mongocxx/options/find_one_and_replace.cpp | 44 +- .../mongocxx/options/find_one_and_update.cpp | 51 +- .../mongocxx/options/gridfs/bucket.cpp | 9 +- .../mongocxx/options/gridfs/upload.cpp | 3 +- .../v_noabi/mongocxx/options/index.cpp | 29 +- .../v_noabi/mongocxx/options/index_view.cpp | 6 +- .../v_noabi/mongocxx/options/insert.cpp | 6 +- .../v_noabi/mongocxx/options/private/apm.hh | 6 +- .../mongocxx/options/private/server_api.hh | 10 +- .../v_noabi/mongocxx/options/private/ssl.hh | 4 +- .../mongocxx/options/private/transaction.hh | 30 +- .../v_noabi/mongocxx/options/range.cpp | 6 +- .../v_noabi/mongocxx/options/replace.cpp | 12 +- .../mongocxx/options/rewrap_many_datakey.cpp | 10 +- .../mongocxx/v_noabi/mongocxx/options/tls.cpp | 15 +- .../v_noabi/mongocxx/options/transaction.cpp | 12 +- .../v_noabi/mongocxx/options/update.cpp | 15 +- .../mongocxx/v_noabi/mongocxx/pipeline.cpp | 94 +- .../lib/mongocxx/v_noabi/mongocxx/pool.cpp | 23 +- .../mongocxx/private/client_encryption.hh | 111 +-- .../mongocxx/private/client_session.hh | 42 +- .../v_noabi/mongocxx/private/cursor.hh | 3 +- .../v_noabi/mongocxx/private/database.hh | 4 +- .../v_noabi/mongocxx/private/index_view.hh | 55 +- .../v_noabi/mongocxx/private/libbson.cpp | 12 +- .../v_noabi/mongocxx/private/libbson.hh | 6 +- .../v_noabi/mongocxx/private/libmongoc.cpp | 5 +- .../v_noabi/mongocxx/private/libmongoc.hh | 6 +- .../mongocxx/private/search_index_model.hh | 3 +- .../mongocxx/private/search_index_view.hh | 46 +- .../v_noabi/mongocxx/read_concern.cpp | 24 +- .../v_noabi/mongocxx/read_preference.cpp | 27 +- .../v_noabi/mongocxx/result/bulk_write.cpp | 3 +- .../v_noabi/mongocxx/result/gridfs/upload.cpp | 3 +- .../v_noabi/mongocxx/result/insert_many.cpp | 3 +- .../v_noabi/mongocxx/result/insert_one.cpp | 3 +- .../v_noabi/mongocxx/result/replace_one.cpp | 3 +- .../mongocxx/result/rewrap_many_datakey.cpp | 6 +- .../v_noabi/mongocxx/search_index_model.cpp | 6 +- .../v_noabi/mongocxx/search_index_view.cpp | 27 +- .../v_noabi/mongocxx/test_util/mock.hh | 4 +- .../lib/mongocxx/v_noabi/mongocxx/uri.cpp | 44 +- .../v_noabi/mongocxx/validation_criteria.cpp | 18 +- .../v_noabi/mongocxx/write_concern.cpp | 41 +- src/mongocxx/test/bulk_write.cpp | 26 +- src/mongocxx/test/catch_helpers.hh | 313 +++---- src/mongocxx/test/change_streams.cpp | 78 +- src/mongocxx/test/client.cpp | 36 +- src/mongocxx/test/client_helpers.cpp | 16 +- src/mongocxx/test/client_helpers.hh | 20 +- src/mongocxx/test/client_session.cpp | 103 +-- src/mongocxx/test/client_side_encryption.cpp | 837 ++++++++---------- src/mongocxx/test/collection.cpp | 148 ++-- src/mongocxx/test/collection_mocked.cpp | 404 ++++----- src/mongocxx/test/conversions.cpp | 19 +- src/mongocxx/test/database.cpp | 77 +- src/mongocxx/test/gridfs/bucket.cpp | 211 ++--- src/mongocxx/test/gridfs/downloader.cpp | 3 +- src/mongocxx/test/gridfs/uploader.cpp | 3 +- src/mongocxx/test/index_view.cpp | 34 +- src/mongocxx/test/options/aggregate.cpp | 3 +- src/mongocxx/test/options/index.cpp | 3 +- src/mongocxx/test/pool.cpp | 14 +- src/mongocxx/test/private/numeric_casting.cpp | 8 +- src/mongocxx/test/private/write_concern.cpp | 3 +- src/mongocxx/test/read_preference.cpp | 15 +- src/mongocxx/test/result/bulk_write.cpp | 25 +- src/mongocxx/test/result/delete.cpp | 3 +- src/mongocxx/test/sdam-monitoring.cpp | 19 +- src/mongocxx/test/search_index_view.cpp | 119 +-- .../test/spec/client_side_encryption.cpp | 75 +- src/mongocxx/test/spec/gridfs.cpp | 72 +- .../spec/initial_dns_seedlist_discovery.cpp | 16 +- src/mongocxx/test/spec/mongohouse.cpp | 6 +- src/mongocxx/test/spec/monitoring.cpp | 74 +- src/mongocxx/test/spec/monitoring.hh | 4 +- src/mongocxx/test/spec/operation.cpp | 70 +- src/mongocxx/test/spec/retryable-reads.cpp | 15 +- src/mongocxx/test/spec/transactions.cpp | 5 +- .../test/spec/unified_tests/assert.cpp | 17 +- .../test/spec/unified_tests/entity.cpp | 6 +- .../test/spec/unified_tests/operations.cpp | 197 ++--- .../test/spec/unified_tests/runner.cpp | 94 +- src/mongocxx/test/spec/uri_options.cpp | 15 +- src/mongocxx/test/spec/util.cpp | 247 +++--- src/mongocxx/test/transactions.cpp | 160 ++-- src/mongocxx/test/uri.cpp | 57 +- src/mongocxx/test/versioned_api.cpp | 19 +- src/mongocxx/test/write_concern.cpp | 9 +- 316 files changed, 3499 insertions(+), 5596 deletions(-) diff --git a/.clang-format b/.clang-format index d1f02cd586..eda0d9b11a 100644 --- a/.clang-format +++ b/.clang-format @@ -126,7 +126,7 @@ BreakFunctionDefinitionParameters: false BreakInheritanceList: BeforeColon BreakStringLiterals: true BreakTemplateDeclarations: Yes -ColumnLimit: 100 +ColumnLimit: 120 CommentPragmas: '^\s*(@(addtogroup|copydoc|defgroup|fn|ref)|- )' CompactNamespaces: false ConstructorInitializerIndentWidth: 4 diff --git a/benchmark/benchmark_runner.cpp b/benchmark/benchmark_runner.cpp index a4c1cd7c96..109b6c2072 100644 --- a/benchmark/benchmark_runner.cpp +++ b/benchmark/benchmark_runner.cpp @@ -47,29 +47,25 @@ namespace benchmark { // The task sizes and iteration numbers come from the Driver Perfomance Benchmarking Reference Doc. benchmark_runner::benchmark_runner(std::set types) : _types{types} { // Bson microbenchmarks - _microbenches.push_back( - std::make_unique("TestFlatEncoding", 75.31, "extended_bson/flat_bson.json")); - _microbenches.push_back( - std::make_unique("TestDeepEncoding", 19.64, "extended_bson/deep_bson.json")); - _microbenches.push_back( - std::make_unique("TestFullEncoding", 57.34, "extended_bson/full_bson.json")); + _microbenches.push_back(std::make_unique("TestFlatEncoding", 75.31, "extended_bson/flat_bson.json")); + _microbenches.push_back(std::make_unique("TestDeepEncoding", 19.64, "extended_bson/deep_bson.json")); + _microbenches.push_back(std::make_unique("TestFullEncoding", 57.34, "extended_bson/full_bson.json")); // TODO CXX-1241: Add bson_decoding equivalents. // Single doc microbenchmarks _microbenches.push_back(std::make_unique()); - _microbenches.push_back( - std::make_unique("single_and_multi_document/tweet.json")); + _microbenches.push_back(std::make_unique("single_and_multi_document/tweet.json")); _microbenches.push_back(std::make_unique( "TestSmallDocInsertOne", 2.75, iterations, "single_and_multi_document/small_doc.json")); - _microbenches.push_back(std::make_unique( - "TestLargeDocInsertOne", 27.31, 10, "single_and_multi_document/large_doc.json")); + _microbenches.push_back( + std::make_unique("TestLargeDocInsertOne", 27.31, 10, "single_and_multi_document/large_doc.json")); // Multi doc microbenchmarks _microbenches.push_back(std::make_unique("single_and_multi_document/tweet.json")); _microbenches.push_back(std::make_unique( "TestSmallDocBulkInsert", 2.75, iterations, "single_and_multi_document/small_doc.json")); - _microbenches.push_back(std::make_unique( - "TestLargeDocBulkInsert", 27.31, 10, "single_and_multi_document/large_doc.json")); + _microbenches.push_back( + std::make_unique("TestLargeDocBulkInsert", 27.31, 10, "single_and_multi_document/large_doc.json")); // CXX-2794: Disable GridFS benchmarks due to long runtime // _microbenches.push_back( // std::make_unique("single_and_multi_document/gridfs_large.bin")); @@ -88,11 +84,8 @@ benchmark_runner::benchmark_runner(std::set types) : _types{type for (auto&& it = _microbenches.begin(); it != _microbenches.end();) { const std::set& tags = (*it)->get_tags(); std::set intersect; - std::set_intersection(tags.begin(), - tags.end(), - _types.begin(), - _types.end(), - std::inserter(intersect, intersect.begin())); + std::set_intersection( + tags.begin(), tags.end(), _types.begin(), _types.end(), std::inserter(intersect, intersect.begin())); if (intersect.empty()) { _microbenches.erase(it); @@ -112,8 +105,7 @@ void benchmark_runner::run_microbenches() { auto score = bench->get_results(); - std::cout << bench->get_name() << ": " - << static_cast(score.get_percentile(50).count()) / 1000.0 + std::cout << bench->get_name() << ": " << static_cast(score.get_percentile(50).count()) / 1000.0 << " second(s) | " << score.get_score() << " MB/s" << std::endl << std::endl; } @@ -168,12 +160,9 @@ void benchmark_runner::write_scores() { using builder::basic::sub_document; auto doc = builder::basic::document{}; - doc.append(kvp("info", [](sub_document subdoc) { - subdoc.append(kvp("test_name", "C++ Driver microbenchmarks")); - })); + doc.append(kvp("info", [](sub_document subdoc) { subdoc.append(kvp("test_name", "C++ Driver microbenchmarks")); })); - auto write_time = - [](const std::chrono::time_point t) -> std::string { + auto write_time = [](const std::chrono::time_point t) -> std::string { std::time_t t1 = std::chrono::system_clock::to_time_t(t); std::ostringstream oss; oss << std::put_time(std::gmtime(&t1), "%Y-%m-%dT%H:%M:%S") << "+00:00"; @@ -191,8 +180,8 @@ void benchmark_runner::write_scores() { auto& score = bench->get_results(); const auto bench_time = static_cast(score.get_percentile(50).count()) / 1000.0; - std::cout << bench->get_name() << ": " << bench_time << " seconds | " << score.get_score() - << " MB/s" << std::endl; + std::cout << bench->get_name() << ": " << bench_time << " seconds | " << score.get_score() << " MB/s" + << std::endl; auto metric_doc = builder::basic::document{}; metric_doc.append(kvp("name", bench->get_name())); diff --git a/benchmark/bson/bson_decoding.hpp b/benchmark/bson/bson_decoding.hpp index a09dcc09b8..67f5cb87e5 100644 --- a/benchmark/bson/bson_decoding.hpp +++ b/benchmark/bson/bson_decoding.hpp @@ -23,9 +23,7 @@ class bson_decoding : public microbench { bson_decoding() = delete; bson_decoding(std::string name, double task_size, std::string json_file) - : microbench{std::move(name), - task_size, - std::set{benchmark_type::bson_bench}}, + : microbench{std::move(name), task_size, std::set{benchmark_type::bson_bench}}, _file_name{std::move(json_file)} {} protected: diff --git a/benchmark/bson/bson_encoding.hpp b/benchmark/bson/bson_encoding.hpp index c11b6c791e..e8fdd9b7a1 100644 --- a/benchmark/bson/bson_encoding.hpp +++ b/benchmark/bson/bson_encoding.hpp @@ -28,9 +28,7 @@ class bson_encoding : public microbench { bson_encoding() = delete; bson_encoding(std::string name, double task_size, std::string json_file) - : microbench{std::move(name), - task_size, - std::set{benchmark_type::bson_bench}}, + : microbench{std::move(name), task_size, std::set{benchmark_type::bson_bench}}, _json_file{std::move(json_file)} {} protected: diff --git a/benchmark/microbench.cpp b/benchmark/microbench.cpp index fc01167a38..882fc2aad2 100644 --- a/benchmark/microbench.cpp +++ b/benchmark/microbench.cpp @@ -21,8 +21,7 @@ namespace benchmark { -bool finished_running(const std::chrono::duration& curr_time, - std::uint32_t iter) { +bool finished_running(const std::chrono::duration& curr_time, std::uint32_t iter) { return (curr_time > maxtime || (curr_time > mintime && iter > max_iter)); } @@ -79,8 +78,7 @@ std::vector parse_json_file_to_documents(const std::st return docs; } -std::vector parse_documents_to_bson( - const std::vector& docs) { +std::vector parse_documents_to_bson(const std::vector& docs) { std::vector bsons; for (std::uint32_t i = 0; i < docs.size(); i++) { bsons.push_back(bsoncxx::to_json(docs[i])); diff --git a/benchmark/multi_doc/bulk_insert.hpp b/benchmark/multi_doc/bulk_insert.hpp index 3b450b5105..fb258fb835 100644 --- a/benchmark/multi_doc/bulk_insert.hpp +++ b/benchmark/multi_doc/bulk_insert.hpp @@ -38,8 +38,7 @@ class bulk_insert : public microbench { bulk_insert(std::string name, double task_size, std::int32_t doc_num, std::string json_file) : microbench{std::move(name), task_size, - std::set{benchmark_type::multi_bench, - benchmark_type::write_bench}}, + std::set{benchmark_type::multi_bench, benchmark_type::write_bench}}, _conn{mongocxx::uri{}}, _doc_num{doc_num}, _file_name{std::move(json_file)} {} diff --git a/benchmark/multi_doc/find_many.hpp b/benchmark/multi_doc/find_many.hpp index ac9db9b9a1..a4a2d82658 100644 --- a/benchmark/multi_doc/find_many.hpp +++ b/benchmark/multi_doc/find_many.hpp @@ -35,8 +35,7 @@ class find_many : public microbench { find_many(std::string json_file) : microbench{"TestFindManyAndEmptyCursor", 16.22, - std::set{benchmark_type::multi_bench, - benchmark_type::read_bench}}, + std::set{benchmark_type::multi_bench, benchmark_type::read_bench}}, _conn{mongocxx::uri{}}, _json_file{std::move(json_file)} {} diff --git a/benchmark/multi_doc/gridfs_download.hpp b/benchmark/multi_doc/gridfs_download.hpp index da05aac50a..09623fe265 100644 --- a/benchmark/multi_doc/gridfs_download.hpp +++ b/benchmark/multi_doc/gridfs_download.hpp @@ -38,8 +38,7 @@ class gridfs_download : public microbench { gridfs_download(std::string file_name) : microbench{"TestGridFsDownload", 52.43, - std::set{benchmark_type::multi_bench, - benchmark_type::read_bench}}, + std::set{benchmark_type::multi_bench, benchmark_type::read_bench}}, _conn{mongocxx::uri{}}, _file_name{std::move(file_name)} {} @@ -77,8 +76,7 @@ void gridfs_download::task() { auto buffer_size = std::min(file_length, static_cast(downloader.chunk_size())); auto buffer = std::make_unique(static_cast(buffer_size)); - while ([[maybe_unused]] auto length_read = - downloader.read(buffer.get(), static_cast(buffer_size))) { + while ([[maybe_unused]] auto length_read = downloader.read(buffer.get(), static_cast(buffer_size))) { } } } // namespace benchmark diff --git a/benchmark/multi_doc/gridfs_upload.hpp b/benchmark/multi_doc/gridfs_upload.hpp index c066b83440..6d3fd0f9e9 100644 --- a/benchmark/multi_doc/gridfs_upload.hpp +++ b/benchmark/multi_doc/gridfs_upload.hpp @@ -36,8 +36,7 @@ class gridfs_upload : public microbench { gridfs_upload(std::string file_name) : microbench{"TestGridFsUpload", 52.43, - std::set{benchmark_type::multi_bench, - benchmark_type::write_bench}}, + std::set{benchmark_type::multi_bench, benchmark_type::write_bench}}, _conn{mongocxx::uri{}}, _file_name{file_name} {} diff --git a/benchmark/parallel/gridfs_multi_export.hpp b/benchmark/parallel/gridfs_multi_export.hpp index 528df3862e..1e137b0319 100644 --- a/benchmark/parallel/gridfs_multi_export.hpp +++ b/benchmark/parallel/gridfs_multi_export.hpp @@ -38,12 +38,10 @@ class gridfs_multi_export : public microbench { gridfs_multi_export() = delete; // The task size comes from the Driver Perfomance Benchmarking Reference Doc. - gridfs_multi_export(std::string dir, - std::uint32_t thread_num = std::thread::hardware_concurrency()) + gridfs_multi_export(std::string dir, std::uint32_t thread_num = std::thread::hardware_concurrency()) : microbench{"TestGridFsMultiExport", 262.144, - std::set{benchmark_type::parallel_bench, - benchmark_type::read_bench}}, + std::set{benchmark_type::parallel_bench, benchmark_type::read_bench}}, _directory{std::move(dir)}, _pool{mongocxx::uri{}}, _thread_num{thread_num} {} @@ -95,8 +93,7 @@ void gridfs_multi_export::teardown() { } void gridfs_multi_export::task() { - std::div_t result = - std::div(static_cast(TOTAL_FILES), static_cast(_thread_num)); + std::div_t result = std::div(static_cast(TOTAL_FILES), static_cast(_thread_num)); std::uint32_t num_each = static_cast(result.quot); if (result.rem != 0) { num_each++; @@ -104,8 +101,8 @@ void gridfs_multi_export::task() { std::vector threads; for (std::uint32_t i = 0; i < TOTAL_FILES; i += num_each) { - threads.push_back(std::thread{ - [i, num_each, this] { concurrency_task(i, std::min(TOTAL_FILES - i, num_each)); }}); + threads.push_back( + std::thread{[i, num_each, this] { concurrency_task(i, std::min(TOTAL_FILES - i, num_each)); }}); } for (std::uint32_t i = 0; i < threads.size(); i++) { threads[i].join(); diff --git a/benchmark/parallel/gridfs_multi_import.hpp b/benchmark/parallel/gridfs_multi_import.hpp index 187ef2612a..cc020146c9 100644 --- a/benchmark/parallel/gridfs_multi_import.hpp +++ b/benchmark/parallel/gridfs_multi_import.hpp @@ -40,12 +40,10 @@ class gridfs_multi_import : public microbench { gridfs_multi_import() = delete; // The task size comes from the Driver Perfomance Benchmarking Reference Doc. - gridfs_multi_import(std::string dir, - std::uint32_t thread_num = std::thread::hardware_concurrency() * 2) + gridfs_multi_import(std::string dir, std::uint32_t thread_num = std::thread::hardware_concurrency() * 2) : microbench{"TestGridFsMultiImport", 262.144, - std::set{benchmark_type::parallel_bench, - benchmark_type::write_bench}}, + std::set{benchmark_type::parallel_bench, benchmark_type::write_bench}}, _directory{std::move(dir)}, _pool{mongocxx::uri{}}, _thread_num{thread_num} {} @@ -91,8 +89,7 @@ void gridfs_multi_import::teardown() { } void gridfs_multi_import::task() { - std::div_t result = - std::div(static_cast(TOTAL_FILES), static_cast(_thread_num)); + std::div_t result = std::div(static_cast(TOTAL_FILES), static_cast(_thread_num)); std::uint32_t num_each = static_cast(result.quot); if (result.rem != 0) { num_each++; @@ -100,8 +97,8 @@ void gridfs_multi_import::task() { std::vector threads; for (std::uint32_t i = 0; i < TOTAL_FILES; i += num_each) { - threads.push_back(std::thread{ - [i, num_each, this] { concurrency_task(i, std::min(TOTAL_FILES - i, num_each)); }}); + threads.push_back( + std::thread{[i, num_each, this] { concurrency_task(i, std::min(TOTAL_FILES - i, num_each)); }}); } for (std::uint32_t i = 0; i < threads.size(); i++) { threads[i].join(); diff --git a/benchmark/parallel/json_multi_export.hpp b/benchmark/parallel/json_multi_export.hpp index 544203b19f..92442f8c9c 100644 --- a/benchmark/parallel/json_multi_export.hpp +++ b/benchmark/parallel/json_multi_export.hpp @@ -44,12 +44,10 @@ class json_multi_export : public microbench { json_multi_export() = delete; // The task size comes from the Driver Perfomance Benchmarking Reference Doc. - json_multi_export(std::string dir, - std::uint32_t thread_num = std::thread::hardware_concurrency()) + json_multi_export(std::string dir, std::uint32_t thread_num = std::thread::hardware_concurrency()) : microbench{"TestJsonMultiExport", 565, - std::set{benchmark_type::parallel_bench, - benchmark_type::read_bench}}, + std::set{benchmark_type::parallel_bench, benchmark_type::read_bench}}, _directory{std::move(dir)}, _pool{mongocxx::uri{}}, _thread_num{thread_num} {} @@ -86,9 +84,8 @@ void json_multi_export::setup() { ins_opts.ordered(false); for (std::uint32_t j = 0; j < docs.size(); j++) { - bsoncxx::document::value insert = - make_document(kvp("file", bsoncxx::types::b_int32{static_cast(j)}), - concatenate(docs[i].view())); + bsoncxx::document::value insert = make_document( + kvp("file", bsoncxx::types::b_int32{static_cast(j)}), concatenate(docs[i].view())); db["corpus"].insert_one(insert.view(), ins_opts); } } @@ -108,8 +105,7 @@ void json_multi_export::teardown() { } void json_multi_export::task() { - std::div_t result = - std::div(static_cast(TOTAL_FILES), static_cast(_thread_num)); + std::div_t result = std::div(static_cast(TOTAL_FILES), static_cast(_thread_num)); std::uint32_t num_each = static_cast(result.quot); if (result.rem != 0) { num_each++; @@ -117,8 +113,8 @@ void json_multi_export::task() { std::vector threads; for (std::uint32_t i = 0; i < TOTAL_FILES; i += num_each) { - threads.push_back(std::thread{ - [i, num_each, this] { concurrency_task(i, std::min(TOTAL_FILES - i, num_each)); }}); + threads.push_back( + std::thread{[i, num_each, this] { concurrency_task(i, std::min(TOTAL_FILES - i, num_each)); }}); } for (std::uint32_t i = 0; i < threads.size(); i++) { threads[i].join(); diff --git a/benchmark/parallel/json_multi_import.hpp b/benchmark/parallel/json_multi_import.hpp index bb366bbe83..5ee06ca784 100644 --- a/benchmark/parallel/json_multi_import.hpp +++ b/benchmark/parallel/json_multi_import.hpp @@ -43,12 +43,10 @@ class json_multi_import : public microbench { json_multi_import() = delete; // The task size comes from the Driver Perfomance Benchmarking Reference Doc. - json_multi_import(std::string dir, - std::uint32_t thread_num = std::thread::hardware_concurrency() * 2) + json_multi_import(std::string dir, std::uint32_t thread_num = std::thread::hardware_concurrency() * 2) : microbench{"TestJsonMultiImport", 565, - std::set{benchmark_type::parallel_bench, - benchmark_type::write_bench}}, + std::set{benchmark_type::parallel_bench, benchmark_type::write_bench}}, _directory{std::move(dir)}, _pool{mongocxx::uri{}}, _thread_num{thread_num} {} @@ -87,8 +85,7 @@ void json_multi_import::teardown() { } void json_multi_import::task() { - std::div_t result = - std::div(static_cast(TOTAL_FILES), static_cast(_thread_num)); + std::div_t result = std::div(static_cast(TOTAL_FILES), static_cast(_thread_num)); std::uint32_t num_each = static_cast(result.quot); if (result.rem != 0) { num_each++; @@ -96,8 +93,8 @@ void json_multi_import::task() { std::vector threads; for (std::uint32_t i = 0; i < TOTAL_FILES; i += num_each) { - threads.push_back(std::thread{ - [i, num_each, this] { concurrency_task(i, std::min(TOTAL_FILES - i, num_each)); }}); + threads.push_back( + std::thread{[i, num_each, this] { concurrency_task(i, std::min(TOTAL_FILES - i, num_each)); }}); } for (std::uint32_t i = 0; i < threads.size(); i++) { threads[i].join(); diff --git a/benchmark/score_recorder.cpp b/benchmark/score_recorder.cpp index 8013deef6b..183582012f 100644 --- a/benchmark/score_recorder.cpp +++ b/benchmark/score_recorder.cpp @@ -19,8 +19,7 @@ namespace benchmark { -score_recorder::score_recorder(double task_size) - : _execution_time{0}, _sorted{false}, _task_size{task_size} {} +score_recorder::score_recorder(double task_size) : _execution_time{0}, _sorted{false}, _task_size{task_size} {} const std::chrono::milliseconds& score_recorder::get_execution_time() const { return _execution_time; @@ -31,10 +30,8 @@ void benchmark::score_recorder::start_sample() { } void score_recorder::end_sample() { - std::chrono::time_point end = - std::chrono::high_resolution_clock::now(); - std::chrono::milliseconds duration = - std::chrono::duration_cast(end - _last_start); + std::chrono::time_point end = std::chrono::high_resolution_clock::now(); + std::chrono::milliseconds duration = std::chrono::duration_cast(end - _last_start); _samples.push_back(duration); _sorted = false; diff --git a/benchmark/single_doc/find_one_by_id.hpp b/benchmark/single_doc/find_one_by_id.hpp index 3a721f6021..48c7108bf5 100644 --- a/benchmark/single_doc/find_one_by_id.hpp +++ b/benchmark/single_doc/find_one_by_id.hpp @@ -35,8 +35,7 @@ class find_one_by_id : public microbench { find_one_by_id(std::string json_file) : microbench{"TestFindOneById", 16.22, - std::set{benchmark_type::single_bench, - benchmark_type::read_bench}}, + std::set{benchmark_type::single_bench, benchmark_type::read_bench}}, _conn{mongocxx::uri{}}, _json_file{std::move(json_file)} {} diff --git a/benchmark/single_doc/insert_one.hpp b/benchmark/single_doc/insert_one.hpp index f343e96492..91645e131f 100644 --- a/benchmark/single_doc/insert_one.hpp +++ b/benchmark/single_doc/insert_one.hpp @@ -36,8 +36,7 @@ class insert_one : public microbench { insert_one(std::string name, double task_size, std::int32_t iter, std::string json_file) : microbench{std::move(name), task_size, - std::set{benchmark_type::single_bench, - benchmark_type::write_bench}}, + std::set{benchmark_type::single_bench, benchmark_type::write_bench}}, _conn{mongocxx::uri{}}, _iter{iter}, _file_name{std::move(json_file)} {} diff --git a/benchmark/single_doc/run_command.hpp b/benchmark/single_doc/run_command.hpp index 97db905dc5..14e4532ae6 100644 --- a/benchmark/single_doc/run_command.hpp +++ b/benchmark/single_doc/run_command.hpp @@ -31,9 +31,7 @@ using bsoncxx::builder::basic::make_document; class run_command : public microbench { public: run_command() - : microbench{"TestRunCommand", - 0.13, - std::set{benchmark_type::run_command_bench}}, + : microbench{"TestRunCommand", 0.13, std::set{benchmark_type::run_command_bench}}, _conn{mongocxx::uri{}} { _db = _conn["perftest"]; } diff --git a/examples/api/bsoncxx/examples/bson_documents/access_array/algorithms.cpp b/examples/api/bsoncxx/examples/bson_documents/access_array/algorithms.cpp index dd965486b8..e609434be3 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_array/algorithms.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_array/algorithms.cpp @@ -32,10 +32,9 @@ void example(bsoncxx::array::view arr) { std::vector elements; - std::copy_if( - arr.begin(), arr.end(), std::back_inserter(elements), [](const bsoncxx::array::element& e) { - return e.key() == "0" || e.type() == bsoncxx::type::k_string; - }); + std::copy_if(arr.begin(), arr.end(), std::back_inserter(elements), [](const bsoncxx::array::element& e) { + return e.key() == "0" || e.type() == bsoncxx::type::k_string; + }); EXPECT(elements.size() == 2u); EXPECT(elements[0].key() == "0"); diff --git a/examples/api/bsoncxx/examples/bson_documents/access_doc/algorithms.cpp b/examples/api/bsoncxx/examples/bson_documents/access_doc/algorithms.cpp index f0e7f01236..bb8700fe0e 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_doc/algorithms.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_doc/algorithms.cpp @@ -33,12 +33,9 @@ void example(bsoncxx::document::view doc) { std::vector elements; - std::copy_if(doc.begin(), - doc.end(), - std::back_inserter(elements), - [](const bsoncxx::document::element& e) { - return e.key() == "a" || e.type() == bsoncxx::type::k_string; - }); + std::copy_if(doc.begin(), doc.end(), std::back_inserter(elements), [](const bsoncxx::document::element& e) { + return e.key() == "a" || e.type() == bsoncxx::type::k_string; + }); EXPECT(elements.size() == 2u); EXPECT(elements[0].key() == "a"); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_bson_value.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_bson_value.cpp index 64b09eacef..f78ca1aec5 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_bson_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_bson_value.cpp @@ -35,8 +35,7 @@ void example() { "three", }; - bsoncxx::array::value arr = - bsoncxx::builder::basic::make_array(values[0], values[1], values[2]); + bsoncxx::array::value arr = bsoncxx::builder::basic::make_array(values[0], values[1], values[2]); EXPECT(arr.view() == bsoncxx::builder::basic::make_array(1, 2.0, "three")); } diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_make_document.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_make_document.cpp index d7f7a393c2..f0955452a9 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_make_document.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_make_document.cpp @@ -26,8 +26,7 @@ namespace { // [Example] void example() { - bsoncxx::array::value owner = - bsoncxx::builder::basic::make_array(std::int32_t{1}, 2.0, "three"); + bsoncxx::array::value owner = bsoncxx::builder::basic::make_array(std::int32_t{1}, 2.0, "three"); bsoncxx::array::view arr = owner.view(); EXPECT(arr[0].get_int32().value == 1); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_document_append.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_document_append.cpp index ba64c0e862..ba0beb0964 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_document_append.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_document_append.cpp @@ -33,12 +33,11 @@ void example() { std::string keys[] = {"a", "b", "c"}; std::int32_t values[] = {1, 2, 3}; - bsoncxx::array::value owner = - bsoncxx::builder::basic::make_array([&](bsoncxx::builder::basic::sub_document doc) { - for (int i = 0; i < 3; ++i) { - doc.append(kvp(keys[i], values[i])); - } - }); + bsoncxx::array::value owner = bsoncxx::builder::basic::make_array([&](bsoncxx::builder::basic::sub_document doc) { + for (int i = 0; i < 3; ++i) { + doc.append(kvp(keys[i], values[i])); + } + }); bsoncxx::document::view v = owner.view()[0].get_document().value; EXPECT(v == bsoncxx::from_json(R"({"a": 1, "b": 2, "c": 3})")); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_value_type.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_value_type.cpp index 44c4597bc5..3b83cca750 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_value_type.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_value_type.cpp @@ -26,8 +26,7 @@ namespace { // [Example] void example() { - bsoncxx::array::value owner = - bsoncxx::builder::basic::make_array(std::int32_t{1}, 2.0, "three"); + bsoncxx::array::value owner = bsoncxx::builder::basic::make_array(std::int32_t{1}, 2.0, "three"); bsoncxx::array::view arr = owner.view(); EXPECT(arr[0].type() == bsoncxx::type::k_int32); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_bson_type.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_bson_type.cpp index fc7370650f..ef78fe0f86 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_bson_type.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_bson_type.cpp @@ -33,8 +33,7 @@ void example() { bsoncxx::types::b_double b{2.0}; bsoncxx::types::b_string c{"three"}; - bsoncxx::document::value doc = - bsoncxx::builder::basic::make_document(kvp("a", a), kvp("b", b), kvp("c", c)); + bsoncxx::document::value doc = bsoncxx::builder::basic::make_document(kvp("a", a), kvp("b", b), kvp("c", c)); EXPECT(doc.view() == bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})")); } diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_bson_value.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_bson_value.cpp index bed8933dd4..adb53a6c23 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_bson_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_bson_value.cpp @@ -35,8 +35,8 @@ void example() { "three", }; - bsoncxx::document::value doc = bsoncxx::builder::basic::make_document( - kvp("a", values[0]), kvp("b", values[1]), kvp("c", values[2])); + bsoncxx::document::value doc = + bsoncxx::builder::basic::make_document(kvp("a", values[0]), kvp("b", values[1]), kvp("c", values[2])); EXPECT(doc.view() == bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})")); } diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_make_document.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_make_document.cpp index 6e17a7bed6..20de34ab14 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_make_document.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_make_document.cpp @@ -28,8 +28,8 @@ namespace { void example() { using bsoncxx::builder::basic::kvp; - bsoncxx::document::value doc = bsoncxx::builder::basic::make_document( - kvp("a", std::int32_t{1}), kvp("b", 2.0), kvp("c", "three")); + bsoncxx::document::value doc = + bsoncxx::builder::basic::make_document(kvp("a", std::int32_t{1}), kvp("b", 2.0), kvp("c", "three")); EXPECT(doc.view() == bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})")); } diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array_append.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array_append.cpp index 14896eab70..d9e64ab83c 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array_append.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array_append.cpp @@ -33,8 +33,8 @@ void example() { std::int32_t values[] = {1, 2, 3}; - bsoncxx::document::value owner = bsoncxx::builder::basic::make_document( - kvp("v", [&](bsoncxx::builder::basic::sub_array arr) { + bsoncxx::document::value owner = + bsoncxx::builder::basic::make_document(kvp("v", [&](bsoncxx::builder::basic::sub_array arr) { for (int i = 0; i < 3; ++i) { arr.append(values[i]); } diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document_append.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document_append.cpp index bf48aaf269..80d0c8e52b 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document_append.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document_append.cpp @@ -33,8 +33,8 @@ void example() { std::string keys[] = {"a", "b", "c"}; std::int32_t values[] = {1, 2, 3}; - bsoncxx::document::value owner = bsoncxx::builder::basic::make_document( - kvp("v", [&](bsoncxx::builder::basic::sub_document doc) { + bsoncxx::document::value owner = + bsoncxx::builder::basic::make_document(kvp("v", [&](bsoncxx::builder::basic::sub_document doc) { for (int i = 0; i < 3; ++i) { doc.append(kvp(keys[i], values[i])); } diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_value_type.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_value_type.cpp index 22c6e974ee..8f3ef0de48 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_value_type.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_value_type.cpp @@ -28,8 +28,8 @@ namespace { void example() { using bsoncxx::builder::basic::kvp; - bsoncxx::document::value doc = bsoncxx::builder::basic::make_document( - kvp("a", std::int32_t{1}), kvp("b", 2.0), kvp("c", "three")); + bsoncxx::document::value doc = + bsoncxx::builder::basic::make_document(kvp("a", std::int32_t{1}), kvp("b", 2.0), kvp("c", "three")); EXPECT(doc == bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})")); } diff --git a/examples/api/bsoncxx/examples/bson_documents/json/array.cpp b/examples/api/bsoncxx/examples/bson_documents/json/array.cpp index 3bc7ee8ef4..8ec46e05d7 100644 --- a/examples/api/bsoncxx/examples/bson_documents/json/array.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/json/array.cpp @@ -34,11 +34,11 @@ void example() { std::uint32_t data_len{5u}; // Exclude null terminator. bsoncxx::types::b_binary binary{bsoncxx::binary_sub_type::k_binary, data_len, data}; - bsoncxx::array::value owner = bsoncxx::builder::basic::make_array( - std::int32_t{1}, // "$numberInt": "1" - std::int64_t{2}, // "$numberLong": "2" - binary // "$binary": { "$base64": "dGhyZWU=", "subType": 00 } - ); + bsoncxx::array::value owner = + bsoncxx::builder::basic::make_array(std::int32_t{1}, // "$numberInt": "1" + std::int64_t{2}, // "$numberLong": "2" + binary // "$binary": { "$base64": "dGhyZWU=", "subType": 00 } + ); bsoncxx::array::view arr = owner.view(); { diff --git a/examples/api/bsoncxx/examples/bson_documents/json/document.cpp b/examples/api/bsoncxx/examples/bson_documents/json/document.cpp index 9a3e9a268e..3a427c6229 100644 --- a/examples/api/bsoncxx/examples/bson_documents/json/document.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/json/document.cpp @@ -36,11 +36,11 @@ void example() { auto data_len = static_cast(sizeof(data) - 1u); // Exclude null terminator. bsoncxx::types::b_binary binary{bsoncxx::binary_sub_type::k_binary, data_len, data}; - bsoncxx::document::value owner = bsoncxx::builder::basic::make_document( - kvp("a", std::int32_t{1}), // "$numberInt": "1" - kvp("b", std::int64_t{2}), // "$numberLong": "2" - kvp("c", binary) // "$binary": { "$base64": "dGhyZWU=", "subType": 00 } - ); + bsoncxx::document::value owner = + bsoncxx::builder::basic::make_document(kvp("a", std::int32_t{1}), // "$numberInt": "1" + kvp("b", std::int64_t{2}), // "$numberLong": "2" + kvp("c", binary) // "$binary": { "$base64": "dGhyZWU=", "subType": 00 } + ); bsoncxx::document::view doc = owner.view(); { @@ -74,9 +74,7 @@ void example() { // } // } std::string json = bsoncxx::to_json(doc, ExtendedJsonMode::k_relaxed); - EXPECT( - json == - R"({ "a" : 1, "b" : 2, "c" : { "$binary" : { "base64" : "dGhyZWU=", "subType" : "00" } } })"); + EXPECT(json == R"({ "a" : 1, "b" : 2, "c" : { "$binary" : { "base64" : "dGhyZWU=", "subType" : "00" } } })"); } { diff --git a/examples/api/bsoncxx/examples/oid/basic_usage.cpp b/examples/api/bsoncxx/examples/oid/basic_usage.cpp index b58847b891..acd727acbe 100644 --- a/examples/api/bsoncxx/examples/oid/basic_usage.cpp +++ b/examples/api/bsoncxx/examples/oid/basic_usage.cpp @@ -40,8 +40,7 @@ void example() { { std::time_t time = oid.get_time_t(); char str[sizeof("YYYY-MM-DD HH:MM:SS")]; - EXPECT(std::strftime(str, sizeof(str), "%F %T", std::gmtime(&time)) == - sizeof(str) - 1u); + EXPECT(std::strftime(str, sizeof(str), "%F %T", std::gmtime(&time)) == sizeof(str) - 1u); EXPECT(std::string(str) == "1970-01-01 00:00:00"); } @@ -62,8 +61,7 @@ void example() { { std::time_t time = oid.get_time_t(); char str[sizeof("YYYY-MM-DD HH:MM:SS")]; - EXPECT(std::strftime(str, sizeof(str), "%F %T", std::gmtime(&time)) == - sizeof(str) - 1u); + EXPECT(std::strftime(str, sizeof(str), "%F %T", std::gmtime(&time)) == sizeof(str) - 1u); EXPECT(std::string(str) == "2000-01-01 23:59:59"); } diff --git a/examples/api/bsoncxx/examples/validation/basic_usage.cpp b/examples/api/bsoncxx/examples/validation/basic_usage.cpp index f24b88db63..98e90deb72 100644 --- a/examples/api/bsoncxx/examples/validation/basic_usage.cpp +++ b/examples/api/bsoncxx/examples/validation/basic_usage.cpp @@ -59,8 +59,7 @@ void example() { bsoncxx::validator options; std::size_t offset = 123u; - EXPECT(bsoncxx::validate(data, length) == - bsoncxx::validate(data, length, options, &offset)); + EXPECT(bsoncxx::validate(data, length) == bsoncxx::validate(data, length, options, &offset)); // Not set when valid. EXPECT(offset == 123u); diff --git a/examples/api/db_lock.cpp b/examples/api/db_lock.cpp index 4a624e016b..6eb31dd597 100644 --- a/examples/api/db_lock.cpp +++ b/examples/api/db_lock.cpp @@ -46,8 +46,7 @@ db_lock::db_lock(mongocxx::client& client, std::string name) : _client_ptr(&clie _name = std::move(_name).substr(_name.size() - db_name_size_max, db_name_size_max); } - ((void)std::lock_guard{db_locks_mut}, - _lock = std::unique_lock(db_locks[name])); + ((void)std::lock_guard{db_locks_mut}, _lock = std::unique_lock(db_locks[name])); this->get().drop(wc_majority()); } diff --git a/examples/api/mongocxx/examples/change_streams/with_pipeline.cpp b/examples/api/mongocxx/examples/change_streams/with_pipeline.cpp index 8a70589753..e98094335f 100644 --- a/examples/api/mongocxx/examples/change_streams/with_pipeline.cpp +++ b/examples/api/mongocxx/examples/change_streams/with_pipeline.cpp @@ -37,8 +37,7 @@ void example(mongocxx::database db) { mongocxx::pipeline pipeline; - pipeline.match( - bsoncxx::from_json(R"({"operationType": "insert", "fullDocument.watched": true})")); + pipeline.match(bsoncxx::from_json(R"({"operationType": "insert", "fullDocument.watched": true})")); // ... other pipeline options. mongocxx::change_stream stream = coll.watch(pipeline); @@ -50,8 +49,7 @@ void example(mongocxx::database db) { EXPECT(coll.insert_one(bsoncxx::from_json(R"({"x": 2, "watched": false})"))); // Not observed (operationType mismatch). - EXPECT(coll.update_one(bsoncxx::from_json(R"({"x": 2})"), - bsoncxx::from_json(R"({"$set": {"watched": true}})"))); + EXPECT(coll.update_one(bsoncxx::from_json(R"({"x": 2})"), bsoncxx::from_json(R"({"$set": {"watched": true}})"))); // Observed. EXPECT(coll.insert_one(bsoncxx::from_json(R"({"x": 3, "watched": true})"))); diff --git a/examples/api/mongocxx/examples/client_sessions/use/transactions.cpp b/examples/api/mongocxx/examples/client_sessions/use/transactions.cpp index 67ad38a987..cc84d1fecd 100644 --- a/examples/api/mongocxx/examples/client_sessions/use/transactions.cpp +++ b/examples/api/mongocxx/examples/client_sessions/use/transactions.cpp @@ -55,8 +55,7 @@ void example(mongocxx::client_session session, mongocxx::collection coll) { } { - auto result_opt = - coll.update_many(session, bsoncxx::from_json(R"({"x": {"$exists": 1}})"), inc.view()); + auto result_opt = coll.update_many(session, bsoncxx::from_json(R"({"x": {"$exists": 1}})"), inc.view()); EXPECT(result_opt); EXPECT(result_opt->modified_count() == 3); @@ -76,8 +75,7 @@ RUNNER_REGISTER_COMPONENT_FOR_REPLICA() { try { db_lock guard{client, EXAMPLES_COMPONENT_NAME_STR}; - example(client.start_session(), - set_rw_concern_majority(guard.get()).create_collection("coll")); + example(client.start_session(), set_rw_concern_majority(guard.get()).create_collection("coll")); } catch (const mongocxx::exception& ex) { if (std::strstr(ex.what(), "not supported") != nullptr) { // MongoDB 4.2+ required for sharded clusters. diff --git a/examples/api/mongocxx/examples/clients/create/single/options/auto_encryption.cpp b/examples/api/mongocxx/examples/clients/create/single/options/auto_encryption.cpp index c2409dd17b..cfc6d6f519 100644 --- a/examples/api/mongocxx/examples/clients/create/single/options/auto_encryption.cpp +++ b/examples/api/mongocxx/examples/clients/create/single/options/auto_encryption.cpp @@ -63,9 +63,7 @@ RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(make_document(kvp( "local", - make_document(kvp( - "key", - bsoncxx::types::b_binary{bsoncxx::binary_sub_type::k_binary, 96, local_key}))))); + make_document(kvp("key", bsoncxx::types::b_binary{bsoncxx::binary_sub_type::k_binary, 96, local_key}))))); } catch (const mongocxx::exception& ex) { if (std::strstr(ex.what(), "ENABLE_CLIENT_SIDE_ENCRYPTION") != nullptr) { // Library may not be configured with TLS/SSL support enabled. diff --git a/examples/api/mongocxx/examples/clients/create/single/options/stable_api.cpp b/examples/api/mongocxx/examples/clients/create/single/options/stable_api.cpp index 17bf380547..50c13371d0 100644 --- a/examples/api/mongocxx/examples/clients/create/single/options/stable_api.cpp +++ b/examples/api/mongocxx/examples/clients/create/single/options/stable_api.cpp @@ -26,8 +26,7 @@ namespace { // [Example] mongocxx::client example() { - mongocxx::options::server_api server_api_opts{ - mongocxx::options::server_api::version::k_version_1}; + mongocxx::options::server_api server_api_opts{mongocxx::options::server_api::version::k_version_1}; server_api_opts.strict(true); // ... other Stable API options. diff --git a/examples/api/mongocxx/examples/clients/errors/auto_encryption.cpp b/examples/api/mongocxx/examples/clients/errors/auto_encryption.cpp index cf237289e6..9547feb370 100644 --- a/examples/api/mongocxx/examples/clients/errors/auto_encryption.cpp +++ b/examples/api/mongocxx/examples/clients/errors/auto_encryption.cpp @@ -36,9 +36,9 @@ namespace { void example() { // Missing keyvault namespace. try { - mongocxx::client client{mongocxx::uri{}, - mongocxx::options::client{}.auto_encryption_opts( - mongocxx::options::auto_encryption{})}; // Throws. + mongocxx::client client{ + mongocxx::uri{}, + mongocxx::options::client{}.auto_encryption_opts(mongocxx::options::auto_encryption{})}; // Throws. EXPECT(false && "should not reach this point"); } catch (const mongocxx::exception& ex) { @@ -49,12 +49,11 @@ void example() { // Invalid KMS providers. try { - mongocxx::client client{ - mongocxx::uri{}, - mongocxx::options::client{}.auto_encryption_opts( - mongocxx::options::auto_encryption{} - .key_vault_namespace({"keyvault", "datakeys"}) - .kms_providers(bsoncxx::from_json(R"({"invalid": 1})")))}; // Throws. + mongocxx::client client{mongocxx::uri{}, + mongocxx::options::client{}.auto_encryption_opts( + mongocxx::options::auto_encryption{} + .key_vault_namespace({"keyvault", "datakeys"}) + .kms_providers(bsoncxx::from_json(R"({"invalid": 1})")))}; // Throws. EXPECT(false && "should not reach this point"); } catch (const mongocxx::exception& ex) { @@ -68,8 +67,7 @@ void example() { mongocxx::client client{ mongocxx::uri{}, mongocxx::options::client{}.auto_encryption_opts( - mongocxx::options::auto_encryption{}.key_vault_client(nullptr).key_vault_pool( - nullptr))}; // Throws. + mongocxx::options::auto_encryption{}.key_vault_client(nullptr).key_vault_pool(nullptr))}; // Throws. EXPECT(false && "should not reach this point"); } catch (const mongocxx::exception& ex) { @@ -84,9 +82,8 @@ RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { using bsoncxx::builder::basic::sub_document; try { - (void)mongocxx::client{ - mongocxx::uri{}, - mongocxx::options::client{}.auto_encryption_opts(mongocxx::options::auto_encryption{})}; + (void)mongocxx::client{mongocxx::uri{}, + mongocxx::options::client{}.auto_encryption_opts(mongocxx::options::auto_encryption{})}; EXPECT(false && "should not reach this point"); } catch (const mongocxx::exception& ex) { diff --git a/examples/api/mongocxx/examples/clients/errors/tls.cpp b/examples/api/mongocxx/examples/clients/errors/tls.cpp index 3518975f8a..39add00345 100644 --- a/examples/api/mongocxx/examples/clients/errors/tls.cpp +++ b/examples/api/mongocxx/examples/clients/errors/tls.cpp @@ -27,9 +27,8 @@ namespace { // [Example] void example() { try { - mongocxx::client client{ - mongocxx::uri{}, - mongocxx::options::client{}.tls_opts(mongocxx::options::tls{})}; // Throws. + mongocxx::client client{mongocxx::uri{}, + mongocxx::options::client{}.tls_opts(mongocxx::options::tls{})}; // Throws. EXPECT(false && "should not reach this point"); } catch (const mongocxx::exception& ex) { diff --git a/examples/api/mongocxx/examples/clients/errors/wait_queue_timeout.cpp b/examples/api/mongocxx/examples/clients/errors/wait_queue_timeout.cpp index c2bcab3f9a..f005ce5eff 100644 --- a/examples/api/mongocxx/examples/clients/errors/wait_queue_timeout.cpp +++ b/examples/api/mongocxx/examples/clients/errors/wait_queue_timeout.cpp @@ -27,8 +27,7 @@ namespace { // [Example] void example() { try { - mongocxx::pool pool{ - mongocxx::uri{"mongodb://localhost:27017/?maxPoolSize=1&waitQueueTimeoutMS=1"}}; + mongocxx::pool pool{mongocxx::uri{"mongodb://localhost:27017/?maxPoolSize=1&waitQueueTimeoutMS=1"}}; mongocxx::pool::entry hold = pool.acquire(); diff --git a/examples/api/mongocxx/examples/collections/aggregate.cpp b/examples/api/mongocxx/examples/collections/aggregate.cpp index a18aa39395..635d19ee24 100644 --- a/examples/api/mongocxx/examples/collections/aggregate.cpp +++ b/examples/api/mongocxx/examples/collections/aggregate.cpp @@ -50,9 +50,7 @@ void example(mongocxx::collection coll) { mongocxx::cursor cursor = coll.aggregate(pipeline); - auto has_field_x = [](bsoncxx::document::view doc) -> bool { - return doc.find("x") != doc.end(); - }; + auto has_field_x = [](bsoncxx::document::view doc) -> bool { return doc.find("x") != doc.end(); }; EXPECT(std::count_if(cursor.begin(), cursor.end(), has_field_x) == 1); } diff --git a/examples/api/mongocxx/examples/collections/bulk_write_with_options.cpp b/examples/api/mongocxx/examples/collections/bulk_write_with_options.cpp index f68bfd19ee..0e3d809497 100644 --- a/examples/api/mongocxx/examples/collections/bulk_write_with_options.cpp +++ b/examples/api/mongocxx/examples/collections/bulk_write_with_options.cpp @@ -43,12 +43,11 @@ void example(mongocxx::collection coll) { opts.ordered(true); // ... other bulk write options. - 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}})")}) - .execute(); + 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}})")}) + .execute(); EXPECT(result_opt); diff --git a/examples/api/mongocxx/examples/collections/create_index_with_options.cpp b/examples/api/mongocxx/examples/collections/create_index_with_options.cpp index ee2066599f..4242da02ce 100644 --- a/examples/api/mongocxx/examples/collections/create_index_with_options.cpp +++ b/examples/api/mongocxx/examples/collections/create_index_with_options.cpp @@ -40,8 +40,7 @@ void example(mongocxx::collection coll) { auto opts = bsoncxx::from_json(R"({"name": "custom_name", "unique": true})"); // ... other index options. - bsoncxx::document::value result = - coll.create_index(bsoncxx::from_json(R"({"key_a": 1})"), opts.view()); + bsoncxx::document::value result = coll.create_index(bsoncxx::from_json(R"({"key_a": 1})"), opts.view()); EXPECT(result["name"]); EXPECT(result["name"].get_string().value == "custom_name"); @@ -55,8 +54,7 @@ void example(mongocxx::collection coll) { // ... set create index options. - bsoncxx::document::value result = - coll.create_index(bsoncxx::from_json(R"({"key_b": 1})"), opts.view()); + bsoncxx::document::value result = coll.create_index(bsoncxx::from_json(R"({"key_b": 1})"), opts.view()); EXPECT(result["name"]); EXPECT(result["name"].get_string().value == "key_b_1"); diff --git a/examples/api/mongocxx/examples/collections/index_views/create.cpp b/examples/api/mongocxx/examples/collections/index_views/create.cpp index 6edfcd65e0..dd16905d95 100644 --- a/examples/api/mongocxx/examples/collections/index_views/create.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/create.cpp @@ -42,8 +42,7 @@ void example(mongocxx::index_view indexes) { // Index model. { - auto result_opt = - indexes.create_one(mongocxx::index_model{bsoncxx::from_json(R"({"y": 1})")}); + auto result_opt = indexes.create_one(mongocxx::index_model{bsoncxx::from_json(R"({"y": 1})")}); EXPECT(result_opt); EXPECT(result_opt->compare("y_1") == 0); diff --git a/examples/api/mongocxx/examples/collections/index_views/drop.cpp b/examples/api/mongocxx/examples/collections/index_views/drop.cpp index c64a6dcc00..060d38da1f 100644 --- a/examples/api/mongocxx/examples/collections/index_views/drop.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/drop.cpp @@ -72,8 +72,7 @@ RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { auto coll = set_rw_concern_majority(guard.get().create_collection("coll")); (void)coll.create_index(bsoncxx::from_json(R"({"x": 1})")); - (void)coll.create_index(bsoncxx::from_json(R"({"y": 1})"), - bsoncxx::from_json(R"({"name": "custom_name"})")); + (void)coll.create_index(bsoncxx::from_json(R"({"y": 1})"), bsoncxx::from_json(R"({"name": "custom_name"})")); example(coll.indexes()); } diff --git a/examples/api/mongocxx/examples/collections/index_views/drop_all.cpp b/examples/api/mongocxx/examples/collections/index_views/drop_all.cpp index eccdea1489..8fa625c9c6 100644 --- a/examples/api/mongocxx/examples/collections/index_views/drop_all.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/drop_all.cpp @@ -68,8 +68,7 @@ RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { auto coll = set_rw_concern_majority(guard.get().create_collection("coll")); (void)coll.create_index(bsoncxx::from_json(R"({"x": 1})")); - (void)coll.create_index(bsoncxx::from_json(R"({"y": 1})"), - bsoncxx::from_json(R"({"name": "custom_name"})")); + (void)coll.create_index(bsoncxx::from_json(R"({"y": 1})"), bsoncxx::from_json(R"({"name": "custom_name"})")); example(coll.indexes()); } diff --git a/examples/api/mongocxx/examples/collections/update_one.cpp b/examples/api/mongocxx/examples/collections/update_one.cpp index 47be0524c9..3eaf7045a6 100644 --- a/examples/api/mongocxx/examples/collections/update_one.cpp +++ b/examples/api/mongocxx/examples/collections/update_one.cpp @@ -72,9 +72,8 @@ void example(mongocxx::collection coll) { opts.upsert(true); // ... other update options. - EXPECT(coll.update_one(bsoncxx::from_json(R"({"x": 4})"), - bsoncxx::from_json(R"({"$set": {"updated": true}})"), - opts)); + EXPECT(coll.update_one( + bsoncxx::from_json(R"({"x": 4})"), bsoncxx::from_json(R"({"$set": {"updated": true}})"), opts)); EXPECT(coll.count_documents(x4.view()) == 1); EXPECT(coll.count_documents(updated.view()) == 2); diff --git a/examples/api/runner.cpp b/examples/api/runner.cpp index 4a01574ee3..4b65bf7e9c 100644 --- a/examples/api/runner.cpp +++ b/examples/api/runner.cpp @@ -143,8 +143,7 @@ class runner_type { // For non-zero exit codes, permit continuation for example coverage. if (WIFEXITED(status) && WEXITSTATUS(status) != EXIT_SUCCESS) { std::cout << __func__ << ": failed: " << name - << " exited with a non-zero exit code: " << WEXITSTATUS(status) - << std::endl; + << " exited with a non-zero exit code: " << WEXITSTATUS(status) << std::endl; return action::fail; } @@ -154,8 +153,7 @@ class runner_type { const int signal = WTERMSIG(status); const char* const sigstr = ::strsignal(signal); - std::cout << __func__ << ": failed: " << name - << " was killed by signal: " << signal << " (" + std::cout << __func__ << ": failed: " << name << " was killed by signal: " << signal << " (" << (sigstr ? sigstr : "") << ")" << std::endl; std::exit(EXIT_FAILURE); @@ -184,8 +182,7 @@ class runner_type { try { mongocxx::client client{mongocxx::uri{"mongodb://localhost:27017/"}}; - const auto reply = - client["admin"].run_command(bsoncxx::from_json(R"({"isMaster": 1})")); + const auto reply = client["admin"].run_command(bsoncxx::from_json(R"({"isMaster": 1})")); if (reply["msg"]) { std::cout << "Running API examples against a live sharded server" << std::endl; @@ -201,8 +198,7 @@ class runner_type { run_with_jobs(components_for_single, jobs); } } catch (const mongocxx::exception& ex) { - std::cout << "Skipping API examples that require a live server: " << ex.what() - << std::endl; + std::cout << "Skipping API examples that require a live server: " << ex.what() << std::endl; } } @@ -297,12 +293,11 @@ class runner_type { if (verbose) { std::vector names; - names.reserve(std::accumulate(std::begin(all_components), - std::end(all_components), - std::size_t{0}, - [](std::size_t n, const std::vector* 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, const std::vector* cptr) { return n + cptr->size(); })); for (auto cptr : all_components) { for (auto c : *cptr) { @@ -352,8 +347,7 @@ bool parse_seed(int argc, char** argv, int i, bool& set_seed) { char* const seed_str = argv[i + 1]; // Next argument. char* end = nullptr; - const auto seed = - static_cast(std::strtoul(seed_str, &end, 10)); + const auto seed = static_cast(std::strtoul(seed_str, &end, 10)); if (static_cast(end - seed_str) != std::strlen(seed_str)) { std::cerr << "invalid seed string: " << seed_str << std::endl; diff --git a/examples/api/runner.hh b/examples/api/runner.hh index 684553624b..d6dad829f2 100644 --- a/examples/api/runner.hh +++ b/examples/api/runner.hh @@ -36,27 +36,22 @@ void runner_register_forking_component(void (*fn)(), const char* name); #define EXAMPLES_COMPONENT_NAME_STR EXAMPLES_COMPONENT_NAME_STR_IMPL(EXAMPLES_COMPONENT_NAME) #define EXAMPLES_COMPONENT_NAME_STR_IMPL(name) EXAMPLES_STR(name) -#define RUNNER_REGISTER_COMPONENT_IMPL(name, register_fn) \ - static void EXAMPLES_CONCAT3(name, _entry_point_, __LINE__)(void); \ - static void EXAMPLES_CONCAT4(name, _entry_point_, __LINE__, _guarded)(void) try { \ - EXAMPLES_CONCAT3(name, _entry_point_, __LINE__)(); \ - } catch (...) { \ - std::cout << EXAMPLES_STR(name) ":" << __LINE__ << ": failed: uncaught exception" \ - << std::endl; \ - throw; \ - } \ - static int EXAMPLES_CONCAT2(name, _registrator) = \ - ((register_fn)(&EXAMPLES_CONCAT4(name, _entry_point_, __LINE__, _guarded), \ - EXAMPLES_STR(name)), \ - 0); \ +#define RUNNER_REGISTER_COMPONENT_IMPL(name, register_fn) \ + static void EXAMPLES_CONCAT3(name, _entry_point_, __LINE__)(void); \ + static void EXAMPLES_CONCAT4(name, _entry_point_, __LINE__, _guarded)(void) try { \ + EXAMPLES_CONCAT3(name, _entry_point_, __LINE__)(); \ + } catch (...) { \ + std::cout << EXAMPLES_STR(name) ":" << __LINE__ << ": failed: uncaught exception" << std::endl; \ + throw; \ + } \ + static int EXAMPLES_CONCAT2(name, _registrator) = \ + ((register_fn)(&EXAMPLES_CONCAT4(name, _entry_point_, __LINE__, _guarded), EXAMPLES_STR(name)), 0); \ static void EXAMPLES_CONCAT3(EXAMPLES_COMPONENT_NAME, _entry_point_, __LINE__)(void) -#define RUNNER_REGISTER_COMPONENT() \ - RUNNER_REGISTER_COMPONENT_IMPL(EXAMPLES_COMPONENT_NAME, ::runner_register_component) +#define RUNNER_REGISTER_COMPONENT() RUNNER_REGISTER_COMPONENT_IMPL(EXAMPLES_COMPONENT_NAME, ::runner_register_component) -#define RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() \ - RUNNER_REGISTER_COMPONENT_IMPL(EXAMPLES_COMPONENT_NAME, \ - ::runner_register_component_with_instance) +#define RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() \ + RUNNER_REGISTER_COMPONENT_IMPL(EXAMPLES_COMPONENT_NAME, ::runner_register_component_with_instance) #define RUNNER_REGISTER_COMPONENT_FOR_SINGLE() \ RUNNER_REGISTER_COMPONENT_IMPL(EXAMPLES_COMPONENT_NAME, ::runner_register_component_for_single) diff --git a/examples/bsoncxx/builder_basic.cpp b/examples/bsoncxx/builder_basic.cpp index c1b1b94e0f..b149f31081 100644 --- a/examples/bsoncxx/builder_basic.cpp +++ b/examples/bsoncxx/builder_basic.cpp @@ -36,15 +36,12 @@ int EXAMPLES_CDECL main() { // We append key-value pairs to a document using the kvp helper. using bsoncxx::builder::basic::kvp; - doc.append( - kvp("foo", "bar")); // string literal value will be converted to b_string automatically + doc.append(kvp("foo", "bar")); // string literal value will be converted to b_string automatically doc.append(kvp("baz", types::b_bool{false})); doc.append(kvp("garply", types::b_double{3.14159})); // We can also pass a variable number of keys to append. - doc.append(kvp("a key", "a value"), - kvp("another key", "another value"), - kvp("moar keys", "moar values")); + doc.append(kvp("a key", "a value"), kvp("another key", "another value"), kvp("moar keys", "moar values")); // Appending to arrays is simple, just append one or more bson values. arr.append("hello"); diff --git a/examples/bsoncxx/builder_stream.cpp b/examples/bsoncxx/builder_stream.cpp index 4d50379a53..2092f6c5cd 100644 --- a/examples/bsoncxx/builder_stream.cpp +++ b/examples/bsoncxx/builder_stream.cpp @@ -37,8 +37,7 @@ int EXAMPLES_CDECL main() { doc << "myKey" << "myValue"; // We can chain any number of keys and values - doc << "foo" << types::b_bool{false} << "baz" << types::b_int32{1234} << "quz" - << types::b_double{1.234}; + doc << "foo" << types::b_bool{false} << "baz" << types::b_int32{1234} << "quz" << types::b_double{1.234}; // For arrays, everything just becomes a value arr << 1 << 2 << types::b_bool{true}; @@ -79,8 +78,7 @@ int EXAMPLES_CDECL main() { bsoncxx::document::value nestedValue = document{} << "nested" << true << finalize; document topLevelDoc{}; topLevelDoc << "subDoc1" << types::b_document{nestedValue.view()} << "subDoc2" << open_document - << concatenate(nestedValue.view()) << close_document << "subDoc3" << nestedValue - << finalize; + << concatenate(nestedValue.view()) << close_document << "subDoc3" << nestedValue << finalize; // `topLevelDoc` now looks like: // { diff --git a/examples/bsoncxx/builder_stream_customization.cpp b/examples/bsoncxx/builder_stream_customization.cpp index 87879779da..1716565bf1 100644 --- a/examples/bsoncxx/builder_stream_customization.cpp +++ b/examples/bsoncxx/builder_stream_customization.cpp @@ -27,8 +27,7 @@ using namespace bsoncxx; template class range_array_appender { public: - range_array_appender(begin_t begin, end_t end) - : _begin(std::move(begin)), _end(std::move(end)) {} + range_array_appender(begin_t begin, end_t end) : _begin(std::move(begin)), _end(std::move(end)) {} void operator()(bsoncxx::builder::stream::array_context<> ac) const { for (auto iter = _begin; iter != _end; ++iter) { @@ -43,8 +42,7 @@ class range_array_appender { template range_array_appender make_range_array_appender(begin_t&& begin, end_t&& end) { - return range_array_appender(std::forward(begin), - std::forward(end)); + return range_array_appender(std::forward(begin), std::forward(end)); } // concatenates arbitrary ranges into an key context @@ -66,8 +64,7 @@ class range_kvp_appender { template range_kvp_appender make_range_kvp_appender(begin_t&& begin, end_t&& end) { - return range_kvp_appender(std::forward(begin), - std::forward(end)); + return range_kvp_appender(std::forward(begin), std::forward(end)); } int EXAMPLES_CDECL main() { @@ -83,8 +80,7 @@ int EXAMPLES_CDECL main() { std::map some_kvps = {{"a", 1}, {"b", 2}, {"c", 3}}; // Adapt our kvps - auto doc = document() << make_range_kvp_appender(some_kvps.begin(), some_kvps.end()) - << finalize; + auto doc = document() << make_range_kvp_appender(some_kvps.begin(), some_kvps.end()) << finalize; // Now doc = { // "a" : 1, // "b" : 2, @@ -95,8 +91,7 @@ int EXAMPLES_CDECL main() { std::vector some_numbers = {1, 2, 3}; // Adapt our values - auto arr = array() << make_range_array_appender(some_numbers.begin(), some_numbers.end()) - << finalize; + auto arr = array() << make_range_array_appender(some_numbers.begin(), some_numbers.end()) << finalize; // Now arr = { // "0" : 1, // "1" : 2, diff --git a/examples/bsoncxx/getting_values.cpp b/examples/bsoncxx/getting_values.cpp index b0a9f6c221..7e754ae1f1 100644 --- a/examples/bsoncxx/getting_values.cpp +++ b/examples/bsoncxx/getting_values.cpp @@ -89,8 +89,7 @@ int EXAMPLES_CDECL main() { auto first_name_str = doc["name"]["first"].get_string().value; // Make all variables used. - return (awards && first_award_year && second_award_year && last_name && id_i32 == 1 && - first_name_str == "John") + return (awards && first_award_year && second_award_year && last_name && id_i32 == 1 && first_name_str == "John") ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/examples/bsoncxx/view_and_value.cpp b/examples/bsoncxx/view_and_value.cpp index 1fe9637ca5..5595d1b4be 100644 --- a/examples/bsoncxx/view_and_value.cpp +++ b/examples/bsoncxx/view_and_value.cpp @@ -41,10 +41,9 @@ int EXAMPLES_CDECL main() { using builder::basic::sub_array; auto doc = builder::basic::document{}; - doc.append( - kvp("team", "platforms"), kvp("id", types::b_oid{oid()}), kvp("members", [](sub_array sa) { - sa.append("tyler", "jason", "drew", "sam", "ernie", "john", "mark", "crystal"); - })); + doc.append(kvp("team", "platforms"), kvp("id", types::b_oid{oid()}), kvp("members", [](sub_array sa) { + sa.append("tyler", "jason", "drew", "sam", "ernie", "john", "mark", "crystal"); + })); // document::value is an owning bson document conceptually similar to string. document::value value{doc.extract()}; @@ -81,8 +80,7 @@ int EXAMPLES_CDECL main() { // if we have a subarray, we can access it by getting a view of it. array::view subarr{doc_ele.get_array().value}; for (array::element arr_ele : subarr) { - std::cout << "array element: " - << bsoncxx::string::to_string(arr_ele.get_string().value) + std::cout << "array element: " << bsoncxx::string::to_string(arr_ele.get_string().value) << std::endl; } break; diff --git a/examples/macros.hh b/examples/macros.hh index ac879df96e..482788b55f 100644 --- a/examples/macros.hh +++ b/examples/macros.hh @@ -25,18 +25,16 @@ #define EXAMPLES_CONCAT2(a, b) EXAMPLES_CONCAT_IMPL(a, b) #define EXAMPLES_CONCAT3(a, b, c) EXAMPLES_CONCAT2(EXAMPLES_CONCAT2(a, b), c) -#define EXAMPLES_CONCAT4(a, b, c, d) \ - EXAMPLES_CONCAT2(EXAMPLES_CONCAT2(a, b), EXAMPLES_CONCAT2(c, d)) +#define EXAMPLES_CONCAT4(a, b, c, d) EXAMPLES_CONCAT2(EXAMPLES_CONCAT2(a, b), EXAMPLES_CONCAT2(c, d)) #define EXAMPLES_CONCAT_IMPL(a, b) a##b #define EXAMPLES_STR(e) #e // Unconditionally `assert()` expectations in examples. -#define EXPECT(...) \ - if (!static_cast(__VA_ARGS__)) { \ - std::printf( \ - "%s:%d: %s: expectation failed: %s\n", __FILE__, __LINE__, __func__, #__VA_ARGS__); \ - std::fflush(stdout); \ - std::abort(); \ - } else \ +#define EXPECT(...) \ + if (!static_cast(__VA_ARGS__)) { \ + std::printf("%s:%d: %s: expectation failed: %s\n", __FILE__, __LINE__, __func__, #__VA_ARGS__); \ + std::fflush(stdout); \ + std::abort(); \ + } else \ ((void)0) diff --git a/examples/mongocxx/aggregate.cpp b/examples/mongocxx/aggregate.cpp index b66402f958..9e80132b75 100644 --- a/examples/mongocxx/aggregate.cpp +++ b/examples/mongocxx/aggregate.cpp @@ -41,8 +41,7 @@ int EXAMPLES_CDECL main() { { mongocxx::pipeline stages; - stages.group( - make_document(kvp("_id", "$borough"), kvp("count", make_document(kvp("$sum", 1))))); + stages.group(make_document(kvp("_id", "$borough"), kvp("count", make_document(kvp("$sum", 1))))); auto cursor = db["restaurants"].aggregate(stages); @@ -56,8 +55,7 @@ int EXAMPLES_CDECL main() { mongocxx::pipeline stages; stages.match(make_document(kvp("borough", "queens"), kvp("cuisine", "Brazilian"))) - .group(make_document(kvp("_id", "$address.zipcode"), - kvp("count", make_document(kvp("$sum", 1))))); + .group(make_document(kvp("_id", "$address.zipcode"), kvp("count", make_document(kvp("$sum", 1))))); auto cursor = db["restaurants"].aggregate(stages); diff --git a/examples/mongocxx/automatic_client_side_field_level_encryption.cpp b/examples/mongocxx/automatic_client_side_field_level_encryption.cpp index eb35cd6ccf..5647b09f56 100644 --- a/examples/mongocxx/automatic_client_side_field_level_encryption.cpp +++ b/examples/mongocxx/automatic_client_side_field_level_encryption.cpp @@ -68,13 +68,12 @@ void create_json_schema_file(bsoncxx::document::view_or_value kms_providers, auto data_key_id = client_encryption.create_data_key("local"); // Create a new json schema for the encryptedField. - auto json_schema = document{} << "properties" << open_document << "encryptedField" - << open_document << "encrypt" << open_document << "keyId" - << open_array << data_key_id << close_array << "bsonType" + auto json_schema = document{} << "properties" << open_document << "encryptedField" << open_document << "encrypt" + << open_document << "keyId" << open_array << data_key_id << close_array << "bsonType" << "string" << "algorithm" - << "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" << close_document - << close_document << close_document << "bsonType" + << "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" << close_document << close_document + << close_document << "bsonType" << "object" << finalize; // Write to a file. @@ -90,8 +89,7 @@ bsoncxx::document::value doc_from_file(std::string path) { throw std::runtime_error("could not open file"); } - std::string file_contents((std::istreambuf_iterator(file)), - std::istreambuf_iterator()); + std::string file_contents((std::istreambuf_iterator(file)), std::istreambuf_iterator()); return bsoncxx::from_json(file_contents); } @@ -104,14 +102,11 @@ int EXAMPLES_CDECL main() { // This must be the same master key that was used to create // the encryption key; here, we use a random key as a placeholder. std::uint8_t key_storage[kKeyLength]; - std::generate_n(key_storage, kKeyLength, []() { - return static_cast(std::rand() % UINT8_MAX); - }); - bsoncxx::types::b_binary local_master_key{ - bsoncxx::binary_sub_type::k_binary, kKeyLength, key_storage}; + std::generate_n(key_storage, kKeyLength, []() { return static_cast(std::rand() % UINT8_MAX); }); + bsoncxx::types::b_binary local_master_key{bsoncxx::binary_sub_type::k_binary, kKeyLength, key_storage}; - auto kms_providers = document{} << "local" << open_document << "key" << local_master_key - << close_document << finalize; + auto kms_providers = document{} << "local" << open_document << "key" << local_master_key << close_document + << finalize; // The MongoClient used to access the key vault. class client key_vault_client{uri{}}; @@ -123,8 +118,7 @@ int EXAMPLES_CDECL main() { mongocxx::options::index index_options{}; index_options.unique(true); - auto expression = document{} << "keyAltNames" << open_document << "$exists" << true - << close_document << finalize; + auto expression = document{} << "keyAltNames" << open_document << "$exists" << true << close_document << finalize; index_options.partial_filter_expression(expression.view()); key_vault.create_index(make_document(kvp("keyAltNames", 1)), index_options); @@ -151,12 +145,10 @@ int EXAMPLES_CDECL main() { coll.insert_one(make_document(kvp("encryptedField", "123456789"))); auto res = coll.find_one({}); - std::cout << "\nDocument retrieved with auto-encrypted client:\n" - << bsoncxx::to_json(*res) << std::endl; + std::cout << "\nDocument retrieved with auto-encrypted client:\n" << bsoncxx::to_json(*res) << std::endl; class client unencrypted_client{uri{}}; auto unencrypted_coll = unencrypted_client["test"]["coll"]; auto res2 = unencrypted_coll.find_one({}); - std::cout << "\nDocument retrieved with unencrypted client:\n" - << bsoncxx::to_json(*res2) << std::endl; + std::cout << "\nDocument retrieved with unencrypted client:\n" << bsoncxx::to_json(*res2) << std::endl; } diff --git a/examples/mongocxx/causal_consistency.cpp b/examples/mongocxx/causal_consistency.cpp index 856b4ac2e2..2042cab8e0 100644 --- a/examples/mongocxx/causal_consistency.cpp +++ b/examples/mongocxx/causal_consistency.cpp @@ -79,8 +79,7 @@ int EXAMPLES_CDECL main() { auto update_filter = document{} << "sku" << "111" << "end" << none << finalize; - auto update_op = document{} << "$set" << open_document << "end" << current_date - << close_document << finalize; + auto update_op = document{} << "$set" << open_document << "end" << current_date << close_document << finalize; items.update_one(session_1, std::move(update_filter), std::move(update_op), {}); // Run an insert with our causally-consistent session. diff --git a/examples/mongocxx/change_streams.cpp b/examples/mongocxx/change_streams.cpp index 01dcaa6b77..8482e4356f 100644 --- a/examples/mongocxx/change_streams.cpp +++ b/examples/mongocxx/change_streams.cpp @@ -97,8 +97,7 @@ int EXAMPLES_CDECL main(int argc, char* argv[]) { } std::cerr << "Unexpected argument: '" << arg << "'" << std::endl; - std::cerr << "Usage: " << argv[0] << " [--uri ] [--db ] [--coll ]" - << std::endl; + std::cerr << "Usage: " << argv[0] << " [--uri ] [--db ] [--coll ]" << std::endl; return EXIT_FAILURE; } @@ -108,8 +107,7 @@ int EXAMPLES_CDECL main(int argc, char* argv[]) { auto entry = pool.acquire(); auto collection = (*entry)[db][coll]; - std::cout << "Watching for notifications on the collection " << db << "." << coll - << std::endl; + std::cout << "Watching for notifications on the collection " << db << "." << coll << std::endl; std::cout << "To observe a notification, try inserting a document." << std::endl; watch_forever(collection); diff --git a/examples/mongocxx/client_session.cpp b/examples/mongocxx/client_session.cpp index db74ed045d..fcc3e3a6dc 100644 --- a/examples/mongocxx/client_session.cpp +++ b/examples/mongocxx/client_session.cpp @@ -51,9 +51,8 @@ int EXAMPLES_CDECL main() { // causal consistency. auto session = conn.start_session(); auto coll = conn["db"]["collection"]; - auto result = coll.update_one(session, - make_document(kvp("_id", 1)), - make_document(kvp("$inc", make_document(kvp("x", 1))))); + auto result = + coll.update_one(session, make_document(kvp("_id", 1)), make_document(kvp("$inc", make_document(kvp("x", 1))))); std::cout << "Updated " << result->modified_count() << " documents" << std::endl; diff --git a/examples/mongocxx/create.cpp b/examples/mongocxx/create.cpp index f2730ccd21..46ad546173 100644 --- a/examples/mongocxx/create.cpp +++ b/examples/mongocxx/create.cpp @@ -49,14 +49,12 @@ int EXAMPLES_CDECL main() { kvp("borough", "Manhattan"), kvp("cuisine", "Italian"), kvp("grades", - make_array( - make_document(kvp("date", bsoncxx::types::b_date{std::chrono::milliseconds{12323}}), - kvp("grade", "A"), - kvp("score", 11)), - make_document( - kvp("date", bsoncxx::types::b_date{std::chrono::milliseconds{121212}}), - kvp("grade", "B"), - kvp("score", 17)))), + make_array(make_document(kvp("date", bsoncxx::types::b_date{std::chrono::milliseconds{12323}}), + kvp("grade", "A"), + kvp("score", 11)), + make_document(kvp("date", bsoncxx::types::b_date{std::chrono::milliseconds{121212}}), + kvp("grade", "B"), + kvp("score", 17)))), kvp("name", "Vella"), kvp("restaurant_id", "41704620")); diff --git a/examples/mongocxx/document_validation.cpp b/examples/mongocxx/document_validation.cpp index 7b864c1484..6ff0ba31f8 100644 --- a/examples/mongocxx/document_validation.cpp +++ b/examples/mongocxx/document_validation.cpp @@ -50,20 +50,16 @@ int EXAMPLES_CDECL main() { // Create a validation rule: all zombies need to eat some brains. collection zombies = db.create_collection( - "zombies", - make_document( - kvp("validator", make_document(kvp("brains", make_document(kvp("$gt", 0))))))); + "zombies", make_document(kvp("validator", make_document(kvp("brains", make_document(kvp("$gt", 0))))))); try { // Insert a document passing validation - auto res = - zombies.insert_one(make_document(kvp("name", "Bloody Betty"), kvp("brains", 3))); + auto res = zombies.insert_one(make_document(kvp("name", "Bloody Betty"), kvp("brains", 3))); std::cout << "Bloody Betty passed document validation!" << std::endl; // Insert a document failing validation, which should throw. - auto res2 = - zombies.insert_one(make_document(kvp("name", "Undead Fred"), kvp("brains", 0))); + auto res2 = zombies.insert_one(make_document(kvp("name", "Undead Fred"), kvp("brains", 0))); std::cout << "ERROR: server does not support document validation." << std::endl; diff --git a/examples/mongocxx/explicit_encryption.cpp b/examples/mongocxx/explicit_encryption.cpp index 617f53453d..5df5324e91 100644 --- a/examples/mongocxx/explicit_encryption.cpp +++ b/examples/mongocxx/explicit_encryption.cpp @@ -54,14 +54,11 @@ int EXAMPLES_CDECL main() { // This must be the same master key that was used to create // the encryption key; here, we use a random key as a placeholder. std::uint8_t key_storage[kKeyLength]; - std::generate_n(key_storage, kKeyLength, []() { - return static_cast(std::rand() % UINT8_MAX); - }); - bsoncxx::types::b_binary local_master_key{ - bsoncxx::binary_sub_type::k_binary, kKeyLength, key_storage}; + std::generate_n(key_storage, kKeyLength, []() { return static_cast(std::rand() % UINT8_MAX); }); + bsoncxx::types::b_binary local_master_key{bsoncxx::binary_sub_type::k_binary, kKeyLength, key_storage}; - auto kms_providers = document{} << "local" << open_document << "key" << local_master_key - << close_document << finalize; + auto kms_providers = document{} << "local" << open_document << "key" << local_master_key << close_document + << finalize; // Create an unencrypted mongocxx::client. class client client{uri{}}; @@ -79,8 +76,7 @@ int EXAMPLES_CDECL main() { mongocxx::options::index index_options{}; index_options.unique(true); - auto expression = document{} << "keyAltNames" << open_document << "$exists" << true - << close_document << finalize; + auto expression = document{} << "keyAltNames" << open_document << "$exists" << true << close_document << finalize; index_options.partial_filter_expression(expression.view()); key_vault.create_index(make_document(kvp("keyAltNames", 1)), index_options); @@ -112,6 +108,5 @@ int EXAMPLES_CDECL main() { // Explicitly decrypt the field: auto encrypted_message_retrieved = res->view()["encryptedField"].get_value(); auto decrypted_message = client_encryption.decrypt(encrypted_message_retrieved); - std::cout << "Explicitly decrypted message: " << decrypted_message.view().get_string().value - << std::endl; + std::cout << "Explicitly decrypted message: " << decrypted_message.view().get_string().value << std::endl; } diff --git a/examples/mongocxx/explicit_encryption_auto_decryption.cpp b/examples/mongocxx/explicit_encryption_auto_decryption.cpp index 0ef44cefa6..6840fe51d7 100644 --- a/examples/mongocxx/explicit_encryption_auto_decryption.cpp +++ b/examples/mongocxx/explicit_encryption_auto_decryption.cpp @@ -54,14 +54,11 @@ int EXAMPLES_CDECL main() { // This must be the same master key that was used to create // the encryption key; here, we use a random key as a placeholder. std::uint8_t key_storage[kKeyLength]; - std::generate_n(key_storage, kKeyLength, []() { - return static_cast(std::rand() % UINT8_MAX); - }); - bsoncxx::types::b_binary local_master_key{ - bsoncxx::binary_sub_type::k_binary, kKeyLength, key_storage}; + std::generate_n(key_storage, kKeyLength, []() { return static_cast(std::rand() % UINT8_MAX); }); + bsoncxx::types::b_binary local_master_key{bsoncxx::binary_sub_type::k_binary, kKeyLength, key_storage}; - auto kms_providers = document{} << "local" << open_document << "key" << local_master_key - << close_document << finalize; + auto kms_providers = document{} << "local" << open_document << "key" << local_master_key << close_document + << finalize; // Setting bypass_auto_encryption to "true" on the options::auto_encryption // class will disable automatic encryption but keeps the automatic decryption @@ -89,8 +86,7 @@ int EXAMPLES_CDECL main() { mongocxx::options::index index_options{}; index_options.unique(true); - auto expression = document{} << "keyAltNames" << open_document << "$exists" << true - << close_document << finalize; + auto expression = document{} << "keyAltNames" << open_document << "$exists" << true << close_document << finalize; index_options.partial_filter_expression(expression.view()); key_vault.create_index(make_document(kvp("keyAltNames", 1)), index_options); diff --git a/examples/mongocxx/get_values_from_documents.cpp b/examples/mongocxx/get_values_from_documents.cpp index 0edd3d625f..2bfd594aca 100644 --- a/examples/mongocxx/get_values_from_documents.cpp +++ b/examples/mongocxx/get_values_from_documents.cpp @@ -51,11 +51,10 @@ bsoncxx::document::value new_message(int64_t uid, int32_t status, std::string ms // Insert a document into the database. void insert_test_data(mongocxx::collection& coll) { - bsoncxx::document::value doc = - make_document(kvp("messagelist", - make_array(new_message(413098706, 3, "Lorem ipsum..."), - new_message(413098707, 2, "Lorem ipsum..."), - new_message(413098708, 1, "Lorem ipsum...")))); + bsoncxx::document::value doc = make_document(kvp("messagelist", + make_array(new_message(413098706, 3, "Lorem ipsum..."), + new_message(413098707, 2, "Lorem ipsum..."), + new_message(413098708, 1, "Lorem ipsum...")))); // Normally, one should check the return value for success. coll.insert_one(std::move(doc)); diff --git a/examples/mongocxx/gridfs.cpp b/examples/mongocxx/gridfs.cpp index 37d48cf8bd..cf4f303fb6 100644 --- a/examples/mongocxx/gridfs.cpp +++ b/examples/mongocxx/gridfs.cpp @@ -65,8 +65,7 @@ int EXAMPLES_CDECL main() { // Use `std::make_unique` with C++14 and newer. auto buffer = std::unique_ptr(new std::uint8_t[buffer_size]); - while (auto length_read = - downloader.read(buffer.get(), static_cast(buffer_size))) { + while (auto length_read = downloader.read(buffer.get(), static_cast(buffer_size))) { bytes_counter += static_cast(length_read); // Do something with the contents of buffer. diff --git a/examples/mongocxx/index.cpp b/examples/mongocxx/index.cpp index 54881081dc..a2661d39f8 100644 --- a/examples/mongocxx/index.cpp +++ b/examples/mongocxx/index.cpp @@ -46,8 +46,7 @@ int EXAMPLES_CDECL main() { // Create a compound index. { db["restaurants"].drop(); - db["restaurants"].create_index(make_document(kvp("cuisine", 1), kvp("address.zipcode", -1)), - {}); + db["restaurants"].create_index(make_document(kvp("cuisine", 1), kvp("address.zipcode", -1)), {}); } // Create a unique index. diff --git a/examples/mongocxx/instance_management.cpp b/examples/mongocxx/instance_management.cpp index 73d0d20cbf..ad1ddf568d 100644 --- a/examples/mongocxx/instance_management.cpp +++ b/examples/mongocxx/instance_management.cpp @@ -47,8 +47,7 @@ class mongo_access { return instance; } - void configure(std::unique_ptr instance, - std::unique_ptr pool) { + void configure(std::unique_ptr instance, std::unique_ptr pool) { _instance = std::move(instance); _pool = std::move(pool); } @@ -72,14 +71,13 @@ class mongo_access { void configure(mongocxx::uri uri) { class noop_logger : public mongocxx::logger { public: - void operator()(mongocxx::log_level, - bsoncxx::stdx::string_view, - bsoncxx::stdx::string_view) noexcept override {} + void operator()(mongocxx::log_level, bsoncxx::stdx::string_view, bsoncxx::stdx::string_view) noexcept override { + } }; // Use `std::make_unique` with C++14 and newer. - auto instance = std::unique_ptr( - new mongocxx::instance(std::unique_ptr(new noop_logger()))); + auto instance = + std::unique_ptr(new mongocxx::instance(std::unique_ptr(new noop_logger()))); // Use `std::make_unique` with C++14 and newer. auto pool = std::unique_ptr(new mongocxx::pool(std::move(uri))); diff --git a/examples/mongocxx/mongodb.com/aggregation_examples.cpp b/examples/mongocxx/mongodb.com/aggregation_examples.cpp index 30657bae73..680797fb0b 100644 --- a/examples/mongocxx/mongodb.com/aggregation_examples.cpp +++ b/examples/mongocxx/mongodb.com/aggregation_examples.cpp @@ -58,11 +58,9 @@ void aggregation_examples(const mongocxx::database& db) { mongocxx::pipeline p{}; p.unwind("$items"); p.match(make_document(kvp("items.fruit", "banana"))); - p.group(make_document( - kvp("_id", make_document(kvp("day", make_document(kvp("$dayOfWeek", "$date"))))), - kvp("count", make_document(kvp("$sum", "$items.quantity"))))); - p.project(make_document( - kvp("dayOfWeek", "$_id.day"), kvp("numberSold", "$count"), kvp("_id", 0))); + p.group(make_document(kvp("_id", make_document(kvp("day", make_document(kvp("$dayOfWeek", "$date"))))), + kvp("count", make_document(kvp("$sum", "$items.quantity"))))); + p.project(make_document(kvp("dayOfWeek", "$_id.day"), kvp("numberSold", "$count"), kvp("_id", 0))); p.sort(make_document(kvp("numberSold", 1))); auto cursor = db["sales"].aggregate(p, mongocxx::options::aggregate{}); @@ -85,20 +83,16 @@ void aggregation_examples(const mongocxx::database& db) { kvp("items_sold", make_document(kvp("$sum", "$items.quantity"))), kvp("revenue", make_document( - kvp("$sum", - make_document( - kvp("$multiply", make_array("$items.quantity", "$items.price")))))))); + kvp("$sum", make_document(kvp("$multiply", make_array("$items.quantity", "$items.price")))))))); p.project(make_document( kvp("day", "$_id.day"), kvp("revenue", 1), kvp("items_sold", 1), kvp("discount", - make_document( - kvp("$cond", - make_document( - kvp("if", make_document(kvp("$lte", make_array("$revenue", 250)))), - kvp("then", 25), - kvp("else", 0))))))); + make_document(kvp("$cond", + make_document(kvp("if", make_document(kvp("$lte", make_array("$revenue", 250)))), + kvp("then", 25), + kvp("else", 0))))))); auto cursor = db["sales"].aggregate(p, mongocxx::options::aggregate{}); // End Aggregation Example 3 @@ -117,23 +111,20 @@ void aggregation_examples(const mongocxx::database& db) { kvp("from", "air_airlines"), kvp("let", make_document(kvp("constituents", "$airlines"))), kvp("pipeline", - make_array(make_document( - kvp("$match", - make_document(kvp( - "$expr", - make_document(kvp("$in", make_array("$name", "$$constituents"))))))))), + make_array(make_document(kvp( + "$match", + make_document(kvp("$expr", make_document(kvp("$in", make_array("$name", "$$constituents"))))))))), kvp("as", "airlines"))); p.project(make_document( kvp("_id", 0), kvp("name", 1), kvp("airlines", - make_document(kvp( - "$filter", - make_document(kvp("input", "$airlines"), - kvp("as", "airline"), - kvp("cond", - make_document(kvp( - "$eq", make_array("$$airline.country", "Canada")))))))))); + make_document( + kvp("$filter", + make_document( + kvp("input", "$airlines"), + kvp("as", "airline"), + kvp("cond", make_document(kvp("$eq", make_array("$$airline.country", "Canada")))))))))); auto cursor = db["air_alliances"].aggregate(p, mongocxx::options::aggregate{}); // End Aggregation Example 4 diff --git a/examples/mongocxx/mongodb.com/documentation_examples.cpp b/examples/mongocxx/mongodb.com/documentation_examples.cpp index ff1d20ac2d..5ccfcf4ee1 100644 --- a/examples/mongocxx/mongodb.com/documentation_examples.cpp +++ b/examples/mongocxx/mongodb.com/documentation_examples.cpp @@ -39,23 +39,18 @@ namespace { template -void check_field(const T& document, - const char* field, - bool should_have, - int example_no, - const char* example_type = nullptr) { +void check_field( + const T& document, const char* field, bool should_have, int example_no, const char* example_type = nullptr) { std::string example_type_formatted = example_type ? example_type + std::string(" ") : ""; if (should_have) { if (!document[field]) { - throw std::logic_error(std::string("document in ") + example_type_formatted + - std::string("example ") + std::to_string(example_no) + - " should not have field " + field); + throw std::logic_error(std::string("document in ") + example_type_formatted + std::string("example ") + + std::to_string(example_no) + " should not have field " + field); } } else { if (document[field]) { - throw std::logic_error(std::string("document in ") + example_type_formatted + - std::string("example ") + std::to_string(example_no) + - " should not have field " + field); + throw std::logic_error(std::string("document in ") + example_type_formatted + std::string("example ") + + std::to_string(example_no) + " should not have field " + field); } } } @@ -71,18 +66,12 @@ void check_has_no_field(const T& document, const char* field, int example_no) { } template -void check_has_field(const T& document, - const char* field, - int example_no, - const char* example_type) { +void check_has_field(const T& document, const char* field, int example_no, const char* example_type) { check_field(document, field, true, example_no, example_type); } template -void check_has_no_field(const T& document, - const char* field, - int example_no, - const char* example_type) { +void check_has_no_field(const T& document, const char* field, int example_no, const char* example_type) { check_field(document, field, false, example_no, example_type); } @@ -99,12 +88,12 @@ bool should_run_client_side_encryption_test(void) { "MONGOCXX_TEST_GCP_PRIVATEKEY", }; - const auto iter = std::find_if_not( - std::begin(vars), std::end(vars), [](const char* var) { return std::getenv(var); }); + const auto iter = + std::find_if_not(std::begin(vars), std::end(vars), [](const char* var) { return std::getenv(var); }); if (iter != std::end(vars)) { - std::cerr << "Skipping Queryable Encryption tests: environment variable " << *iter - << " not defined" << std::endl; + std::cerr << "Skipping Queryable Encryption tests: environment variable " << *iter << " not defined" + << std::endl; return false; } @@ -122,8 +111,7 @@ mongocxx::options::client add_test_server_api(mongocxx::options::client opts = { if (!api_version_sv.empty()) { if (api_version_sv == "1") { - opts.server_api_opts( - mongocxx::options::server_api(mongocxx::options::server_api::version::k_version_1)); + opts.server_api_opts(mongocxx::options::server_api(mongocxx::options::server_api::version::k_version_1)); } else { throw std::logic_error("invalid MONGODB_API_VERSION: " + std::string(api_version_sv)); } @@ -169,8 +157,7 @@ bsoncxx::document::value make_kms_doc(bool include_external = true) { if (include_external) { kms_doc.append(kvp("aws", [&](sub_document subdoc) { - subdoc.append( - kvp("secretAccessKey", getenv_or_fail("MONGOCXX_TEST_AWS_SECRET_ACCESS_KEY"))); + subdoc.append(kvp("secretAccessKey", getenv_or_fail("MONGOCXX_TEST_AWS_SECRET_ACCESS_KEY"))); subdoc.append(kvp("accessKeyId", getenv_or_fail("MONGOCXX_TEST_AWS_ACCESS_KEY_ID"))); })); @@ -185,16 +172,12 @@ bsoncxx::document::value make_kms_doc(bool include_external = true) { subdoc.append(kvp("privateKey", getenv_or_fail("MONGOCXX_TEST_GCP_PRIVATEKEY"))); })); - kms_doc.append(kvp("kmip", [&](sub_document subdoc) { - subdoc.append(kvp("endpoint", "localhost:5698")); - })); + kms_doc.append(kvp("kmip", [&](sub_document subdoc) { subdoc.append(kvp("endpoint", "localhost:5698")); })); } - bsoncxx::types::b_binary local_master_key{ - bsoncxx::binary_sub_type::k_binary, 96, kLocalMasterKey}; + bsoncxx::types::b_binary local_master_key{bsoncxx::binary_sub_type::k_binary, 96, kLocalMasterKey}; - kms_doc.append( - kvp("local", [&](sub_document subdoc) { subdoc.append(kvp("key", local_master_key)); })); + kms_doc.append(kvp("local", [&](sub_document subdoc) { subdoc.append(kvp("key", local_master_key)); })); return {kms_doc.extract()}; } @@ -212,10 +195,7 @@ static bool is_replica_set(const mongocxx::client& client) { return static_cast(reply.view()["setName"]); } -static bool version_at_least(mongocxx::database& db, - int minimum_major, - int minimum_minor, - int minimum_patch) { +static bool version_at_least(mongocxx::database& db, int minimum_major, int minimum_minor, int minimum_patch) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; @@ -239,8 +219,7 @@ static bool version_at_least(mongocxx::database& db, } } - std::vector server_semver{ - std::stoi(major_string), std::stoi(minor_string), std::stoi(minor_string)}; + std::vector server_semver{std::stoi(major_string), std::stoi(minor_string), std::stoi(minor_string)}; std::vector minimum_semver{minimum_major, minimum_minor, minimum_patch}; for (size_t i = 0; i < server_semver.size(); i++) { if (server_semver[i] < minimum_semver[i]) { @@ -261,11 +240,11 @@ void insert_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_array; using bsoncxx::builder::basic::make_document; - db["inventory"].insert_one(make_document( - kvp("item", "canvas"), - kvp("qty", 100), - kvp("tags", make_array("cotton")), - kvp("size", make_document(kvp("h", 28), kvp("w", 35.5), kvp("uom", "cm"))))); + db["inventory"].insert_one( + make_document(kvp("item", "canvas"), + kvp("qty", 100), + kvp("tags", make_array("cotton")), + kvp("size", make_document(kvp("h", 28), kvp("w", 35.5), kvp("uom", "cm"))))); // End Example 1 if (db["inventory"].count_documents({}) != 1) { @@ -297,16 +276,14 @@ void insert_examples(mongocxx::database db) { kvp("qty", 25), kvp("tags", make_array("blank", "red")), kvp("size", make_document(kvp("h", 14), kvp("w", 21), kvp("uom", "cm")))), - make_document( - kvp("item", "mat"), - kvp("qty", 85), - kvp("tags", make_array("gray")), - kvp("size", make_document(kvp("h", 27.9), kvp("w", 35.5), kvp("uom", "cm")))), - make_document( - kvp("item", "mousepad"), - kvp("qty", 25), - kvp("tags", make_array("gel", "blue")), - kvp("size", make_document(kvp("h", 19), kvp("w", 22.85), kvp("uom", "cm")))), + make_document(kvp("item", "mat"), + kvp("qty", 85), + kvp("tags", make_array("gray")), + kvp("size", make_document(kvp("h", 27.9), kvp("w", 35.5), kvp("uom", "cm")))), + make_document(kvp("item", "mousepad"), + kvp("qty", 25), + kvp("tags", make_array("gel", "blue")), + kvp("size", make_document(kvp("h", 19), kvp("w", 22.85), kvp("uom", "cm")))), }; db["inventory"].insert_many(docs); @@ -339,16 +316,14 @@ void query_top_level_fields_examples(mongocxx::database db) { kvp("qty", 100), kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), kvp("status", "D")), - make_document( - kvp("item", "planner"), - kvp("qty", 75), - kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), - kvp("status", "D")), - make_document( - kvp("item", "postcard"), - kvp("qty", 45), - kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), - kvp("status", "A")), + make_document(kvp("item", "planner"), + kvp("qty", 75), + kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), + kvp("status", "D")), + make_document(kvp("item", "postcard"), + kvp("qty", 45), + kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), + kvp("status", "A")), }; db["inventory"].insert_many(docs); @@ -388,8 +363,8 @@ void query_top_level_fields_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_array; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("status", make_document(kvp("$in", make_array("A", "D")))))); + auto cursor = + db["inventory"].find(make_document(kvp("status", make_document(kvp("$in", make_array("A", "D")))))); // End Example 10 if (std::distance(cursor.begin(), cursor.end()) != 5) { @@ -402,8 +377,8 @@ void query_top_level_fields_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("status", "A"), kvp("qty", make_document(kvp("$lt", 30))))); + auto cursor = + db["inventory"].find(make_document(kvp("status", "A"), kvp("qty", make_document(kvp("$lt", 30))))); // End Example 11 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -417,10 +392,9 @@ void query_top_level_fields_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_array; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find(make_document( - kvp("$or", - make_array(make_document(kvp("status", "A")), - make_document(kvp("qty", make_document(kvp("$lt", 30)))))))); + auto cursor = db["inventory"].find(make_document(kvp( + "$or", + make_array(make_document(kvp("status", "A")), make_document(kvp("qty", make_document(kvp("$lt", 30)))))))); // End Example 12 if (std::distance(cursor.begin(), cursor.end()) != 3) { @@ -434,11 +408,11 @@ void query_top_level_fields_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_array; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find(make_document( - kvp("status", "A"), - kvp("$or", - make_array(make_document(kvp("qty", make_document(kvp("$lt", 30)))), - make_document(kvp("item", bsoncxx::types::b_regex{"^p"})))))); + auto cursor = db["inventory"].find( + make_document(kvp("status", "A"), + kvp("$or", + make_array(make_document(kvp("qty", make_document(kvp("$lt", 30)))), + make_document(kvp("item", bsoncxx::types::b_regex{"^p"})))))); // End Example 13 if (std::distance(cursor.begin(), cursor.end()) != 2) { @@ -468,16 +442,14 @@ void query_embedded_documents_examples(mongocxx::database db) { kvp("qty", 100), kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), kvp("status", "D")), - make_document( - kvp("item", "planner"), - kvp("qty", 75), - kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), - kvp("status", "D")), - make_document( - kvp("item", "postcard"), - kvp("qty", 45), - kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), - kvp("status", "A")), + make_document(kvp("item", "planner"), + kvp("qty", 75), + kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), + kvp("status", "D")), + make_document(kvp("item", "postcard"), + kvp("qty", 45), + kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), + kvp("status", "A")), }; db["inventory"].insert_many(docs); @@ -493,8 +465,8 @@ void query_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find(make_document( - kvp("size", make_document(kvp("h", 14), kvp("w", 21), kvp("uom", "cm"))))); + auto cursor = db["inventory"].find( + make_document(kvp("size", make_document(kvp("h", 14), kvp("w", 21), kvp("uom", "cm"))))); // End Example 15 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -507,8 +479,8 @@ void query_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find(make_document( - kvp("size", make_document(kvp("w", 21), kvp("h", 14), kvp("uom", "cm"))))); + auto cursor = db["inventory"].find( + make_document(kvp("size", make_document(kvp("w", 21), kvp("h", 14), kvp("uom", "cm"))))); // End Example 16 if (std::distance(cursor.begin(), cursor.end()) != 0) { @@ -534,8 +506,7 @@ void query_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("size.h", make_document(kvp("$lt", 15))))); + auto cursor = db["inventory"].find(make_document(kvp("size.h", make_document(kvp("$lt", 15))))); // End Example 18 if (std::distance(cursor.begin(), cursor.end()) != 4) { @@ -548,10 +519,8 @@ void query_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("size.h", make_document(kvp("$lt", 15))), - kvp("size.uom", "in"), - kvp("status", "D"))); + auto cursor = db["inventory"].find( + make_document(kvp("size.h", make_document(kvp("$lt", 15))), kvp("size.uom", "in"), kvp("status", "D"))); // End Example 19 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -620,8 +589,8 @@ void query_arrays_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_array; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("tags", make_document(kvp("$all", make_array("red", "blank")))))); + auto cursor = + db["inventory"].find(make_document(kvp("tags", make_document(kvp("$all", make_array("red", "blank")))))); // End Example 22 if (std::distance(cursor.begin(), cursor.end()) != 4) { @@ -647,8 +616,7 @@ void query_arrays_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("dim_cm", make_document(kvp("$gt", 25))))); + auto cursor = db["inventory"].find(make_document(kvp("dim_cm", make_document(kvp("$gt", 25))))); // End Example 24 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -661,8 +629,7 @@ void query_arrays_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("dim_cm", make_document(kvp("$gt", 15), kvp("$lt", 20))))); + auto cursor = db["inventory"].find(make_document(kvp("dim_cm", make_document(kvp("$gt", 15), kvp("$lt", 20))))); // End Example 25 if (std::distance(cursor.begin(), cursor.end()) != 4) { @@ -676,8 +643,7 @@ void query_arrays_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; auto cursor = db["inventory"].find(make_document( - kvp("dim_cm", - make_document(kvp("$elemMatch", make_document(kvp("$gt", 22), kvp("$lt", 30))))))); + kvp("dim_cm", make_document(kvp("$elemMatch", make_document(kvp("$gt", 22), kvp("$lt", 30))))))); // End Example 26 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -690,8 +656,7 @@ void query_arrays_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("dim_cm.1", make_document(kvp("$gt", 25))))); + auto cursor = db["inventory"].find(make_document(kvp("dim_cm.1", make_document(kvp("$gt", 25))))); // End Example 27 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -704,8 +669,7 @@ void query_arrays_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("tags", make_document(kvp("$size", 3))))); + auto cursor = db["inventory"].find(make_document(kvp("tags", make_document(kvp("$size", 3))))); // End Example 28 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -728,9 +692,8 @@ void query_array_embedded_documents_examples(mongocxx::database db) { kvp("instock", make_array(make_document(kvp("warehouse", "A"), kvp("qty", 5)), make_document(kvp("warehouse", "C"), kvp("qty", 15))))), - make_document( - kvp("item", "notebook"), - kvp("instock", make_array(make_document(kvp("warehouse", "C"), kvp("qty", 5))))), + make_document(kvp("item", "notebook"), + kvp("instock", make_array(make_document(kvp("warehouse", "C"), kvp("qty", 5))))), make_document(kvp("item", "paper"), kvp("instock", make_array(make_document(kvp("warehouse", "A"), kvp("qty", 60)), @@ -758,8 +721,8 @@ void query_array_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("instock", make_document(kvp("warehouse", "A"), kvp("qty", 5))))); + auto cursor = + db["inventory"].find(make_document(kvp("instock", make_document(kvp("warehouse", "A"), kvp("qty", 5))))); // End Example 30 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -772,8 +735,8 @@ void query_array_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("instock", make_document(kvp("qty", 5), kvp("warehouse", "A"))))); + auto cursor = + db["inventory"].find(make_document(kvp("instock", make_document(kvp("qty", 5), kvp("warehouse", "A"))))); // End Example 31 if (std::distance(cursor.begin(), cursor.end()) != 0) { @@ -786,8 +749,7 @@ void query_array_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("instock.0.qty", make_document(kvp("$lte", 20))))); + auto cursor = db["inventory"].find(make_document(kvp("instock.0.qty", make_document(kvp("$lte", 20))))); // End Example 32 if (std::distance(cursor.begin(), cursor.end()) != 3) { @@ -800,8 +762,7 @@ void query_array_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("instock.qty", make_document(kvp("$lte", 20))))); + auto cursor = db["inventory"].find(make_document(kvp("instock.qty", make_document(kvp("$lte", 20))))); // End Example 33 if (std::distance(cursor.begin(), cursor.end()) != 5) { @@ -815,9 +776,7 @@ void query_array_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; auto cursor = db["inventory"].find(make_document( - kvp("instock", - make_document( - kvp("$elemMatch", make_document(kvp("qty", 5), kvp("warehouse", "A"))))))); + kvp("instock", make_document(kvp("$elemMatch", make_document(kvp("qty", 5), kvp("warehouse", "A"))))))); // End Example 34 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -832,9 +791,8 @@ void query_array_embedded_documents_examples(mongocxx::database db) { auto cursor = db["inventory"].find(make_document( kvp("instock", - make_document(kvp( - "$elemMatch", - make_document(kvp("qty", make_document(kvp("$gt", 10), kvp("$lte", 20))))))))); + make_document( + kvp("$elemMatch", make_document(kvp("qty", make_document(kvp("$gt", 10), kvp("$lte", 20))))))))); // End Example 35 if (std::distance(cursor.begin(), cursor.end()) != 3) { @@ -847,8 +805,8 @@ void query_array_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("instock.qty", make_document(kvp("$gt", 10), kvp("$lte", 20))))); + auto cursor = + db["inventory"].find(make_document(kvp("instock.qty", make_document(kvp("$gt", 10), kvp("$lte", 20))))); // End Example 36 if (std::distance(cursor.begin(), cursor.end()) != 4) { @@ -861,8 +819,7 @@ void query_array_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("instock.qty", 5), kvp("instock.warehouse", "A"))); + auto cursor = db["inventory"].find(make_document(kvp("instock.qty", 5), kvp("instock.warehouse", "A"))); // End Example 37 if (std::distance(cursor.begin(), cursor.end()) != 2) { @@ -910,8 +867,7 @@ void query_null_missing_fields_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("item", make_document(kvp("$type", 10))))); + auto cursor = db["inventory"].find(make_document(kvp("item", make_document(kvp("$type", 10))))); // End Example 40 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -924,8 +880,7 @@ void query_null_missing_fields_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("item", make_document(kvp("$exists", false))))); + auto cursor = db["inventory"].find(make_document(kvp("item", make_document(kvp("$exists", false))))); // End Example 41 if (std::distance(cursor.begin(), cursor.end()) != 1) { @@ -944,33 +899,28 @@ void projection_insertion_example(mongocxx::database db) { using bsoncxx::builder::basic::make_document; std::vector docs{ - make_document( - kvp("item", "journal"), - kvp("status", "A"), - kvp("size", make_document(kvp("h", 14), kvp("w", 21), kvp("uom", "cm"))), - kvp("instock", make_array(make_document(kvp("warehouse", "A"), kvp("qty", 5))))), - make_document( - kvp("item", "notebook"), - kvp("status", "A"), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("instock", make_array(make_document(kvp("warehouse", "C"), kvp("qty", 5))))), - make_document( - kvp("item", "paper"), - kvp("status", "D"), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("instock", make_array(make_document(kvp("warehouse", "A"), kvp("qty", 60))))), - make_document( - kvp("item", "planner"), - kvp("status", "D"), - kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), - kvp("instock", make_array(make_document(kvp("warehouse", "A"), kvp("qty", 40))))), - make_document( - kvp("item", "postcard"), - kvp("status", "A"), - kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), - kvp("instock", - make_array(make_document(kvp("warehouse", "B"), kvp("qty", 15)), - make_document(kvp("warehouse", "C"), kvp("qty", 35))))), + make_document(kvp("item", "journal"), + kvp("status", "A"), + kvp("size", make_document(kvp("h", 14), kvp("w", 21), kvp("uom", "cm"))), + kvp("instock", make_array(make_document(kvp("warehouse", "A"), kvp("qty", 5))))), + make_document(kvp("item", "notebook"), + kvp("status", "A"), + kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), + kvp("instock", make_array(make_document(kvp("warehouse", "C"), kvp("qty", 5))))), + make_document(kvp("item", "paper"), + kvp("status", "D"), + kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), + kvp("instock", make_array(make_document(kvp("warehouse", "A"), kvp("qty", 60))))), + make_document(kvp("item", "planner"), + kvp("status", "D"), + kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), + kvp("instock", make_array(make_document(kvp("warehouse", "A"), kvp("qty", 40))))), + make_document(kvp("item", "postcard"), + kvp("status", "A"), + kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), + kvp("instock", + make_array(make_document(kvp("warehouse", "B"), kvp("qty", 15)), + make_document(kvp("warehouse", "C"), kvp("qty", 35))))), }; db["inventory"].insert_many(docs); @@ -1003,9 +953,9 @@ void projection_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("status", "A")), - mongocxx::options::find{}.projection(make_document(kvp("item", 1), kvp("status", 1)))); + auto cursor = + db["inventory"].find(make_document(kvp("status", "A")), + mongocxx::options::find{}.projection(make_document(kvp("item", 1), kvp("status", 1)))); // End Example 44 for (auto&& document : cursor) { @@ -1022,9 +972,9 @@ void projection_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find(make_document(kvp("status", "A")), - mongocxx::options::find{}.projection(make_document( - kvp("item", 1), kvp("status", 1), kvp("_id", 0)))); + auto cursor = db["inventory"].find( + make_document(kvp("status", "A")), + mongocxx::options::find{}.projection(make_document(kvp("item", 1), kvp("status", 1), kvp("_id", 0)))); // End Example 45 for (auto&& document : cursor) { @@ -1041,9 +991,9 @@ void projection_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find(make_document(kvp("status", "A")), - mongocxx::options::find{}.projection( - make_document(kvp("status", 0), kvp("instock", 0)))); + auto cursor = db["inventory"].find( + make_document(kvp("status", "A")), + mongocxx::options::find{}.projection(make_document(kvp("status", 0), kvp("instock", 0)))); // End Example 46 for (auto&& document : cursor) { @@ -1060,10 +1010,9 @@ void projection_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("status", "A")), - mongocxx::options::find{}.projection(make_document( - kvp("item", 1), kvp("status", 1), kvp("size.uom", 1)))); + auto cursor = db["inventory"].find( + make_document(kvp("status", "A")), + mongocxx::options::find{}.projection(make_document(kvp("item", 1), kvp("status", 1), kvp("size.uom", 1)))); // End Example 47 for (auto&& document : cursor) { @@ -1086,9 +1035,8 @@ void projection_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find( - make_document(kvp("status", "A")), - mongocxx::options::find{}.projection(make_document(kvp("size.uom", 0)))); + auto cursor = db["inventory"].find(make_document(kvp("status", "A")), + mongocxx::options::find{}.projection(make_document(kvp("size.uom", 0)))); // End Example 48 for (auto&& document : cursor) { @@ -1111,10 +1059,9 @@ void projection_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = - db["inventory"].find(make_document(kvp("status", "A")), - mongocxx::options::find{}.projection(make_document( - kvp("item", 1), kvp("status", 1), kvp("instock.qty", 1)))); + auto cursor = db["inventory"].find(make_document(kvp("status", "A")), + mongocxx::options::find{}.projection( + make_document(kvp("item", 1), kvp("status", 1), kvp("instock.qty", 1)))); // End Example 49 for (auto&& document : cursor) { @@ -1138,11 +1085,10 @@ void projection_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - auto cursor = db["inventory"].find(make_document(kvp("status", "A")), - mongocxx::options::find{}.projection(make_document( - kvp("item", 1), - kvp("status", 1), - kvp("instock", make_document(kvp("$slice", -1)))))); + auto cursor = db["inventory"].find( + make_document(kvp("status", "A")), + mongocxx::options::find{}.projection( + make_document(kvp("item", 1), kvp("status", 1), kvp("instock", make_document(kvp("$slice", -1)))))); // End Example 50 for (auto&& document : cursor) { @@ -1185,24 +1131,18 @@ void projection_with_aggregation_example(mongocxx::database db) { make_document( kvp("branches", make_array( - make_document( - kvp("case", - make_document(kvp("$eq", make_array("$status", "A")))), - kvp("then", "Available")), - make_document( - kvp("case", - make_document(kvp("$eq", make_array("$status", "D")))), - kvp("then", "Discontinued")))), + make_document(kvp("case", make_document(kvp("$eq", make_array("$status", "A")))), + kvp("then", "Available")), + make_document(kvp("case", make_document(kvp("$eq", make_array("$status", "D")))), + kvp("then", "Discontinued")))), kvp("default", "No status found"))))), kvp("area", make_document(kvp( "$concat", - make_array( - make_document(kvp( - "$toString", - make_document(kvp("$multiply", make_array("$size.h", "$size.w"))))), - " ", - "$size.uom")))), + make_array(make_document(kvp( + "$toString", make_document(kvp("$multiply", make_array("$size.h", "$size.w"))))), + " ", + "$size.uom")))), kvp("reportNumber", make_document(kvp("$literal", 1)))))); // End Aggregation Projection Example 1 @@ -1227,25 +1167,22 @@ void update_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; std::vector docs{ - make_document( - kvp("item", "canvas"), - kvp("qty", 100), - kvp("size", make_document(kvp("h", 28), kvp("w", 35.5), kvp("uom", "cm"))), - kvp("status", "A")), + make_document(kvp("item", "canvas"), + kvp("qty", 100), + kvp("size", make_document(kvp("h", 28), kvp("w", 35.5), kvp("uom", "cm"))), + kvp("status", "A")), make_document(kvp("item", "journal"), kvp("qty", 25), kvp("size", make_document(kvp("h", 14), kvp("w", 21), kvp("uom", "cm"))), kvp("status", "A")), - make_document( - kvp("item", "mat"), - kvp("qty", 85), - kvp("size", make_document(kvp("h", 27.9), kvp("w", 35.5), kvp("uom", "cm"))), - kvp("status", "A")), - make_document( - kvp("item", "mousepad"), - kvp("qty", 25), - kvp("size", make_document(kvp("h", 19), kvp("w", 22.85), kvp("uom", "cm"))), - kvp("status", "P")), + make_document(kvp("item", "mat"), + kvp("qty", 85), + kvp("size", make_document(kvp("h", 27.9), kvp("w", 35.5), kvp("uom", "cm"))), + kvp("status", "A")), + make_document(kvp("item", "mousepad"), + kvp("qty", 25), + kvp("size", make_document(kvp("h", 19), kvp("w", 22.85), kvp("uom", "cm"))), + kvp("status", "P")), make_document(kvp("item", "notebook"), kvp("qty", 50), kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), @@ -1254,25 +1191,22 @@ void update_examples(mongocxx::database db) { kvp("qty", 100), kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), kvp("status", "D")), - make_document( - kvp("item", "planner"), - kvp("qty", 75), - kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), - kvp("status", "D")), - make_document( - kvp("item", "postcard"), - kvp("qty", 45), - kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), - kvp("status", "A")), + make_document(kvp("item", "planner"), + kvp("qty", 75), + kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), + kvp("status", "D")), + make_document(kvp("item", "postcard"), + kvp("qty", 45), + kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), + kvp("status", "A")), make_document(kvp("item", "sketchbook"), kvp("qty", 80), kvp("size", make_document(kvp("h", 14), kvp("w", 21), kvp("uom", "cm"))), kvp("status", "A")), - make_document( - kvp("item", "sketch pad"), - kvp("qty", 95), - kvp("size", make_document(kvp("h", 22.85), kvp("w", 30.5), kvp("uom", "cm"))), - kvp("status", "A")), + make_document(kvp("item", "sketch pad"), + kvp("qty", 95), + kvp("size", make_document(kvp("h", 22.85), kvp("w", 30.5), kvp("uom", "cm"))), + kvp("status", "A")), }; db["inventory"].insert_many(docs); @@ -1288,15 +1222,13 @@ void update_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - db["inventory"].update_one( - make_document(kvp("item", "paper")), - make_document(kvp("$set", make_document(kvp("size.uom", "cm"), kvp("status", "P"))), - kvp("$currentDate", make_document(kvp("lastModified", true))))); + db["inventory"].update_one(make_document(kvp("item", "paper")), + make_document(kvp("$set", make_document(kvp("size.uom", "cm"), kvp("status", "P"))), + kvp("$currentDate", make_document(kvp("lastModified", true))))); // End Example 52 for (auto&& document : db["inventory"].find(make_document(kvp("item", "paper")))) { - if (document["size"].get_document().value["uom"].get_string().value != - bsoncxx::stdx::string_view{"cm"}) { + if (document["size"].get_document().value["uom"].get_string().value != bsoncxx::stdx::string_view{"cm"}) { throw std::logic_error("error in example 52"); } if (document["status"].get_string().value != bsoncxx::stdx::string_view{"P"}) { @@ -1311,16 +1243,13 @@ void update_examples(mongocxx::database db) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - db["inventory"].update_many( - make_document(kvp("qty", make_document((kvp("$lt", 50))))), - make_document(kvp("$set", make_document(kvp("size.uom", "in"), kvp("status", "P"))), - kvp("$currentDate", make_document(kvp("lastModified", true))))); + db["inventory"].update_many(make_document(kvp("qty", make_document((kvp("$lt", 50))))), + make_document(kvp("$set", make_document(kvp("size.uom", "in"), kvp("status", "P"))), + kvp("$currentDate", make_document(kvp("lastModified", true))))); // End Example 53 - for (auto&& document : - db["inventory"].find(make_document(kvp("qty", make_document(kvp("$lt", 50)))))) { - if (document["size"].get_document().value["uom"].get_string().value != - bsoncxx::stdx::string_view{"in"}) { + for (auto&& document : db["inventory"].find(make_document(kvp("qty", make_document(kvp("$lt", 50)))))) { + if (document["size"].get_document().value["uom"].get_string().value != bsoncxx::stdx::string_view{"in"}) { throw std::logic_error("error in example 53"); } if (document["status"].get_string().value != bsoncxx::stdx::string_view{"P"}) { @@ -1382,16 +1311,14 @@ void delete_examples(mongocxx::database db) { kvp("qty", 100), kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), kvp("status", "D")), - make_document( - kvp("item", "planner"), - kvp("qty", 75), - kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), - kvp("status", "D")), - make_document( - kvp("item", "postcard"), - kvp("qty", 45), - kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), - kvp("status", "A")), + make_document(kvp("item", "planner"), + kvp("qty", 75), + kvp("size", make_document(kvp("h", 22.85), kvp("w", 30), kvp("uom", "cm"))), + kvp("status", "D")), + make_document(kvp("item", "postcard"), + kvp("qty", 45), + kvp("size", make_document(kvp("h", 10), kvp("w", 15.25), kvp("uom", "cm"))), + kvp("status", "A")), }; db["inventory"].insert_many(docs); @@ -1462,8 +1389,7 @@ static bool is_snapshot_ready(mongocxx::client& client, mongocxx::collection& co // Seed the pets database and wait for the snapshot to become available. // This follows the pattern from the Python driver as seen below: // https://github.com/mongodb/mongo-python-driver/commit/e325b24b78e431cb889c5902d00b8f4af2c700c3#diff-c5d782e261f04fca18024ab18c3ed38fb45ede24cde4f9092e012f6fcbbe0df5R1368 -static void wait_for_snapshot_ready(mongocxx::client& client, - std::vector collections) { +static void wait_for_snapshot_ready(mongocxx::client& client, std::vector collections) { size_t sleep_time = 1; for (;;) { @@ -1536,9 +1462,8 @@ static void snapshot_example1(mongocxx::client& client) { // End Snapshot Query Example 1 if (adoptable_pets_count != 2) { - throw std::logic_error( - "wrong number of adoptable pets in Snapshot Query Example 1, expecting 2 got: " + - std::to_string(adoptable_pets_count)); + throw std::logic_error("wrong number of adoptable pets in Snapshot Query Example 1, expecting 2 got: " + + std::to_string(adoptable_pets_count)); } } @@ -1551,8 +1476,7 @@ static void setup_retail(mongocxx::client& client) { auto db = client["retail"]; db.drop(); b_date sales_date{system_clock::now()}; - db["sales"].insert_one( - make_document(kvp("shoeType", "boot"), kvp("price", 30), kvp("saleDate", sales_date))); + db["sales"].insert_one(make_document(kvp("shoeType", "boot"), kvp("price", 30), kvp("saleDate", sales_date))); wait_for_snapshot_ready(client, {db["sales"]}); } @@ -1573,12 +1497,12 @@ static void snapshot_example2(mongocxx::client& client) { pipeline p; - p.match(make_document(kvp("$expr", - make_document(kvp("$gt", - make_array("$saleDate", - make_document(kvp("startDate", "$$NOW"), - kvp("unit", "day"), - kvp("amount", 1)))))))) + p.match(make_document( + kvp("$expr", + make_document(kvp( + "$gt", + make_array("$saleDate", + make_document(kvp("startDate", "$$NOW"), kvp("unit", "day"), kvp("amount", 1)))))))) .count("totalDailySales"); auto cursor = db["sales"].aggregate(session, p); @@ -1626,13 +1550,12 @@ static void queryable_encryption_api(mongocxx::client& client) { "docsExamples.encrypted", make_document(kvp( "fields", - make_array(make_document(kvp("path", "encryptedIndexed"), - kvp("bsonType", "string"), - kvp("keyId", key1_id), - kvp("queries", make_document(kvp("queryType", "equality")))), - make_document(kvp("path", "encryptedUnindexed"), - kvp("bsonType", "string"), - kvp("keyId", key2_id))))))); + make_array( + make_document(kvp("path", "encryptedIndexed"), + kvp("bsonType", "string"), + kvp("keyId", key1_id), + kvp("queries", make_document(kvp("queryType", "equality")))), + make_document(kvp("path", "encryptedUnindexed"), kvp("bsonType", "string"), kvp("keyId", key2_id))))))); // Create an Queryable Encryption collection. options::auto_encryption auto_encrypt_opts{}; @@ -1643,8 +1566,7 @@ static void queryable_encryption_api(mongocxx::client& client) { // Optional, If mongocryptd is not in PATH, then find the binary at MONGOCRYPTD_PATH. char* mongocryptd_path = std::getenv("MONGOCRYPTD_PATH"); if (mongocryptd_path) { - auto_encrypt_opts.extra_options( - make_document(kvp("mongocryptdSpawnPath", mongocryptd_path))); + auto_encrypt_opts.extra_options(make_document(kvp("mongocryptdSpawnPath", mongocryptd_path))); } mongocxx::options::client encrypted_client_opts; @@ -1661,13 +1583,11 @@ static void queryable_encryption_api(mongocxx::client& client) { // Auto encrypt an insert and find. { // Encrypt an insert. - encrypted_collection.insert_one(make_document(kvp("_id", 1), - kvp("encryptedIndexed", "indexedValue"), - kvp("encryptedUnindexed", "unindexedValue"))); + encrypted_collection.insert_one(make_document( + kvp("_id", 1), kvp("encryptedIndexed", "indexedValue"), kvp("encryptedUnindexed", "unindexedValue"))); // Encrypt a find. - auto res = - encrypted_collection.find_one(make_document(kvp("encryptedIndexed", "indexedValue"))); + auto res = encrypted_collection.find_one(make_document(kvp("encryptedIndexed", "indexedValue"))); auto doc = res.value(); @@ -1726,8 +1646,7 @@ int EXAMPLES_CDECL main() { snapshot_example1(conn); snapshot_example2(conn); } - if (should_run_client_side_encryption_test() && is_replica_set(conn) && - version_at_least(db, 7, 0, 0)) { + if (should_run_client_side_encryption_test() && is_replica_set(conn) && version_at_least(db, 7, 0, 0)) { queryable_encryption_api(conn); } } catch (const std::logic_error& e) { diff --git a/examples/mongocxx/mongodb.com/index_examples.cpp b/examples/mongocxx/mongodb.com/index_examples.cpp index ecbf1b2b2c..bb18f8175a 100644 --- a/examples/mongocxx/mongodb.com/index_examples.cpp +++ b/examples/mongocxx/mongodb.com/index_examples.cpp @@ -35,8 +35,7 @@ void index_examples(const mongocxx::database& db) { using namespace bsoncxx::builder::basic; auto result = db["restaurants"].create_index( make_document(kvp("cuisine", 1), kvp("name", 1)), - make_document(kvp("partialFilterExpression", - make_document(kvp("rating", make_document(kvp("$gt", 5))))))); + make_document(kvp("partialFilterExpression", make_document(kvp("rating", make_document(kvp("$gt", 5))))))); // End Index Example 2 } } diff --git a/examples/mongocxx/mongodb.com/usage_overview.cpp b/examples/mongocxx/mongodb.com/usage_overview.cpp index 62652973bb..064a709740 100644 --- a/examples/mongocxx/mongodb.com/usage_overview.cpp +++ b/examples/mongocxx/mongodb.com/usage_overview.cpp @@ -50,30 +50,26 @@ int EXAMPLES_CDECL main() { bsoncxx::builder::basic::document doc2; doc2.append(kvp("name", "Blue Bagels Grill"), kvp("stars", 3), - kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { - arr.append("Bagels", "Cookies", "Sandwiches"); - })); + kvp("categories", + [](bsoncxx::builder::basic::sub_array arr) { arr.append("Bagels", "Cookies", "Sandwiches"); })); bsoncxx::builder::basic::document doc3; - doc3.append(kvp("name", "Hot Bakery Cafe"), - kvp("stars", 4), - kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { - arr.append("Bakery", "Cafe", "Coffee", "Dessert"); - })); + doc3.append( + kvp("name", "Hot Bakery Cafe"), kvp("stars", 4), kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { + arr.append("Bakery", "Cafe", "Coffee", "Dessert"); + })); bsoncxx::builder::basic::document doc4; - doc4.append(kvp("name", "XYZ Coffee Bar"), - kvp("stars", 5), - kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { - arr.append("Bakery", "Coffee", "Cafe", "Bakery", "Chocolates"); - })); + doc4.append( + kvp("name", "XYZ Coffee Bar"), kvp("stars", 5), kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { + arr.append("Bakery", "Coffee", "Cafe", "Bakery", "Chocolates"); + })); bsoncxx::builder::basic::document doc5; - doc5.append(kvp("name", "456 Cookies Shop"), - kvp("stars", 4), - kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { - arr.append("Bakery", "Cookies", "Cake", "Coffee"); - })); + doc5.append( + kvp("name", "456 Cookies Shop"), kvp("stars", 4), kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { + arr.append("Bakery", "Cookies", "Cake", "Coffee"); + })); std::vector documents = { doc1.extract(), doc2.extract(), doc3.extract(), doc4.extract(), doc5.extract()}; @@ -100,8 +96,7 @@ int EXAMPLES_CDECL main() { using bsoncxx::builder::basic::sub_document; match_stage.append(kvp("categories", "Bakery")); - group_stage.append(kvp("_id", "$stars"), - kvp("count", [](sub_document sub) { sub.append(kvp("$sum", 1)); })); + group_stage.append(kvp("_id", "$stars"), kvp("count", [](sub_document sub) { sub.append(kvp("$sum", 1)); })); stages.match(match_stage.view()).group(group_stage.view()); diff --git a/examples/mongocxx/pool.cpp b/examples/mongocxx/pool.cpp index 1d6274630d..95b5739247 100644 --- a/examples/mongocxx/pool.cpp +++ b/examples/mongocxx/pool.cpp @@ -54,8 +54,7 @@ int EXAMPLES_CDECL main() { bsoncxx::types::b_int64 index = {j}; coll.insert_one(bsoncxx::builder::basic::make_document(kvp("x", index))); - if (auto doc = - client["test"][collection_names[static_cast(j)]].find_one({})) { + if (auto doc = client["test"][collection_names[static_cast(j)]].find_one({})) { // In order to ensure that the newline is printed immediately after the document, // they need to be streamed to std::cout as a single string. std::stringstream ss; diff --git a/examples/mongocxx/query.cpp b/examples/mongocxx/query.cpp index b5af07a8bc..2035e3baa6 100644 --- a/examples/mongocxx/query.cpp +++ b/examples/mongocxx/query.cpp @@ -74,8 +74,7 @@ int EXAMPLES_CDECL main() { // Query with the greater-than operator ($gt). { - auto cursor = db["restaurants"].find( - make_document(kvp("grade.score", make_document(kvp("$gt", 30))))); + auto cursor = db["restaurants"].find(make_document(kvp("grade.score", make_document(kvp("$gt", 30))))); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) << std::endl; } @@ -83,8 +82,7 @@ int EXAMPLES_CDECL main() { // Query with the less-than operator ($lt). { - auto cursor = db["restaurants"].find( - make_document(kvp("grades.score", make_document(kvp("$lt", 10))))); + auto cursor = db["restaurants"].find(make_document(kvp("grades.score", make_document(kvp("$lt", 10))))); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) << std::endl; } @@ -92,8 +90,7 @@ int EXAMPLES_CDECL main() { // Query with a logical conjunction (AND) of query conditions. { - auto cursor = db["restaurants"].find( - make_document(kvp("cuisine", "Italian"), kvp("address.zipcode", "10075"))); + auto cursor = db["restaurants"].find(make_document(kvp("cuisine", "Italian"), kvp("address.zipcode", "10075"))); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) << std::endl; } @@ -101,10 +98,9 @@ int EXAMPLES_CDECL main() { // Query with a logical disjunction (OR) of query conditions. { - auto cursor = db["restaurants"].find( - make_document(kvp("$or", - make_array(make_document(kvp("cuisine", "Italian")), - make_document(kvp("address.zipcode", "10075")))))); + auto cursor = db["restaurants"].find(make_document( + kvp("$or", + make_array(make_document(kvp("cuisine", "Italian")), make_document(kvp("address.zipcode", "10075")))))); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) << std::endl; } diff --git a/examples/mongocxx/query_projection.cpp b/examples/mongocxx/query_projection.cpp index 28c5f24859..743d485530 100644 --- a/examples/mongocxx/query_projection.cpp +++ b/examples/mongocxx/query_projection.cpp @@ -39,8 +39,7 @@ int EXAMPLES_CDECL main() { coll.drop(); // Insert a test document - auto result = - coll.insert_one(make_document(kvp("user info", make_document(kvp("user name", "Joe"))))); + auto result = coll.insert_one(make_document(kvp("user info", make_document(kvp("user name", "Joe"))))); std::cout << "Inserted " << result->inserted_id().get_oid().value.to_string() << std::endl; // Create the find options with the projection diff --git a/examples/mongocxx/server_side_field_level_encryption_enforcement.cpp b/examples/mongocxx/server_side_field_level_encryption_enforcement.cpp index bad946247d..5c266947d5 100644 --- a/examples/mongocxx/server_side_field_level_encryption_enforcement.cpp +++ b/examples/mongocxx/server_side_field_level_encryption_enforcement.cpp @@ -56,14 +56,11 @@ int EXAMPLES_CDECL main() { // This must be the same master key that was used to create // the encryption key; here, we use a random key as a placeholder. std::uint8_t key_storage[kKeyLength]; - std::generate_n(key_storage, kKeyLength, []() { - return static_cast(std::rand() % UINT8_MAX); - }); - bsoncxx::types::b_binary local_master_key{ - bsoncxx::binary_sub_type::k_binary, kKeyLength, key_storage}; + std::generate_n(key_storage, kKeyLength, []() { return static_cast(std::rand() % UINT8_MAX); }); + bsoncxx::types::b_binary local_master_key{bsoncxx::binary_sub_type::k_binary, kKeyLength, key_storage}; - auto kms_providers = document{} << "local" << open_document << "key" << local_master_key - << close_document << finalize; + auto kms_providers = document{} << "local" << open_document << "key" << local_master_key << close_document + << finalize; class client key_vault_client{uri{}}; auto key_vault = key_vault_client["keyvault"]["datakeys"]; @@ -74,8 +71,7 @@ int EXAMPLES_CDECL main() { mongocxx::options::index index_options{}; index_options.unique(true); - auto expression = document{} << "keyAltNames" << open_document << "$exists" << true - << close_document << finalize; + auto expression = document{} << "keyAltNames" << open_document << "$exists" << true << close_document << finalize; index_options.partial_filter_expression(expression.view()); key_vault.create_index(make_document(kvp("keyAltNames", 1)), index_options); @@ -91,13 +87,12 @@ int EXAMPLES_CDECL main() { auto data_key_id = client_encryption.create_data_key("local"); // Create a new json schema for the encryptedField. - auto json_schema = document{} << "properties" << open_document << "encryptedField" - << open_document << "encrypt" << open_document << "keyId" - << open_array << data_key_id << close_array << "bsonType" + auto json_schema = document{} << "properties" << open_document << "encryptedField" << open_document << "encrypt" + << open_document << "keyId" << open_array << data_key_id << close_array << "bsonType" << "string" << "algorithm" - << "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" << close_document - << close_document << close_document << "bsonType" + << "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" << close_document << close_document + << close_document << "bsonType" << "object" << finalize; // Set up auto encryption opts. @@ -121,8 +116,8 @@ int EXAMPLES_CDECL main() { // Create the collection with the encryption JSON Schema. auto cmd = document{} << "create" << "coll" - << "validator" << open_document << "$jsonSchema" << json_schema.view() - << close_document << finalize; + << "validator" << open_document << "$jsonSchema" << json_schema.view() << close_document + << finalize; db.run_command(cmd.view()); auto coll = db["coll"]; diff --git a/examples/mongocxx/tutorial.cpp b/examples/mongocxx/tutorial.cpp index 2158dd7a8a..d89fec4c3e 100644 --- a/examples/mongocxx/tutorial.cpp +++ b/examples/mongocxx/tutorial.cpp @@ -43,12 +43,11 @@ int EXAMPLES_CDECL main() { // Create a Document { - auto doc_value = make_document( - kvp("name", "MongoDB"), - kvp("type", "database"), - kvp("count", 1), - kvp("versions", make_array("v6.0", "v5.0", "v4.4", "v4.2", "v4.0", "v3.6")), - kvp("info", make_document(kvp("x", 203), kvp("y", 102)))); + auto doc_value = make_document(kvp("name", "MongoDB"), + kvp("type", "database"), + kvp("count", 1), + kvp("versions", make_array("v6.0", "v5.0", "v4.4", "v4.2", "v4.0", "v3.6")), + kvp("info", make_document(kvp("x", 203), kvp("y", 102)))); auto doc_view = doc_value.view(); auto element = doc_view["name"]; @@ -100,8 +99,7 @@ int EXAMPLES_CDECL main() { // Print All Documents in a Collection { auto cursor_all = collection.find({}); - std::cout << "collection " << collection.name() - << " contains these documents:" << std::endl; + std::cout << "collection " << collection.name() << " contains these documents:" << std::endl; for (auto doc : cursor_all) { std::cout << bsoncxx::to_json(doc, bsoncxx::ExtendedJsonMode::k_relaxed) << std::endl; } @@ -118,8 +116,7 @@ int EXAMPLES_CDECL main() { // Get All Documents That Match a Filter { - auto cursor_filtered = - collection.find(make_document(kvp("i", make_document(kvp("$gt", 0), kvp("$lte", 2))))); + auto cursor_filtered = collection.find(make_document(kvp("i", make_document(kvp("$gt", 0), kvp("$lte", 2))))); for (auto doc : cursor_filtered) { // Do something with doc assert(doc["_id"].type() == bsoncxx::type::k_oid); @@ -128,18 +125,16 @@ int EXAMPLES_CDECL main() { // Update a Single Document { - auto update_one_result = - collection.update_one(make_document(kvp("i", 0)), - make_document(kvp("$set", make_document(kvp("foo", "bar"))))); + auto update_one_result = collection.update_one(make_document(kvp("i", 0)), + make_document(kvp("$set", make_document(kvp("foo", "bar"))))); assert(update_one_result); // Acknowledged writes return results. assert(update_one_result->modified_count() == 1); } // Update Multiple Documents { - auto update_many_result = - collection.update_many(make_document(kvp("i", make_document(kvp("$gt", 0)))), - make_document(kvp("$set", make_document(kvp("foo", "buzz"))))); + auto update_many_result = collection.update_many(make_document(kvp("i", make_document(kvp("$gt", 0)))), + make_document(kvp("$set", make_document(kvp("foo", "buzz"))))); assert(update_many_result); // Acknowledged writes return results. assert(update_many_result->modified_count() == 2); } @@ -153,8 +148,7 @@ int EXAMPLES_CDECL main() { // Delete All Documents That Match a Filter { - auto delete_many_result = - collection.delete_many(make_document(kvp("i", make_document(kvp("$gt", 0))))); + auto delete_many_result = collection.delete_many(make_document(kvp("i", make_document(kvp("$gt", 0))))); assert(delete_many_result); // Acknowledged writes return results. assert(delete_many_result->deleted_count() == 2); } diff --git a/examples/mongocxx/update.cpp b/examples/mongocxx/update.cpp index 210b88646d..4212010876 100644 --- a/examples/mongocxx/update.cpp +++ b/examples/mongocxx/update.cpp @@ -37,10 +37,9 @@ int EXAMPLES_CDECL main() { // Update top-level fields in a single document. { - db["restaurants"].update_one( - make_document(kvp("name", "Juni")), - make_document(kvp("$set", make_document(kvp("cuisine", "American (New)"))), - kvp("$currentDate", make_document(kvp("lastModified", true))))); + db["restaurants"].update_one(make_document(kvp("name", "Juni")), + make_document(kvp("$set", make_document(kvp("cuisine", "American (New)"))), + kvp("$currentDate", make_document(kvp("lastModified", true))))); } // Update an embedded document in a single document. @@ -60,13 +59,12 @@ int EXAMPLES_CDECL main() { // Replace the contents of a single document. { - db["restaurants"].replace_one( - make_document(kvp("restaurant_id", "41704620")), - make_document(kvp("name", "Vella 2"), - kvp("address", - make_document(kvp("coord", make_array(-73.9557413, 40.7720266)), - kvp("building", "1480"), - kvp("street", "2 Avenue"), - kvp("zipcode", "10075"))))); + db["restaurants"].replace_one(make_document(kvp("restaurant_id", "41704620")), + make_document(kvp("name", "Vella 2"), + kvp("address", + make_document(kvp("coord", make_array(-73.9557413, 40.7720266)), + kvp("building", "1480"), + kvp("street", "2 Avenue"), + kvp("zipcode", "10075"))))); } } diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp index 589e80c98f..1c1ec251ed 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp @@ -79,10 +79,7 @@ class element : private document::element { private: friend ::bsoncxx::v_noabi::array::view; - explicit element(const std::uint8_t* raw, - std::uint32_t length, - std::uint32_t offset, - std::uint32_t keylen); + explicit element(const std::uint8_t* raw, std::uint32_t length, std::uint32_t offset, std::uint32_t keylen); explicit element(const stdx::string_view key); }; diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/impl.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/impl.hpp index 4064d1f4d7..03fe90642e 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/impl.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/impl.hpp @@ -27,8 +27,7 @@ namespace basic { namespace impl { template -detail::requires_t> generic_append(core* core, - T&& func) { +detail::requires_t> generic_append(core* core, T&& func) { core->open_document(); detail::invoke(std::forward(func), sub_document(core)); core->close_document(); @@ -42,10 +41,8 @@ detail::requires_t> generic_append(core } template -detail::requires_not_t, - detail::is_invocable> -generic_append(core* core, T&& t) { +detail::requires_not_t, detail::is_invocable> generic_append( + core* core, T&& t) { core->append(std::forward(t)); } diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core.hpp index c4c5b4b22f..a061ec0265 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core.hpp @@ -515,8 +515,7 @@ class core { /// template core& append(T* v) { - static_assert(detail::is_alike::value, - "append is disabled for non-char pointer types"); + static_assert(detail::is_alike::value, "append is disabled for non-char pointer types"); append(types::b_string{v}); return *this; diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp index 86da01b12c..cb4984d765 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp @@ -138,8 +138,7 @@ class list { _core.append(ele.val); val = types::bson_value::value(_core.extract_array()); } else { - throw bsoncxx::v_noabi::exception{error_code::k_unmatched_key_in_builder, - err_msg.str()}; + throw bsoncxx::v_noabi::exception{error_code::k_unmatched_key_in_builder, err_msg.str()}; } } }; diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context.hpp index 2da75156ed..2d9bcd5bd9 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context.hpp @@ -84,9 +84,9 @@ class array_context { /// The callback to invoke /// template - detail::requires_t, - detail::is_invocable>> + detail::requires_t< + array_context&, + detail::disjunction, detail::is_invocable>> operator<<(Func&& func) { detail::invoke(std::forward(func), *this); return *this; diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context.hpp index 76f7de1ead..6d7cb11928 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context.hpp @@ -113,9 +113,8 @@ class value_context { #if !defined(_MSC_VER) && !defined(__INTEL_COMPILER) // TODO(MSVC): Causes an ICE under VS2015U1 - static_assert( - std::is_same() << 1 << "str")>::value, - "value_context must be templatized on a key_context"); + static_assert(std::is_same() << 1 << "str")>::value, + "value_context must be templatized on a key_context"); #endif private: diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/util.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/util.hpp index 239dc09405..37e8e7a9f0 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/util.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/config/util.hpp @@ -92,18 +92,14 @@ BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(pop))) \ BSONCXX_FORCE_SEMICOLON -#define _bsoncxxDisableWarningImpl_for_GCC(...) \ - BSONCXX_IF_GCC(BSONCXX_PRAGMA(GCC diagnostic ignored __VA_ARGS__)) +#define _bsoncxxDisableWarningImpl_for_GCC(...) BSONCXX_IF_GCC(BSONCXX_PRAGMA(GCC diagnostic ignored __VA_ARGS__)) -#define _bsoncxxDisableWarningImpl_for_Clang(...) \ - BSONCXX_IF_CLANG(BSONCXX_PRAGMA(GCC diagnostic ignored __VA_ARGS__)) +#define _bsoncxxDisableWarningImpl_for_Clang(...) BSONCXX_IF_CLANG(BSONCXX_PRAGMA(GCC diagnostic ignored __VA_ARGS__)) -#define _bsoncxxDisableWarningImpl_for_GNU(...) \ - _bsoncxxDisableWarningImpl_for_GCC(__VA_ARGS__) \ - _bsoncxxDisableWarningImpl_for_Clang(__VA_ARGS__) +#define _bsoncxxDisableWarningImpl_for_GNU(...) \ + _bsoncxxDisableWarningImpl_for_GCC(__VA_ARGS__) _bsoncxxDisableWarningImpl_for_Clang(__VA_ARGS__) -#define _bsoncxxDisableWarningImpl_for_MSVC(...) \ - BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(disable : __VA_ARGS__))) +#define _bsoncxxDisableWarningImpl_for_MSVC(...) BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(disable : __VA_ARGS__))) #define BSONCXX_FWD(...) static_cast(__VA_ARGS__) diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp index eb5e00e16e..2b80e13d44 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp @@ -355,10 +355,7 @@ class element { /// @param offset /// The element's offset into the buffer. /// - explicit element(const std::uint8_t* raw, - std::uint32_t length, - std::uint32_t offset, - std::uint32_t keylen); + explicit element(const std::uint8_t* raw, std::uint32_t length, std::uint32_t offset, std::uint32_t keylen); // Construct an invalid element with a key. Useful for exceptions. explicit element(const stdx::string_view key); diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp index 162f388b26..a5f2cddb0f 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp @@ -108,12 +108,10 @@ using ::bsoncxx::v_noabi::operator"" _bson; namespace bsoncxx { /// @ref bsoncxx::v_noabi::to_json(v_noabi::document::view view, v_noabi::ExtendedJsonMode mode) -std::string to_json(v_noabi::document::view view, - v_noabi::ExtendedJsonMode mode = ExtendedJsonMode::k_legacy); +std::string to_json(v_noabi::document::view view, v_noabi::ExtendedJsonMode mode = ExtendedJsonMode::k_legacy); /// @ref bsoncxx::v_noabi::to_json(v_noabi::array::view view, v_noabi::ExtendedJsonMode mode) -std::string to_json(v_noabi::array::view view, - v_noabi::ExtendedJsonMode mode = ExtendedJsonMode::k_legacy); +std::string to_json(v_noabi::array::view view, v_noabi::ExtendedJsonMode mode = ExtendedJsonMode::k_legacy); /// @ref bsoncxx::v_noabi::from_json(v_noabi::stdx::string_view json) v_noabi::document::value from_json(v_noabi::stdx::string_view json); diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/operators.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/operators.hpp index 3d5aa2262e..ca06858a6d 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/operators.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/operators.hpp @@ -47,8 +47,7 @@ struct is_equality_comparable : decltype(is_equality_comparable_f(0)) {}; // Callable object and tag type for equality comparison. struct equal_to { template - constexpr requires_t> operator()(L&& l, R&& r) const - noexcept(noexcept(l == r)) { + constexpr requires_t> operator()(L&& l, R&& r) const noexcept(noexcept(l == r)) { return l == r; } }; @@ -123,14 +122,10 @@ class strong_ordering { BSONCXX_IF_GNU_LIKE([[gnu::weak]]) \ BSONCXX_IF_MSVC(__declspec(selectany)) -INLINE_VAR const strong_ordering strong_ordering::less = - strong_ordering(strong_ordering::_construct{}, -1); -INLINE_VAR const strong_ordering strong_ordering::greater = - strong_ordering(strong_ordering::_construct{}, 1); -INLINE_VAR const strong_ordering strong_ordering::equivalent = - strong_ordering(strong_ordering::_construct{}, 0); -INLINE_VAR const strong_ordering strong_ordering::equal = - strong_ordering(strong_ordering::_construct{}, 0); +INLINE_VAR const strong_ordering strong_ordering::less = strong_ordering(strong_ordering::_construct{}, -1); +INLINE_VAR const strong_ordering strong_ordering::greater = strong_ordering(strong_ordering::_construct{}, 1); +INLINE_VAR const strong_ordering strong_ordering::equivalent = strong_ordering(strong_ordering::_construct{}, 0); +INLINE_VAR const strong_ordering strong_ordering::equal = strong_ordering(strong_ordering::_construct{}, 0); #pragma pop_macro("INLINE_VAR") @@ -145,30 +140,26 @@ struct compare_three_way { typename = decltype(std::declval() < std::declval()), typename = decltype(std::declval() == std::declval())> constexpr static strong_ordering impl(const L& l, const R& r, rank<1>) { - return (l < r) ? strong_ordering::less - : (l == r ? strong_ordering::equal : strong_ordering::greater); + return (l < r) ? strong_ordering::less : (l == r ? strong_ordering::equal : strong_ordering::greater); } BSONCXX_POP_WARNINGS(); template (), std::declval(), std::declval()))> + typename = decltype(tag_invoke(std::declval(), std::declval(), std::declval()))> constexpr static strong_ordering impl(const L& l, const R& r, rank<2>) { return tag_invoke(compare_three_way{}, l, r); } template - constexpr auto operator()(const L& l, const R& r) const - BSONCXX_RETURNS((impl)(l, r, rank<2>{})); + constexpr auto operator()(const L& l, const R& r) const BSONCXX_RETURNS((impl)(l, r, rank<2>{})); }; // Inherit to define ADL-visible ordering operators based on an ADL-visible // implementation of tag_invoke(compare_three_way, l, r). struct ordering_operators { template - constexpr static auto impl(const L& l, const R& r, rank<1>) - BSONCXX_RETURNS(tag_invoke(compare_three_way{}, l, r)); + constexpr static auto impl(const L& l, const R& r, rank<1>) BSONCXX_RETURNS(tag_invoke(compare_three_way{}, l, r)); template constexpr static auto impl(const L& l, const R& r, rank<0>) @@ -191,22 +182,20 @@ template std::false_type is_partially_ordered_with_f(rank<0>); template -auto is_partially_ordered_with_f(rank<1>) - -> true_t() > std::declval()), - decltype(std::declval() < std::declval()), - decltype(std::declval() >= std::declval()), - decltype(std::declval() <= std::declval()), - decltype(std::declval() < std::declval()), - decltype(std::declval() > std::declval()), - decltype(std::declval() <= std::declval()), - decltype(std::declval() >= std::declval())>; +auto is_partially_ordered_with_f(rank<1>) -> true_t() > std::declval()), + decltype(std::declval() < std::declval()), + decltype(std::declval() >= std::declval()), + decltype(std::declval() <= std::declval()), + decltype(std::declval() < std::declval()), + decltype(std::declval() > std::declval()), + decltype(std::declval() <= std::declval()), + decltype(std::declval() >= std::declval())>; template struct is_partially_ordered_with : decltype(is_partially_ordered_with_f(rank<1>{})) {}; template -struct is_totally_ordered - : conjunction, is_partially_ordered_with> {}; +struct is_totally_ordered : conjunction, is_partially_ordered_with> {}; template struct is_totally_ordered_with : conjunction, diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp index 3d6515f7eb..f079da03af 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp @@ -116,16 +116,16 @@ template struct enable_opt_conversion : bsoncxx::detail::conjunction< std::is_constructible, - bsoncxx::detail::disjunction, - bsoncxx::detail::negation&>, - std::is_constructible&>, - std::is_constructible&&>, - std::is_constructible&&>, - std::is_convertible&, T>, - std::is_convertible&, T>, - std::is_convertible&&, T>, - std::is_convertible&&, T>>>>> {}; + bsoncxx::detail::disjunction< + std::is_same, + bsoncxx::detail::negation&>, + std::is_constructible&>, + std::is_constructible&&>, + std::is_constructible&&>, + std::is_convertible&, T>, + std::is_convertible&, T>, + std::is_convertible&&, T>, + std::is_convertible&&, T>>>>> {}; template struct enable_opt_value_conversion // @@ -133,9 +133,8 @@ struct enable_opt_value_conversion // std::is_constructible, bsoncxx::detail::negation>, bsoncxx::detail::negation>>, - bsoncxx::detail::disjunction< - bsoncxx::detail::negation>, - detail::not_an_optional>>> {}; + bsoncxx::detail::disjunction>, + detail::not_an_optional>>> {}; } // namespace detail @@ -146,11 +145,9 @@ class optional : bsoncxx::detail::equality_operators, public: using value_type = T; using reference = bsoncxx::detail::add_lvalue_reference_t; - using const_reference = - bsoncxx::detail::add_lvalue_reference_t>; + using const_reference = bsoncxx::detail::add_lvalue_reference_t>; using rvalue_reference = bsoncxx::detail::add_rvalue_reference_t; - using const_rvalue_reference = - bsoncxx::detail::add_rvalue_reference_t>; + using const_rvalue_reference = bsoncxx::detail::add_rvalue_reference_t>; using pointer = bsoncxx::detail::add_pointer_t; using const_pointer = bsoncxx::detail::add_pointer_t; @@ -173,44 +170,38 @@ class optional : bsoncxx::detail::equality_operators, // In-place constructors template - bsoncxx_cxx14_constexpr explicit optional(in_place_t, Args&&... args) noexcept( - noexcept(T(BSONCXX_FWD(args)...))) { + bsoncxx_cxx14_constexpr explicit optional(in_place_t, Args&&... args) noexcept(noexcept(T(BSONCXX_FWD(args)...))) { this->emplace(BSONCXX_FWD(args)...); } template - bsoncxx_cxx14_constexpr explicit optional( - in_place_t, - std::initializer_list il, - Args&&... args) noexcept(noexcept(T(il, BSONCXX_FWD(args)...))) { + bsoncxx_cxx14_constexpr explicit optional(in_place_t, + std::initializer_list il, + Args&&... args) noexcept(noexcept(T(il, BSONCXX_FWD(args)...))) { this->emplace(il, BSONCXX_FWD(args)...); } // Explicit converting constructor. Only available if implicit conversion is // not possible. - template < - typename U = T, - bsoncxx::detail::requires_t, - bsoncxx::detail::negation>> = 0> - bsoncxx_cxx14_constexpr explicit optional(U&& arg) noexcept( - std::is_nothrow_constructible::value) + template , + bsoncxx::detail::negation>> = 0> + bsoncxx_cxx14_constexpr explicit optional(U&& arg) noexcept(std::is_nothrow_constructible::value) : optional(in_place, BSONCXX_FWD(arg)) {} // Implicit converting constructor. Only available if implicit conversion is // possible. - template , - std::is_convertible> = 0> + template < + typename U = T, + bsoncxx::detail::requires_t, std::is_convertible> = 0> bsoncxx_cxx14_constexpr optional(U&& arg) noexcept(std::is_nothrow_constructible::value) : optional(in_place, BSONCXX_FWD(arg)) {} template , - bsoncxx::detail::negation>> = 0> + bsoncxx::detail::requires_t, + bsoncxx::detail::negation>> = 0> bsoncxx_cxx14_constexpr explicit optional(const optional& other) noexcept( std::is_nothrow_constructible>::value) { if (other.has_value()) { @@ -229,11 +220,10 @@ class optional : bsoncxx::detail::equality_operators, } } - template < - typename U, - bsoncxx::detail::requires_t, - bsoncxx::detail::negation>> = 0> + template , + bsoncxx::detail::negation>> = 0> bsoncxx_cxx14_constexpr explicit optional(optional&& other) noexcept( std::is_nothrow_constructible>::value) { if (other.has_value()) { @@ -241,10 +231,9 @@ class optional : bsoncxx::detail::equality_operators, } } - template , - std::is_convertible> = 0> + template < + typename U, + bsoncxx::detail::requires_t, std::is_convertible> = 0> bsoncxx_cxx14_constexpr optional(optional&& other) noexcept( std::is_nothrow_constructible>::value) { if (other.has_value()) { @@ -364,8 +353,7 @@ bsoncxx_cxx14_constexpr optional make_optional(Args&&... args) noexcept( // Emplace-construct a new optional of the given type with the given arguments (accepts an init-list // as the first argument). template -bsoncxx_cxx14_constexpr optional -make_optional(std::initializer_list il, Args&&... args) noexcept( +bsoncxx_cxx14_constexpr optional make_optional(std::initializer_list il, Args&&... args) noexcept( std::is_nothrow_constructible, Args&&...>::value) { return optional(in_place, il, BSONCXX_FWD(args)...); } @@ -542,12 +530,8 @@ struct optional_operators_base { } template - friend constexpr auto tag_invoke(bsoncxx::detail::equal_to, - const optional& left, - const U& right) noexcept - -> bsoncxx::detail::requires_t, - bsoncxx::detail::is_equality_comparable> { + friend constexpr auto tag_invoke(bsoncxx::detail::equal_to, const optional& left, const U& right) noexcept + -> bsoncxx::detail::requires_t, bsoncxx::detail::is_equality_comparable> { BSONCXX_PUSH_WARNINGS(); BSONCXX_DISABLE_WARNING(GNU("-Wfloat-equal")); return left.has_value() && *left == right; @@ -555,9 +539,7 @@ struct optional_operators_base { } template - friend constexpr bool tag_invoke(bsoncxx::detail::equal_to, - const optional& opt, - nullopt_t) noexcept { + friend constexpr bool tag_invoke(bsoncxx::detail::equal_to, const optional& opt, nullopt_t) noexcept { return !opt.has_value(); } @@ -600,8 +582,9 @@ struct optional_operators_base { } template - constexpr friend bsoncxx::detail::strong_ordering tag_invoke( - bsoncxx::detail::compare_three_way compare, const optional& left, nullopt_t) { + constexpr friend bsoncxx::detail::strong_ordering tag_invoke(bsoncxx::detail::compare_three_way compare, + const optional& left, + nullopt_t) { return compare(left.has_value(), false); } }; @@ -613,8 +596,7 @@ struct optional_swap_mixin {}; template struct optional_swap_mixin { bsoncxx_cxx14_constexpr friend void swap(optional& left, optional& right) noexcept( - std::is_nothrow_move_constructible::value && - bsoncxx::detail::is_nothrow_swappable::value) { + std::is_nothrow_move_constructible::value && bsoncxx::detail::is_nothrow_swappable::value) { left.swap(right); } }; @@ -628,15 +610,13 @@ class optional_common_base : optional_operators_base, optional_swap_mixin { optional_common_base() = default; ~optional_common_base() = default; - optional_common_base(const optional_common_base& other) noexcept( - std::is_nothrow_copy_constructible::value) { + optional_common_base(const optional_common_base& other) noexcept(std::is_nothrow_copy_constructible::value) { if (other._has_value) { this->emplace(other._storage.value); } } - optional_common_base(optional_common_base&& other) noexcept( - std::is_nothrow_move_constructible::value) { + optional_common_base(optional_common_base&& other) noexcept(std::is_nothrow_move_constructible::value) { if (other._has_value) { this->_emplace_construct_anew(std::move(other)._storage.value); } @@ -648,8 +628,7 @@ class optional_common_base : optional_operators_base, optional_swap_mixin { return *this; } - optional_common_base& operator=(optional_common_base&& other) noexcept( - std::is_nothrow_move_assignable::value) { + optional_common_base& operator=(optional_common_base&& other) noexcept(std::is_nothrow_move_assignable::value) { this->_assign(BSONCXX_FWD(other)); return *this; } @@ -682,8 +661,7 @@ class optional_common_base : optional_operators_base, optional_swap_mixin { // Special swap for optional values that removes need for a temporary. bsoncxx_cxx14_constexpr void swap(optional_common_base& other) noexcept( - std::is_nothrow_move_constructible::value && - bsoncxx::detail::is_nothrow_swappable::value) { + std::is_nothrow_move_constructible::value && bsoncxx::detail::is_nothrow_swappable::value) { if (other._has_value) { if (this->_has_value) { using std::swap; @@ -710,8 +688,7 @@ class optional_common_base : optional_operators_base, optional_swap_mixin { // In-place construct a new value from the given arguments. Assumes that the optional does not // have a live value. template - void _emplace_construct_anew(Args&&... args) noexcept( - std::is_nothrow_constructible::value) { + void _emplace_construct_anew(Args&&... args) noexcept(std::is_nothrow_constructible::value) { new (std::addressof(this->_storage.value)) T(BSONCXX_FWD(args)...); this->_has_value = true; } @@ -741,8 +718,7 @@ struct optional_base_class { }; template >>::value> + bool CanHash = std::is_default_constructible>>::value> struct optional_hash; // Hash is "disabled" if the underlying type is not hashable (disabled = cannot construct the hash @@ -773,8 +749,7 @@ struct optional_hash { namespace std { template -struct hash> - : bsoncxx::v_noabi::stdx::detail::optional_hash {}; +struct hash> : bsoncxx::v_noabi::stdx::detail::optional_hash {}; } // namespace std diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp index 62bcb3b2a9..77728427d2 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp @@ -77,16 +77,14 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: constexpr basic_string_view() noexcept = default; constexpr basic_string_view(const basic_string_view&) noexcept = default; - bsoncxx_cxx14_constexpr basic_string_view& operator=(const basic_string_view&) noexcept = - default; + bsoncxx_cxx14_constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default; constexpr basic_string_view(const_pointer s, size_type count) : _begin(s), _size(count) {} constexpr basic_string_view(const_pointer s) : _begin(s), _size(traits_type::length(s)) {} template - constexpr basic_string_view( - const std::basic_string& str) noexcept + constexpr basic_string_view(const std::basic_string& str) noexcept : _begin(str.data()), _size(str.size()) {} #if defined(__cpp_lib_string_view) @@ -187,8 +185,7 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: return count; } - bsoncxx_cxx14_constexpr basic_string_view substr(size_type pos = 0, - size_type count = npos) const { + bsoncxx_cxx14_constexpr basic_string_view substr(size_type pos = 0, size_type count = npos) const { if (pos > size()) { throw std::out_of_range{"bsoncxx::stdx::basic_string_view::substr()"}; } @@ -197,8 +194,7 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: constexpr int compare(basic_string_view other) const noexcept { // Another level of indirection to support restricted C++11 constexpr. - return _compare2(Traits::compare(data(), other.data(), (std::min)(size(), other.size())), - other); + return _compare2(Traits::compare(data(), other.data(), (std::min)(size(), other.size())), other); } constexpr int compare(const_pointer cstr) const { @@ -213,23 +209,16 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: return compare(pos1, count1, basic_string_view(cstr)); } - constexpr int compare(size_type pos1, - size_type count1, - basic_string_view other, - size_type pos2, - size_type count2) const { + constexpr int compare( + size_type pos1, size_type count1, basic_string_view other, size_type pos2, size_type count2) const { return substr(pos1, count1).compare(other.substr(pos2, count2)); } - constexpr int compare(size_type pos1, - size_type count1, - const_pointer str, - size_type count2) const { + constexpr int compare(size_type pos1, size_type count1, const_pointer str, size_type count2) const { return substr(pos1, count1).compare(basic_string_view(str, count2)); } - bsoncxx_cxx14_constexpr size_type find(basic_string_view infix, - size_type pos = 0) const noexcept { + bsoncxx_cxx14_constexpr size_type find(basic_string_view infix, size_type pos = 0) const noexcept { if (pos > size()) { return npos; } @@ -245,8 +234,7 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: return static_cast(found - begin()); } - bsoncxx_cxx14_constexpr size_type rfind(basic_string_view infix, - size_type pos = npos) const noexcept { + bsoncxx_cxx14_constexpr size_type rfind(basic_string_view infix, size_type pos = npos) const noexcept { // Calc the endpos where searching should begin, which includes the infix size. const size_type substr_size = pos != npos ? pos + infix.size() : pos; if (infix.empty()) { @@ -272,8 +260,7 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: return _find_if(pos, [&](value_type chr) { return set.find(chr) == npos; }); } - constexpr size_type find_last_not_of(basic_string_view set, - size_type pos = npos) const noexcept { + constexpr size_type find_last_not_of(basic_string_view set, size_type pos = npos) const noexcept { return _rfind_if(pos, [&](value_type chr) { return set.find(chr) == npos; }); } @@ -326,15 +313,13 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: } // Implementation of a three-way-comparison. - constexpr friend bsoncxx::detail::strong_ordering tag_invoke( - bsoncxx::detail::compare_three_way cmp, - basic_string_view left, - basic_string_view right) noexcept { + constexpr friend bsoncxx::detail::strong_ordering tag_invoke(bsoncxx::detail::compare_three_way cmp, + basic_string_view left, + basic_string_view right) noexcept { return cmp(left.compare(right), 0); } - friend std::basic_ostream& operator<<(std::basic_ostream& out, - basic_string_view self) { + friend std::basic_ostream& operator<<(std::basic_ostream& out, basic_string_view self) { out << std::basic_string(self); return out; } @@ -384,8 +369,7 @@ namespace std { template struct hash> : private std::hash> { - std::size_t operator()( - const bsoncxx::v_noabi::stdx::basic_string_view& str) const { + std::size_t operator()(const bsoncxx::v_noabi::stdx::basic_string_view& str) const { return std::hash>::operator()( std::basic_string(str.data(), str.size())); } diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/type_traits.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/type_traits.hpp index fcc1f9b452..bbfe8da197 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/type_traits.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/type_traits.hpp @@ -159,8 +159,7 @@ struct nonesuch { // @tparam Oper A template that evaluates to a type // @tparam Args Some number of arguments to apply to Oper template