diff --git a/.clang-format b/.clang-format index d1f02cd586..7cf63c1ad3 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ --- Language: Cpp AccessModifierOffset: -1 -AlignAfterOpenBracket: Align +AlignAfterOpenBracket: AlwaysBreak AlignArrayOfStructures: None AlignConsecutiveAssignments: Enabled: false @@ -64,7 +64,7 @@ AlignTrailingComments: Kind: Always OverEmptyLines: 0 AllowAllArgumentsOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false AllowBreakBeforeNoexceptSpecifier: Never AllowShortBlocksOnASingleLine: Never AllowShortCaseExpressionOnASingleLine: true @@ -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 @@ -190,7 +190,7 @@ JavaScriptWrapImports: true KeepEmptyLines: AtEndOfFile: false AtStartOfBlock: false - AtStartOfFile: true + AtStartOfFile: false LambdaBodyIndentation: Signature LineEnding: DeriveLF MacroBlockBegin: '' @@ -217,7 +217,7 @@ PenaltyIndentedWhitespace: 0 PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Left PPIndentWidth: -1 -QualifierAlignment: Left +QualifierAlignment: Right RawStringFormats: [] ReferenceAlignment: Pointer ReflowComments: true @@ -227,7 +227,7 @@ RemoveSemicolon: false RequiresClausePosition: OwnLine RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave -ShortNamespaceLines: 1 +ShortNamespaceLines: 0 SkipMacroDefinitionBody: false SortIncludes: CaseSensitive SortJavaStaticImport: Before @@ -257,7 +257,7 @@ SpaceBeforeParensOptions: SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeSquareBrackets: false SpaceInEmptyBlock: false -SpacesBeforeTrailingComments: 2 +SpacesBeforeTrailingComments: 1 SpacesInAngles: Never SpacesInContainerLiterals: true SpacesInLineCommentPrefix: diff --git a/benchmark/benchmark_runner.cpp b/benchmark/benchmark_runner.cpp index a4c1cd7c96..048baebbfd 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")); @@ -86,13 +82,10 @@ benchmark_runner::benchmark_runner(std::set types) : _types{type // Need to remove some if (!_types.empty()) { for (auto&& it = _microbenches.begin(); it != _microbenches.end();) { - const std::set& tags = (*it)->get_tags(); + std::set const& 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 = [](std::chrono::time_point const 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"; @@ -189,10 +178,10 @@ void benchmark_runner::write_scores() { std::cout << "Individual microbenchmark scores:" << std::endl << "===========" << std::endl; for (auto&& bench : _microbenches) { auto& score = bench->get_results(); - const auto bench_time = static_cast(score.get_percentile(50).count()) / 1000.0; + auto const 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())); @@ -232,4 +221,4 @@ void benchmark_runner::write_scores() { std::ofstream os{"results.json"}; os << '[' << bsoncxx::to_json(doc.view()) << ']'; } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/benchmark_runner.hpp b/benchmark/benchmark_runner.hpp index 6df7e1ebfd..ec92d5e552 100644 --- a/benchmark/benchmark_runner.hpp +++ b/benchmark/benchmark_runner.hpp @@ -54,4 +54,4 @@ class benchmark_runner { std::vector> _microbenches; std::set _types; }; -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/bson/bson_decoding.hpp b/benchmark/bson/bson_decoding.hpp index a09dcc09b8..18c1971041 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: @@ -46,4 +44,4 @@ void bson_decoding::task() { // TODO CXX-1241: call bson_as_extended json on _json. } } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/bson/bson_encoding.hpp b/benchmark/bson/bson_encoding.hpp index c11b6c791e..5d0d0d4e1d 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: @@ -64,4 +62,4 @@ void bson_encoding::task() { } void bson_encoding::teardown() {} -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/main.cpp b/benchmark/main.cpp index a45d4c33c8..53120d2400 100644 --- a/benchmark/main.cpp +++ b/benchmark/main.cpp @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) { if (argc > 1) { if (bsoncxx::stdx::string_view(argv[1]) == "all") { - for (const auto& [name, type] : names_types) { + for (auto const& [name, type] : names_types) { types.insert(type); } } else { diff --git a/benchmark/microbench.cpp b/benchmark/microbench.cpp index fc01167a38..1ff5150e68 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(std::chrono::duration const& curr_time, std::uint32_t iter) { return (curr_time > maxtime || (curr_time > mintime && iter > max_iter)); } @@ -44,7 +43,7 @@ void microbench::run() { teardown(); } -std::vector parse_json_file_to_strings(const std::string& json_file) { +std::vector parse_json_file_to_strings(std::string const& json_file) { std::vector jsons; std::ifstream stream{"data/benchmark/" + json_file}; @@ -60,7 +59,7 @@ std::vector parse_json_file_to_strings(const std::string& json_file return jsons; } -std::vector parse_json_file_to_documents(const std::string& json_file) { +std::vector parse_json_file_to_documents(std::string const& json_file) { std::vector docs; std::ifstream stream{"data/benchmark/" + json_file}; @@ -79,12 +78,11 @@ 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(std::vector const& docs) { std::vector bsons; for (std::uint32_t i = 0; i < docs.size(); i++) { bsons.push_back(bsoncxx::to_json(docs[i])); } return bsons; } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/microbench.hpp b/benchmark/microbench.hpp index a03c090bdd..4ac3322021 100644 --- a/benchmark/microbench.hpp +++ b/benchmark/microbench.hpp @@ -37,7 +37,7 @@ enum class benchmark_type { run_command_bench, }; -static const std::unordered_map type_names = { +static std::unordered_map const type_names = { {benchmark_type::bson_bench, "BSONBench"}, {benchmark_type::single_bench, "SingleBench"}, {benchmark_type::multi_bench, "MultiBench"}, @@ -46,7 +46,7 @@ static const std::unordered_map type_names = { {benchmark_type::write_bench, "WriteBench"}, {benchmark_type::run_command_bench, "RunCommandBench"}}; -static const std::unordered_map names_types = { +static std::unordered_map const names_types = { {"BSONBench", benchmark_type::bson_bench}, {"SingleBench", benchmark_type::single_bench}, {"MultiBench", benchmark_type::multi_bench}, @@ -72,8 +72,8 @@ class microbench { microbench(microbench&&) = default; microbench& operator=(microbench&&) = default; - microbench(const microbench&) = default; - microbench& operator=(const microbench&) = default; + microbench(microbench const&) = default; + microbench& operator=(microbench const&) = default; void run(); @@ -85,7 +85,7 @@ class microbench { return _score; } - const std::set& get_tags() { + std::set const& get_tags() { return _tags; } @@ -109,9 +109,9 @@ class microbench { std::string _name; }; -std::vector parse_json_file_to_strings(const std::string& json_file); +std::vector parse_json_file_to_strings(std::string const& json_file); -std::vector parse_json_file_to_documents(const std::string& json_file); +std::vector parse_json_file_to_documents(std::string const& json_file); -std::vector parse_documents_to_bson(const std::vector& docs); -} // namespace benchmark +std::vector parse_documents_to_bson(std::vector const& docs); +} // namespace benchmark diff --git a/benchmark/multi_doc/bulk_insert.hpp b/benchmark/multi_doc/bulk_insert.hpp index 3b450b5105..5872366800 100644 --- a/benchmark/multi_doc/bulk_insert.hpp +++ b/benchmark/multi_doc/bulk_insert.hpp @@ -36,10 +36,7 @@ class bulk_insert : public microbench { bulk_insert() = delete; 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}}, + : microbench{std::move(name), task_size, std::set{benchmark_type::multi_bench, benchmark_type::write_bench}}, _conn{mongocxx::uri{}}, _doc_num{doc_num}, _file_name{std::move(json_file)} {} @@ -85,4 +82,4 @@ void bulk_insert::teardown() { void bulk_insert::task() { _coll.insert_many(_docs); } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/multi_doc/find_many.hpp b/benchmark/multi_doc/find_many.hpp index ac9db9b9a1..e3bbf8157a 100644 --- a/benchmark/multi_doc/find_many.hpp +++ b/benchmark/multi_doc/find_many.hpp @@ -33,10 +33,7 @@ class find_many : public microbench { public: // The task size comes from the Driver Perfomance Benchmarking Reference Doc. find_many(std::string json_file) - : microbench{"TestFindManyAndEmptyCursor", - 16.22, - std::set{benchmark_type::multi_bench, - benchmark_type::read_bench}}, + : microbench{"TestFindManyAndEmptyCursor", 16.22, std::set{benchmark_type::multi_bench, benchmark_type::read_bench}}, _conn{mongocxx::uri{}}, _json_file{std::move(json_file)} {} @@ -74,4 +71,4 @@ void find_many::task() { for ([[maybe_unused]] auto&& doc : cursor) { } } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/multi_doc/gridfs_download.hpp b/benchmark/multi_doc/gridfs_download.hpp index da05aac50a..58c8805b3c 100644 --- a/benchmark/multi_doc/gridfs_download.hpp +++ b/benchmark/multi_doc/gridfs_download.hpp @@ -36,10 +36,7 @@ class gridfs_download : public microbench { public: // The task size comes from the Driver Perfomance Benchmarking Reference Doc. gridfs_download(std::string file_name) - : microbench{"TestGridFsDownload", - 52.43, - std::set{benchmark_type::multi_bench, - benchmark_type::read_bench}}, + : microbench{"TestGridFsDownload", 52.43, std::set{benchmark_type::multi_bench, benchmark_type::read_bench}}, _conn{mongocxx::uri{}}, _file_name{std::move(file_name)} {} @@ -77,8 +74,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 +} // namespace benchmark diff --git a/benchmark/multi_doc/gridfs_upload.hpp b/benchmark/multi_doc/gridfs_upload.hpp index c066b83440..ccf859e89d 100644 --- a/benchmark/multi_doc/gridfs_upload.hpp +++ b/benchmark/multi_doc/gridfs_upload.hpp @@ -34,10 +34,7 @@ class gridfs_upload : public microbench { public: // The task size comes from the Driver Perfomance Benchmarking Reference Doc. gridfs_upload(std::string file_name) - : microbench{"TestGridFsUpload", - 52.43, - std::set{benchmark_type::multi_bench, - benchmark_type::write_bench}}, + : microbench{"TestGridFsUpload", 52.43, std::set{benchmark_type::multi_bench, benchmark_type::write_bench}}, _conn{mongocxx::uri{}}, _file_name{file_name} {} @@ -60,8 +57,8 @@ class gridfs_upload : public microbench { void gridfs_upload::setup() { std::ifstream stream{_file_name}; stream >> std::noskipws; - _gridfs_file = std::vector{(std::istream_iterator{stream}), - (std::istream_iterator{})}; + _gridfs_file = std::vector{ + (std::istream_iterator{stream}), (std::istream_iterator{})}; mongocxx::database db = _conn["perftest"]; db.drop(); @@ -87,4 +84,4 @@ void gridfs_upload::task() { uploader.write(_gridfs_file.data(), _gridfs_file.size()); uploader.close(); } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/parallel/gridfs_multi_export.hpp b/benchmark/parallel/gridfs_multi_export.hpp index 528df3862e..3184c439e2 100644 --- a/benchmark/parallel/gridfs_multi_export.hpp +++ b/benchmark/parallel/gridfs_multi_export.hpp @@ -33,17 +33,13 @@ using bsoncxx::builder::basic::make_document; class gridfs_multi_export : public microbench { public: - static const std::uint32_t TOTAL_FILES{50}; + static std::uint32_t const TOTAL_FILES{50}; 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()) - : microbench{"TestGridFsMultiExport", - 262.144, - std::set{benchmark_type::parallel_bench, - benchmark_type::read_bench}}, + 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}}, _directory{std::move(dir)}, _pool{mongocxx::uri{}}, _thread_num{thread_num} {} @@ -95,8 +91,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 +99,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(); @@ -123,4 +118,4 @@ void gridfs_multi_export::concurrency_task(std::uint32_t start_file, std::uint32 bucket.download_to_stream(_ids[i], &stream); } } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/parallel/gridfs_multi_import.hpp b/benchmark/parallel/gridfs_multi_import.hpp index 187ef2612a..6cdbe12618 100644 --- a/benchmark/parallel/gridfs_multi_import.hpp +++ b/benchmark/parallel/gridfs_multi_import.hpp @@ -35,17 +35,13 @@ using bsoncxx::builder::basic::make_document; class gridfs_multi_import : public microbench { public: - static const std::uint32_t TOTAL_FILES{50}; + static std::uint32_t const TOTAL_FILES{50}; 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) - : microbench{"TestGridFsMultiImport", - 262.144, - std::set{benchmark_type::parallel_bench, - benchmark_type::write_bench}}, + 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}}, _directory{std::move(dir)}, _pool{mongocxx::uri{}}, _thread_num{thread_num} {} @@ -91,8 +87,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 +95,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(); @@ -120,4 +115,4 @@ void gridfs_multi_import::concurrency_task(std::uint32_t start_file, std::uint32 auto uploader = bucket.upload_from_stream(file_name, &stream); } } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/parallel/json_multi_export.hpp b/benchmark/parallel/json_multi_export.hpp index 544203b19f..2ae307c01f 100644 --- a/benchmark/parallel/json_multi_export.hpp +++ b/benchmark/parallel/json_multi_export.hpp @@ -38,18 +38,14 @@ using bsoncxx::builder::basic::make_document; class json_multi_export : public microbench { public: - static const std::uint32_t TOTAL_FILES{100}; - static const std::uint32_t DOCS_PER_FILE{5000}; + static std::uint32_t const TOTAL_FILES{100}; + static std::uint32_t const DOCS_PER_FILE{5000}; 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()) - : microbench{"TestJsonMultiExport", - 565, - std::set{benchmark_type::parallel_bench, - benchmark_type::read_bench}}, + 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}}, _directory{std::move(dir)}, _pool{mongocxx::uri{}}, _thread_num{thread_num} {} @@ -86,9 +82,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 +103,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 +111,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(); @@ -144,4 +138,4 @@ void json_multi_export::concurrency_task(std::uint32_t start_file, std::uint32_t } } } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/parallel/json_multi_import.hpp b/benchmark/parallel/json_multi_import.hpp index bb366bbe83..e1b6d453c4 100644 --- a/benchmark/parallel/json_multi_import.hpp +++ b/benchmark/parallel/json_multi_import.hpp @@ -38,17 +38,13 @@ using bsoncxx::builder::basic::make_document; class json_multi_import : public microbench { public: - static const std::uint32_t TOTAL_FILES{100}; + static std::uint32_t const TOTAL_FILES{100}; 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) - : microbench{"TestJsonMultiImport", - 565, - std::set{benchmark_type::parallel_bench, - benchmark_type::write_bench}}, + 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}}, _directory{std::move(dir)}, _pool{mongocxx::uri{}}, _thread_num{thread_num} {} @@ -87,8 +83,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 +91,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(); @@ -117,4 +112,4 @@ void json_multi_import::concurrency_task(std::uint32_t start_file, std::uint32_t (*client)["perftest"]["corpus"].insert_many(docs, ins_opts); } } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/score_recorder.cpp b/benchmark/score_recorder.cpp index 8013deef6b..49ba5bf93d 100644 --- a/benchmark/score_recorder.cpp +++ b/benchmark/score_recorder.cpp @@ -19,10 +19,9 @@ 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 { +std::chrono::milliseconds const& score_recorder::get_execution_time() const { return _execution_time; } @@ -31,17 +30,15 @@ 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; _execution_time += duration; } -const std::chrono::milliseconds& score_recorder::get_percentile(unsigned long n) { +std::chrono::milliseconds const& score_recorder::get_percentile(unsigned long n) { if (_samples.empty()) { throw std::runtime_error("No samples recorded yet"); } @@ -61,4 +58,4 @@ const std::chrono::milliseconds& score_recorder::get_percentile(unsigned long n) double score_recorder::get_score() { return _task_size / (static_cast(get_percentile(50).count()) * .001); } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/score_recorder.hpp b/benchmark/score_recorder.hpp index 68acb1dec9..cc8c656a70 100644 --- a/benchmark/score_recorder.hpp +++ b/benchmark/score_recorder.hpp @@ -44,7 +44,7 @@ class score_recorder { // @return // The cumulative execution time. // - const std::chrono::milliseconds& get_execution_time() const; + std::chrono::milliseconds const& get_execution_time() const; // // Gets the nth percentile sample runtime. @@ -58,7 +58,7 @@ class score_recorder { // @note // This method should only be called after all samples are completed. // - const std::chrono::milliseconds& get_percentile(unsigned long n); + std::chrono::milliseconds const& get_percentile(unsigned long n); // // Gets the score for this benchmark. @@ -85,4 +85,4 @@ class score_recorder { std::vector _samples; }; -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/single_doc/find_one_by_id.hpp b/benchmark/single_doc/find_one_by_id.hpp index 3a721f6021..763fd94b8c 100644 --- a/benchmark/single_doc/find_one_by_id.hpp +++ b/benchmark/single_doc/find_one_by_id.hpp @@ -33,10 +33,7 @@ class find_one_by_id : public microbench { public: // The task size comes from the Driver Perfomance Benchmarking Reference Doc. find_one_by_id(std::string json_file) - : microbench{"TestFindOneById", - 16.22, - std::set{benchmark_type::single_bench, - benchmark_type::read_bench}}, + : microbench{"TestFindOneById", 16.22, std::set{benchmark_type::single_bench, benchmark_type::read_bench}}, _conn{mongocxx::uri{}}, _json_file{std::move(json_file)} {} @@ -78,4 +75,4 @@ void find_one_by_id::task() { void find_one_by_id::teardown() { _conn["perftest"].drop(); } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/single_doc/insert_one.hpp b/benchmark/single_doc/insert_one.hpp index f343e96492..06154a102d 100644 --- a/benchmark/single_doc/insert_one.hpp +++ b/benchmark/single_doc/insert_one.hpp @@ -34,10 +34,7 @@ class insert_one : public microbench { insert_one() = delete; 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}}, + : microbench{std::move(name), task_size, std::set{benchmark_type::single_bench, benchmark_type::write_bench}}, _conn{mongocxx::uri{}}, _iter{iter}, _file_name{std::move(json_file)} {} @@ -81,4 +78,4 @@ void insert_one::task() { void insert_one::teardown() { _conn["perftest"].drop(); } -} // namespace benchmark +} // namespace benchmark diff --git a/benchmark/single_doc/run_command.hpp b/benchmark/single_doc/run_command.hpp index 97db905dc5..344b6c5eef 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"]; } @@ -51,4 +49,4 @@ void run_command::task() { _db.run_command(command.view()); } } -} // namespace benchmark +} // namespace benchmark diff --git a/cmake/MacroGuardTest.cmake b/cmake/MacroGuardTest.cmake index 5b2c85ccf4..6a39dd9b68 100644 --- a/cmake/MacroGuardTest.cmake +++ b/cmake/MacroGuardTest.cmake @@ -73,7 +73,7 @@ function(add_macro_guard_test) # Implement as recursive algorithm for C++11 compatibility. string(APPEND MACRO_GUARD_TEST_PRELUDE - "static constexpr bool compare_equal(const char* lhs, const char* rhs) {\n" + "static constexpr bool compare_equal(char const* lhs, char const* rhs) {\n" " return (*lhs == *rhs) && (*lhs == '\\0' || compare_equal(lhs + 1, rhs + 1));\n" "}\n" "\n" diff --git a/examples/add_subdirectory/hello_mongocxx.cpp b/examples/add_subdirectory/hello_mongocxx.cpp index e45731245c..de6dffa13b 100644 --- a/examples/add_subdirectory/hello_mongocxx.cpp +++ b/examples/add_subdirectory/hello_mongocxx.cpp @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) { mongocxx::instance inst; try { - const auto uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri}; + auto const uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri}; auto client = mongocxx::client{uri}; auto admin = client["admin"]; @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) { std::cout << bsoncxx::to_json(result) << std::endl; return EXIT_SUCCESS; - } catch (const std::exception& xcp) { + } catch (std::exception const& xcp) { std::cout << "connection failed: " << xcp.what() << std::endl; return EXIT_FAILURE; } 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..483169820b 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), [](bsoncxx::array::element const& e) { + return e.key() == "0" || e.type() == bsoncxx::type::k_string; + }); EXPECT(elements.size() == 2u); EXPECT(elements[0].key() == "0"); @@ -43,7 +42,7 @@ void example(bsoncxx::array::view arr) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::builder::basic::make_array(1, 2.0, "three")); diff --git a/examples/api/bsoncxx/examples/bson_documents/access_array/basic.cpp b/examples/api/bsoncxx/examples/bson_documents/access_array/basic.cpp index 594586c2c7..201f410f14 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_array/basic.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_array/basic.cpp @@ -44,9 +44,9 @@ void example(bsoncxx::array::view arr) { } // [Example] -} // namespace +} // namespace -RUNNER_REGISTER_COMPONENT() { // clang-format off +RUNNER_REGISTER_COMPONENT() { // clang-format off example(bsoncxx::builder::basic::make_array(1, 2.0, "three")); -} // clang-format on +} // clang-format on diff --git a/examples/api/bsoncxx/examples/bson_documents/access_array/find.cpp b/examples/api/bsoncxx/examples/bson_documents/access_array/find.cpp index 6bcaf5fed7..915b30cc65 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_array/find.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_array/find.cpp @@ -38,7 +38,7 @@ void example(bsoncxx::array::view arr) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::builder::basic::make_array(1, 2)); diff --git a/examples/api/bsoncxx/examples/bson_documents/access_array/iterators.cpp b/examples/api/bsoncxx/examples/bson_documents/access_array/iterators.cpp index 88746d2081..052ca2a085 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_array/iterators.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_array/iterators.cpp @@ -54,7 +54,7 @@ void example(bsoncxx::array::view arr) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::builder::basic::make_array(1, 2)); diff --git a/examples/api/bsoncxx/examples/bson_documents/access_array/subscript.cpp b/examples/api/bsoncxx/examples/bson_documents/access_array/subscript.cpp index d1597b42c7..a1d9274673 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_array/subscript.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_array/subscript.cpp @@ -34,11 +34,11 @@ void example(bsoncxx::array::view arr) { EXPECT(e.get_int32().value == 2); } - EXPECT(!arr[2]); // Invalid element. + EXPECT(!arr[2]); // Invalid element. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::builder::basic::make_array(1, 2)); 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..428aa7b04b 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), [](bsoncxx::document::element const& e) { + return e.key() == "a" || e.type() == bsoncxx::type::k_string; + }); EXPECT(elements.size() == 2u); EXPECT(elements[0].key() == "a"); @@ -46,7 +43,7 @@ void example(bsoncxx::document::view doc) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})")); diff --git a/examples/api/bsoncxx/examples/bson_documents/access_doc/basic.cpp b/examples/api/bsoncxx/examples/bson_documents/access_doc/basic.cpp index 4ffe73b165..7ebd492aa9 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_doc/basic.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_doc/basic.cpp @@ -44,7 +44,7 @@ void example(bsoncxx::document::view doc) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})")); diff --git a/examples/api/bsoncxx/examples/bson_documents/access_doc/find.cpp b/examples/api/bsoncxx/examples/bson_documents/access_doc/find.cpp index fb4a594311..68a7527d27 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_doc/find.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_doc/find.cpp @@ -38,7 +38,7 @@ void example(bsoncxx::document::view doc) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::from_json(R"({"a": 1, "b": 2})")); diff --git a/examples/api/bsoncxx/examples/bson_documents/access_doc/iterators.cpp b/examples/api/bsoncxx/examples/bson_documents/access_doc/iterators.cpp index c982533275..b79c80258c 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_doc/iterators.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_doc/iterators.cpp @@ -54,7 +54,7 @@ void example(bsoncxx::document::view doc) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::from_json(R"({"a": 1, "b": 2})")); diff --git a/examples/api/bsoncxx/examples/bson_documents/access_doc/subscript.cpp b/examples/api/bsoncxx/examples/bson_documents/access_doc/subscript.cpp index ffaa0909c1..d9355d6afc 100644 --- a/examples/api/bsoncxx/examples/bson_documents/access_doc/subscript.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/access_doc/subscript.cpp @@ -34,11 +34,11 @@ void example(bsoncxx::document::view doc) { EXPECT(e.get_int32().value == 2); } - EXPECT(!doc["c"]); // Invalid element. + EXPECT(!doc["c"]); // Invalid element. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::from_json(R"({"a": 1, "b": 2})")); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_append.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_append.cpp index d0279de3bd..8943ead31e 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_append.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_append.cpp @@ -35,7 +35,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_basic.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_basic.cpp index 9695ba55ae..76236122e9 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_basic.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_basic.cpp @@ -33,7 +33,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_bson_type.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_bson_type.cpp index d478150376..0a775760db 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_bson_type.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_bson_type.cpp @@ -34,7 +34,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); 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..f1667d982f 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,14 +35,13 @@ 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")); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_concatenate.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_concatenate.cpp index 31129c34f7..09d138abe8 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_concatenate.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_concatenate.cpp @@ -36,7 +36,7 @@ void example(bsoncxx::array::view a, bsoncxx::array::view b) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::builder::basic::make_array(1), bsoncxx::builder::basic::make_array(2)); 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..4718a7373e 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); @@ -36,7 +35,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_raw_value.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_raw_value.cpp index d4d5368d21..12188a4495 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_raw_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_raw_value.cpp @@ -28,7 +28,7 @@ namespace { // [Example] // [1, 2] -void example(const std::uint8_t* data, std::size_t length) { +void example(std::uint8_t const* data, std::size_t length) { using deleter_type = bsoncxx::array::value::deleter_type; std::uint8_t* raw = new std::uint8_t[length]; @@ -41,11 +41,11 @@ void example(const std::uint8_t* data, std::size_t length) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto owner = bsoncxx::builder::basic::make_array(1, 2); - const auto arr = owner.view(); + auto const owner = bsoncxx::builder::basic::make_array(1, 2); + auto const arr = owner.view(); example(arr.data(), arr.length()); } diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_raw_view.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_raw_view.cpp index 62ce5c180c..051feac704 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_raw_view.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_raw_view.cpp @@ -26,18 +26,18 @@ namespace { // [Example] // [1, 2] -void example(const std::uint8_t* data, std::size_t length) { +void example(std::uint8_t const* data, std::size_t length) { bsoncxx::array::view arr{data, length}; EXPECT(arr == bsoncxx::builder::basic::make_array(1, 2)); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto owner = bsoncxx::builder::basic::make_array(1, 2); - const auto arr = owner.view(); + auto const owner = bsoncxx::builder::basic::make_array(1, 2); + auto const arr = owner.view(); example(arr.data(), arr.length()); } diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_reset.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_reset.cpp index c26fbfd215..58226521ce 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_reset.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_reset.cpp @@ -47,7 +47,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_array.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_array.cpp index 6ef6359987..055c6e8648 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_array.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_array.cpp @@ -36,7 +36,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_array_append.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_array_append.cpp index f5a266c849..f8df594989 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_array_append.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_array_append.cpp @@ -40,7 +40,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_document.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_document.cpp index 1919e14918..f1c125283b 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_document.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/builder_sub_document.cpp @@ -39,7 +39,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); 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..f484698d8b 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,19 +33,18 @@ 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})")); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); 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..53953d9a98 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); @@ -40,7 +39,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/json_basic.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/json_basic.cpp index 3ef3d4f9c8..ca0987d837 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/json_basic.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/json_basic.cpp @@ -35,7 +35,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/json_extended.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/json_extended.cpp index cb268eda18..1428e0cf2f 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/json_extended.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/json_extended.cpp @@ -39,7 +39,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/json_sub_array.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/json_sub_array.cpp index 140d5e6c86..bbdfc205df 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/json_sub_array.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/json_sub_array.cpp @@ -36,7 +36,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/json_sub_document.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/json_sub_document.cpp index 25ee21ddb4..ef83249ce9 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/json_sub_document.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/json_sub_document.cpp @@ -35,7 +35,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_array/json_udl.cpp b/examples/api/bsoncxx/examples/bson_documents/create_array/json_udl.cpp index 969ca70634..3c758ce135 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_array/json_udl.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_array/json_udl.cpp @@ -31,7 +31,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_append.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_append.cpp index d5a5f4a893..e0b3c269f8 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_append.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_append.cpp @@ -38,7 +38,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_basic.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_basic.cpp index 1677e7c23e..349e2d64d5 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_basic.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_basic.cpp @@ -36,7 +36,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); 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..f8cc8ba632 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,14 +33,13 @@ 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"})")); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); 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..5ce3956171 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,14 +35,14 @@ 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"})")); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_concatenate.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_concatenate.cpp index a93da9ea4b..b86f2c1054 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_concatenate.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_concatenate.cpp @@ -35,7 +35,7 @@ void example(bsoncxx::document::view a, bsoncxx::document::view b) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::from_json(R"({"a": 1})"), bsoncxx::from_json(R"({"b": 2})")); 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..31da983901 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,14 +28,14 @@ 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"})")); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_raw_value.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_raw_value.cpp index 155b4e14a3..1c963de78d 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_raw_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_raw_value.cpp @@ -27,7 +27,7 @@ namespace { // [Example] // {"key": "value"} -void example(const std::uint8_t* data, std::size_t length) { +void example(std::uint8_t const* data, std::size_t length) { using deleter_type = bsoncxx::document::value::deleter_type; std::uint8_t* raw = new std::uint8_t[length]; @@ -40,7 +40,7 @@ void example(const std::uint8_t* data, std::size_t length) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { bsoncxx::document::value owner = bsoncxx::from_json(R"({"key": "value"})"); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_raw_view.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_raw_view.cpp index 3ada5ee01c..f7e471680c 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_raw_view.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_raw_view.cpp @@ -26,14 +26,14 @@ namespace { // [Example] // {"key": "value"} -void example(const std::uint8_t* data, std::size_t length) { +void example(std::uint8_t const* data, std::size_t length) { bsoncxx::document::view doc{data, length}; EXPECT(doc == bsoncxx::from_json(R"({"key": "value"})")); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { bsoncxx::document::value owner = bsoncxx::from_json(R"({"key": "value"})"); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_reset.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_reset.cpp index 280f21e332..456d30b3fb 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_reset.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_reset.cpp @@ -43,7 +43,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array.cpp index 1d12c4c2dd..1b2cbaf3df 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array.cpp @@ -42,7 +42,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); 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..b6d887d8dd 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]); } @@ -45,7 +45,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document.cpp index eafbbd5d99..0a9f643099 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document.cpp @@ -38,7 +38,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); 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..33fd035e37 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])); } @@ -45,7 +45,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); 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..bbe87664d4 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,14 +28,14 @@ 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"})")); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_basic.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_basic.cpp index 0f11d1f93e..07fab81bb7 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_basic.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_basic.cpp @@ -39,7 +39,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_extended.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_extended.cpp index 3ae281365b..a6214e01e1 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_extended.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_extended.cpp @@ -39,7 +39,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_sub_array.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_sub_array.cpp index d058f950f2..5edadb020c 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_sub_array.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_sub_array.cpp @@ -36,7 +36,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_sub_document.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_sub_document.cpp index caf2b1060d..7dab30e79e 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_sub_document.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_sub_document.cpp @@ -35,7 +35,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_udl.cpp b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_udl.cpp index 1f88bb5c5d..2b5e910653 100644 --- a/examples/api/bsoncxx/examples/bson_documents/create_doc/json_udl.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/create_doc/json_udl.cpp @@ -31,7 +31,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/elements/arr_multi.cpp b/examples/api/bsoncxx/examples/bson_documents/elements/arr_multi.cpp index 61d11154d0..60ce55719e 100644 --- a/examples/api/bsoncxx/examples/bson_documents/elements/arr_multi.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/elements/arr_multi.cpp @@ -59,11 +59,11 @@ void example(bsoncxx::array::element e) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto owner = bsoncxx::builder::basic::make_array(1, 2.0, "three"); - const auto arr = owner.view(); + auto const owner = bsoncxx::builder::basic::make_array(1, 2.0, "three"); + auto const arr = owner.view(); example(arr[0]); example(arr[1]); diff --git a/examples/api/bsoncxx/examples/bson_documents/elements/arr_single.cpp b/examples/api/bsoncxx/examples/bson_documents/elements/arr_single.cpp index 19ee6628e6..b278ac7048 100644 --- a/examples/api/bsoncxx/examples/bson_documents/elements/arr_single.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/elements/arr_single.cpp @@ -37,11 +37,11 @@ void example(bsoncxx::array::element e) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto owner = bsoncxx::builder::basic::make_array(1, 2.0, "three"); - const auto arr = owner.view(); + auto const owner = bsoncxx::builder::basic::make_array(1, 2.0, "three"); + auto const arr = owner.view(); example(arr[0]); example(arr[1]); diff --git a/examples/api/bsoncxx/examples/bson_documents/elements/cmp_bson_value.cpp b/examples/api/bsoncxx/examples/bson_documents/elements/cmp_bson_value.cpp index 81c7bf70a6..a757c66b7d 100644 --- a/examples/api/bsoncxx/examples/bson_documents/elements/cmp_bson_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/elements/cmp_bson_value.cpp @@ -45,10 +45,10 @@ void example(bsoncxx::document::element e) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto doc = bsoncxx::from_json(R"({"a": {"$numberInt": "1"}, "b": {"$numberLong": "2"}})"); + auto const doc = bsoncxx::from_json(R"({"a": {"$numberInt": "1"}, "b": {"$numberLong": "2"}})"); example(doc["a"]); example(doc["b"]); diff --git a/examples/api/bsoncxx/examples/bson_documents/elements/cmp_type.cpp b/examples/api/bsoncxx/examples/bson_documents/elements/cmp_type.cpp index 018ce76f34..d0313e2e3f 100644 --- a/examples/api/bsoncxx/examples/bson_documents/elements/cmp_type.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/elements/cmp_type.cpp @@ -39,10 +39,10 @@ void example(bsoncxx::document::element e) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto doc = bsoncxx::from_json(R"({"a": {"$numberInt": "1"}, "b": {"$numberLong": "2"}})"); + auto const doc = bsoncxx::from_json(R"({"a": {"$numberInt": "1"}, "b": {"$numberLong": "2"}})"); example(doc["a"]); example(doc["b"]); diff --git a/examples/api/bsoncxx/examples/bson_documents/elements/doc_multi.cpp b/examples/api/bsoncxx/examples/bson_documents/elements/doc_multi.cpp index 6e202d2014..d29027f59b 100644 --- a/examples/api/bsoncxx/examples/bson_documents/elements/doc_multi.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/elements/doc_multi.cpp @@ -59,10 +59,10 @@ void example(bsoncxx::document::element e) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto doc = bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})"); + auto const doc = bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})"); example(doc["a"]); example(doc["b"]); diff --git a/examples/api/bsoncxx/examples/bson_documents/elements/doc_single.cpp b/examples/api/bsoncxx/examples/bson_documents/elements/doc_single.cpp index 5bfbdc50b0..c832065ec1 100644 --- a/examples/api/bsoncxx/examples/bson_documents/elements/doc_single.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/elements/doc_single.cpp @@ -37,10 +37,10 @@ void example(bsoncxx::document::element e) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto doc = bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})"); + auto const doc = bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})"); example(doc["a"]); example(doc["b"]); diff --git a/examples/api/bsoncxx/examples/bson_documents/json/array.cpp b/examples/api/bsoncxx/examples/bson_documents/json/array.cpp index 3bc7ee8ef4..56c2208248 100644 --- a/examples/api/bsoncxx/examples/bson_documents/json/array.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/json/array.cpp @@ -30,14 +30,14 @@ namespace { void example() { using bsoncxx::ExtendedJsonMode; - std::uint8_t data[]{"three"}; // Base64: dGhyZWU= - std::uint32_t data_len{5u}; // Exclude null terminator. + std::uint8_t data[]{"three"}; // Base64: dGhyZWU= + 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 } + std::int32_t{1}, // "$numberInt": "1" + std::int64_t{2}, // "$numberLong": "2" + binary // "$binary": { "$base64": "dGhyZWU=", "subType": 00 } ); bsoncxx::array::view arr = owner.view(); @@ -98,7 +98,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/json/document.cpp b/examples/api/bsoncxx/examples/bson_documents/json/document.cpp index 9a3e9a268e..2a46915d3f 100644 --- a/examples/api/bsoncxx/examples/bson_documents/json/document.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/json/document.cpp @@ -32,14 +32,14 @@ void example() { using bsoncxx::ExtendedJsonMode; using bsoncxx::builder::basic::kvp; - std::uint8_t data[]{"three"}; // Base64: dGhyZWU= - auto data_len = static_cast(sizeof(data) - 1u); // Exclude null terminator. + std::uint8_t data[]{"three"}; // Base64: dGhyZWU= + 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 } + 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" } } })"); } { @@ -102,7 +100,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/values/arr_value.cpp b/examples/api/bsoncxx/examples/bson_documents/values/arr_value.cpp index f32227fc21..ea6231301e 100644 --- a/examples/api/bsoncxx/examples/bson_documents/values/arr_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/values/arr_value.cpp @@ -28,20 +28,20 @@ void example() { EXPECT(v.view().type() == bsoncxx::type::k_null); EXPECT(v.view().get_null() == bsoncxx::types::b_null{}); - v = bsoncxx::from_json(R"({"v": ["value"]})") // Temporary object. + v = bsoncxx::from_json(R"({"v": ["value"]})") // Temporary object. ["v"] - .get_owning_value(); // Copy: no dangling. + .get_owning_value(); // Copy: no dangling. EXPECT(v.view().type() == bsoncxx::type::k_array); - v = v.view().get_array().value[0].get_string(); // Copy: no dangling. + v = v.view().get_array().value[0].get_string(); // Copy: no dangling. EXPECT(v.view().type() == bsoncxx::type::k_string); EXPECT(v.view().get_string().value == "value"); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/values/arr_view.cpp b/examples/api/bsoncxx/examples/bson_documents/values/arr_view.cpp index e1dc8284ee..a345e032e4 100644 --- a/examples/api/bsoncxx/examples/bson_documents/values/arr_view.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/values/arr_view.cpp @@ -45,11 +45,11 @@ void example(bsoncxx::array::element e) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto owner = bsoncxx::builder::basic::make_array(1, 2.0, "three"); - const auto arr = owner.view(); + auto const owner = bsoncxx::builder::basic::make_array(1, 2.0, "three"); + auto const arr = owner.view(); example(arr[0]); example(arr[1]); diff --git a/examples/api/bsoncxx/examples/bson_documents/values/bson_type_value.cpp b/examples/api/bsoncxx/examples/bson_documents/values/bson_type_value.cpp index 02cfb1da67..d3b4818baf 100644 --- a/examples/api/bsoncxx/examples/bson_documents/values/bson_type_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/values/bson_type_value.cpp @@ -41,7 +41,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/values/bson_type_view.cpp b/examples/api/bsoncxx/examples/bson_documents/values/bson_type_view.cpp index 6d89c4a866..4e1db2e67a 100644 --- a/examples/api/bsoncxx/examples/bson_documents/values/bson_type_view.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/values/bson_type_view.cpp @@ -46,7 +46,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/values/doc_value.cpp b/examples/api/bsoncxx/examples/bson_documents/values/doc_value.cpp index 8a6a991c68..916d002645 100644 --- a/examples/api/bsoncxx/examples/bson_documents/values/doc_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/values/doc_value.cpp @@ -28,20 +28,20 @@ void example() { EXPECT(v.view().type() == bsoncxx::type::k_null); EXPECT(v.view().get_null() == bsoncxx::types::b_null{}); - v = bsoncxx::from_json(R"({"v": {"key": "value"}})") // Temporary object. + v = bsoncxx::from_json(R"({"v": {"key": "value"}})") // Temporary object. ["v"] - .get_owning_value(); // Copy: no dangling. + .get_owning_value(); // Copy: no dangling. EXPECT(v.view().type() == bsoncxx::type::k_document); - v = v.view().get_document().value["key"].get_string(); // Copy: no dangling. + v = v.view().get_document().value["key"].get_string(); // Copy: no dangling. EXPECT(v.view().type() == bsoncxx::type::k_string); EXPECT(v.view().get_string().value == "value"); } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/values/doc_view.cpp b/examples/api/bsoncxx/examples/bson_documents/values/doc_view.cpp index 42d2bb51a0..8680bc9c70 100644 --- a/examples/api/bsoncxx/examples/bson_documents/values/doc_view.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/values/doc_view.cpp @@ -45,10 +45,10 @@ void example(bsoncxx::document::element e) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto doc = bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})"); + auto const doc = bsoncxx::from_json(R"({"a": 1, "b": 2.0, "c": "three"})"); example(doc["a"]); example(doc["b"]); diff --git a/examples/api/bsoncxx/examples/bson_documents/values/make_value.cpp b/examples/api/bsoncxx/examples/bson_documents/values/make_value.cpp index d2cb4c7f7f..dbd4f7a7a8 100644 --- a/examples/api/bsoncxx/examples/bson_documents/values/make_value.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/values/make_value.cpp @@ -55,7 +55,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_documents/values/value_type.cpp b/examples/api/bsoncxx/examples/bson_documents/values/value_type.cpp index 5b413b3945..eee5960fa5 100644 --- a/examples/api/bsoncxx/examples/bson_documents/values/value_type.cpp +++ b/examples/api/bsoncxx/examples/bson_documents/values/value_type.cpp @@ -46,7 +46,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/access_arr_iter_end.cpp b/examples/api/bsoncxx/examples/bson_errors/access_arr_iter_end.cpp index 0e53d4b530..f14d164d0b 100644 --- a/examples/api/bsoncxx/examples/bson_errors/access_arr_iter_end.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/access_arr_iter_end.cpp @@ -27,25 +27,25 @@ namespace { void example(bsoncxx::array::view arr) { EXPECT(arr.begin() != arr.end()); - auto iter = arr.begin(); // 1 + auto iter = arr.begin(); // 1 - ++iter; // 2 - ++iter; // 3 - ++iter; // End iterator. + ++iter; // 2 + ++iter; // 3 + ++iter; // End iterator. EXPECT(iter == arr.end()); - ++iter; // DO NOT DO THIS + ++iter; // DO NOT DO THIS - EXPECT(iter == arr.end()); // Incrementing an end iterator results in an end iterator. + EXPECT(iter == arr.end()); // Incrementing an end iterator results in an end iterator. - bsoncxx::array::element e = *iter; // DO NOT DO THIS + bsoncxx::array::element e = *iter; // DO NOT DO THIS - EXPECT(!e); // An end iterator returns an invalid element. + EXPECT(!e); // An end iterator returns an invalid element. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::builder::basic::make_array(1, 2, 3)); diff --git a/examples/api/bsoncxx/examples/bson_errors/access_arr_iter_invalid.cpp b/examples/api/bsoncxx/examples/bson_errors/access_arr_iter_invalid.cpp index 3ec1731122..86e423f2be 100644 --- a/examples/api/bsoncxx/examples/bson_errors/access_arr_iter_invalid.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/access_arr_iter_invalid.cpp @@ -27,22 +27,22 @@ namespace { // [Example] void example() { bsoncxx::array::value::deleter_type deleter = [](std::uint8_t*) {}; - std::uint8_t data[] = {0u}; // An invalid BSON array. + std::uint8_t data[] = {0u}; // An invalid BSON array. bsoncxx::array::value owner{data, sizeof(data), deleter}; bsoncxx::array::view arr = owner.view(); auto iter = arr.begin(); - EXPECT(iter == arr.end()); // An invalid BSON document returns an end iterator. + EXPECT(iter == arr.end()); // An invalid BSON document returns an end iterator. - bsoncxx::array::element e = *iter; // DO NOT DO THIS + bsoncxx::array::element e = *iter; // DO NOT DO THIS - EXPECT(!e); // An end iterator returns an invalid element. + EXPECT(!e); // An end iterator returns an invalid element. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/access_arr_key_missing.cpp b/examples/api/bsoncxx/examples/bson_errors/access_arr_key_missing.cpp index f63a1cdc03..611dc09065 100644 --- a/examples/api/bsoncxx/examples/bson_errors/access_arr_key_missing.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/access_arr_key_missing.cpp @@ -31,11 +31,11 @@ void example(bsoncxx::array::view arr) { bsoncxx::array::element e = arr[3]; - EXPECT(!e); // A missing element is represented as an invalid element. + EXPECT(!e); // A missing element is represented as an invalid element. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::builder::basic::make_array(1, 2, 3)); diff --git a/examples/api/bsoncxx/examples/bson_errors/access_doc_iter_end.cpp b/examples/api/bsoncxx/examples/bson_errors/access_doc_iter_end.cpp index 0bb78f20d8..3e8c57c8b9 100644 --- a/examples/api/bsoncxx/examples/bson_errors/access_doc_iter_end.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/access_doc_iter_end.cpp @@ -27,24 +27,24 @@ namespace { void example(bsoncxx::document::view doc) { EXPECT(doc.begin() != doc.end()); - auto iter = doc.begin(); // "a": 1 + auto iter = doc.begin(); // "a": 1 - ++iter; // "b": 2 - ++iter; // End iterator. + ++iter; // "b": 2 + ++iter; // End iterator. EXPECT(iter == doc.end()); - ++iter; // DO NOT DO THIS + ++iter; // DO NOT DO THIS - EXPECT(iter == doc.end()); // Incrementing an end iterator results in an end iterator. + EXPECT(iter == doc.end()); // Incrementing an end iterator results in an end iterator. - bsoncxx::document::element e = *iter; // DO NOT DO THIS + bsoncxx::document::element e = *iter; // DO NOT DO THIS - EXPECT(!e); // An end iterator returns an invalid element. + EXPECT(!e); // An end iterator returns an invalid element. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::from_json(R"({"a": 1, "b": 2})")); diff --git a/examples/api/bsoncxx/examples/bson_errors/access_doc_iter_invalid.cpp b/examples/api/bsoncxx/examples/bson_errors/access_doc_iter_invalid.cpp index 11fc5713af..1c8c84039d 100644 --- a/examples/api/bsoncxx/examples/bson_errors/access_doc_iter_invalid.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/access_doc_iter_invalid.cpp @@ -28,22 +28,22 @@ namespace { // [Example] void example() { bsoncxx::document::value::deleter_type deleter = [](std::uint8_t*) {}; - std::uint8_t data[] = {0u}; // An invalid BSON document. + std::uint8_t data[] = {0u}; // An invalid BSON document. bsoncxx::document::value owner{data, sizeof(data), deleter}; bsoncxx::document::view doc = owner.view(); auto iter = doc.begin(); - EXPECT(iter == doc.end()); // An invalid BSON document returns an end iterator. + EXPECT(iter == doc.end()); // An invalid BSON document returns an end iterator. - bsoncxx::document::element e = *iter; // DO NOT DO THIS + bsoncxx::document::element e = *iter; // DO NOT DO THIS - EXPECT(!e); // An end iterator returns an invalid element. + EXPECT(!e); // An end iterator returns an invalid element. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/access_doc_key_missing.cpp b/examples/api/bsoncxx/examples/bson_errors/access_doc_key_missing.cpp index 7d55ba0377..936220f9f0 100644 --- a/examples/api/bsoncxx/examples/bson_errors/access_doc_key_missing.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/access_doc_key_missing.cpp @@ -30,11 +30,11 @@ void example(bsoncxx::document::view doc) { bsoncxx::document::element e = doc["c"]; - EXPECT(!e); // A missing element is represented as an invalid element. + EXPECT(!e); // A missing element is represented as an invalid element. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::from_json(R"({"a": 1, "b": 2})")); diff --git a/examples/api/bsoncxx/examples/bson_errors/big_string.hh b/examples/api/bsoncxx/examples/bson_errors/big_string.hh index 76566165e3..34559a19c9 100644 --- a/examples/api/bsoncxx/examples/bson_errors/big_string.hh +++ b/examples/api/bsoncxx/examples/bson_errors/big_string.hh @@ -39,4 +39,4 @@ struct big_string { } }; -} // namespace examples +} // namespace examples diff --git a/examples/api/bsoncxx/examples/bson_errors/create_arr_append.cpp b/examples/api/bsoncxx/examples/bson_errors/create_arr_append.cpp index 1213d56243..392528d03e 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_arr_append.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_arr_append.cpp @@ -38,10 +38,10 @@ void example(bsoncxx::stdx::string_view big_string) { bsoncxx::array::value original{builder.view()}; try { - builder.append(big_string); // Throws. + builder.append(big_string); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_cannot_append_string); } @@ -49,7 +49,7 @@ void example(bsoncxx::stdx::string_view big_string) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(examples::big_string().view()); diff --git a/examples/api/bsoncxx/examples/bson_errors/create_arr_append_sub_array.cpp b/examples/api/bsoncxx/examples/bson_errors/create_arr_append_sub_array.cpp index bd696bad9d..c29ca07431 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_arr_append_sub_array.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_arr_append_sub_array.cpp @@ -35,24 +35,24 @@ namespace { void example(bsoncxx::stdx::string_view big_string) { bsoncxx::builder::basic::array builder; builder.append("element"); - bsoncxx::array::value original{builder.view()}; // Copy of current state. + bsoncxx::array::value original{builder.view()}; // Copy of current state. try { builder.append([&](bsoncxx::builder::basic::sub_array arr) { - arr.append(big_string); // Throws. + arr.append(big_string); // Throws. }); EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_cannot_append_string); } // Builder is in an erroneous state. try { - builder.view(); // Throws. + builder.view(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unmatched_key_in_builder); } @@ -67,7 +67,7 @@ void example(bsoncxx::stdx::string_view big_string) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(examples::big_string().view()); diff --git a/examples/api/bsoncxx/examples/bson_errors/create_arr_append_sub_document.cpp b/examples/api/bsoncxx/examples/bson_errors/create_arr_append_sub_document.cpp index 51a4e1af6d..ce5d46f075 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_arr_append_sub_document.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_arr_append_sub_document.cpp @@ -38,24 +38,24 @@ void example(bsoncxx::stdx::string_view big_string) { bsoncxx::builder::basic::array builder; builder.append("element"); - bsoncxx::array::value original{builder.view()}; // Copy of current state. + bsoncxx::array::value original{builder.view()}; // Copy of current state. try { builder.append([&](bsoncxx::builder::basic::sub_document doc) { - doc.append(kvp("too big", big_string)); // Throws. + doc.append(kvp("too big", big_string)); // Throws. }); EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_cannot_append_string); } // Builder is in an erroneous state. try { - builder.view(); // Throws. + builder.view(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unmatched_key_in_builder); } @@ -70,7 +70,7 @@ void example(bsoncxx::stdx::string_view big_string) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(examples::big_string().view()); diff --git a/examples/api/bsoncxx/examples/bson_errors/create_bson_value_invalid_element.cpp b/examples/api/bsoncxx/examples/bson_errors/create_bson_value_invalid_element.cpp index df9d5fdead..44aa5df811 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_bson_value_invalid_element.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_bson_value_invalid_element.cpp @@ -26,16 +26,16 @@ namespace { void example() { try { bsoncxx::document::element e; - bsoncxx::types::bson_value::view v = e.get_value(); // Throws. + bsoncxx::types::bson_value::view v = e.get_value(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unset_element); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/create_bson_value_invalid_type.cpp b/examples/api/bsoncxx/examples/bson_errors/create_bson_value_invalid_type.cpp index 70439777d6..2cfe43765c 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_bson_value_invalid_type.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_bson_value_invalid_type.cpp @@ -25,16 +25,16 @@ namespace { // [Example] void example() { try { - bsoncxx::types::bson_value::value value{bsoncxx::type::k_null}; // Throws. + bsoncxx::types::bson_value::value value{bsoncxx::type::k_null}; // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_invalid_bson_type_id); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/create_doc_append.cpp b/examples/api/bsoncxx/examples/bson_errors/create_doc_append.cpp index b4b760ec35..8511a0c1af 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_doc_append.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_doc_append.cpp @@ -41,10 +41,10 @@ void example(bsoncxx::stdx::string_view big_string) { bsoncxx::document::value original{builder.view()}; try { - builder.append(kvp("too big", big_string)); // Throws. + builder.append(kvp("too big", big_string)); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_cannot_append_string); } @@ -52,7 +52,7 @@ void example(bsoncxx::stdx::string_view big_string) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(examples::big_string().view()); diff --git a/examples/api/bsoncxx/examples/bson_errors/create_doc_append_sub_array.cpp b/examples/api/bsoncxx/examples/bson_errors/create_doc_append_sub_array.cpp index 0393a93ceb..99aea6d526 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_doc_append_sub_array.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_doc_append_sub_array.cpp @@ -40,24 +40,24 @@ void example(bsoncxx::stdx::string_view big_string) { bsoncxx::builder::basic::document builder; builder.append(kvp("key", "value")); - bsoncxx::document::value original{builder.view()}; // Copy of current state. + bsoncxx::document::value original{builder.view()}; // Copy of current state. try { builder.append(kvp("bad", [&](bsoncxx::builder::basic::sub_array arr) { - arr.append(big_string); // Throws. + arr.append(big_string); // Throws. })); EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_cannot_append_string); } // Builder is in an erroneous state. try { - builder.view(); // Throws. + builder.view(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unmatched_key_in_builder); } @@ -72,7 +72,7 @@ void example(bsoncxx::stdx::string_view big_string) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(examples::big_string().view()); diff --git a/examples/api/bsoncxx/examples/bson_errors/create_doc_append_sub_document.cpp b/examples/api/bsoncxx/examples/bson_errors/create_doc_append_sub_document.cpp index 6a3ce423d1..32c5fd7eff 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_doc_append_sub_document.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_doc_append_sub_document.cpp @@ -39,24 +39,24 @@ void example(bsoncxx::stdx::string_view big_string) { bsoncxx::builder::basic::document builder; builder.append(kvp("key", "value")); - bsoncxx::document::value original{builder.view()}; // Copy of current state. + bsoncxx::document::value original{builder.view()}; // Copy of current state. try { builder.append(kvp("bad", [&](bsoncxx::builder::basic::sub_document doc) { - doc.append(kvp("too big", big_string)); // Throws. + doc.append(kvp("too big", big_string)); // Throws. })); EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_cannot_append_string); } // Builder is in an erroneous state. try { - builder.view(); // Throws. + builder.view(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unmatched_key_in_builder); } @@ -71,7 +71,7 @@ void example(bsoncxx::stdx::string_view big_string) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(examples::big_string().view()); diff --git a/examples/api/bsoncxx/examples/bson_errors/create_json.cpp b/examples/api/bsoncxx/examples/bson_errors/create_json.cpp index a9d3df4f63..f681a509ca 100644 --- a/examples/api/bsoncxx/examples/bson_errors/create_json.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/create_json.cpp @@ -24,16 +24,16 @@ namespace { // [Example] void example() { try { - const auto doc = bsoncxx::from_json(R"(invalid json)"); + auto const doc = bsoncxx::from_json(R"(invalid json)"); EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_json_parse_failure); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/query_bson_value_invalid_type.cpp b/examples/api/bsoncxx/examples/bson_errors/query_bson_value_invalid_type.cpp index 5e2a491c55..6a39f9eb9d 100644 --- a/examples/api/bsoncxx/examples/bson_errors/query_bson_value_invalid_type.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/query_bson_value_invalid_type.cpp @@ -29,24 +29,24 @@ void example() { EXPECT(v.get_null() == bsoncxx::types::b_null{}); try { - bsoncxx::types::b_int32 i = v.get_int32(); // Throws. + bsoncxx::types::b_int32 i = v.get_int32(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_need_element_type_k_int32); } try { - bsoncxx::types::b_int64 i = v.get_int64(); // Throws. + bsoncxx::types::b_int64 i = v.get_int64(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_need_element_type_k_int64); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/query_element_arr_invalid.cpp b/examples/api/bsoncxx/examples/bson_errors/query_element_arr_invalid.cpp index 8b2df5e6f1..f2c507cbc2 100644 --- a/examples/api/bsoncxx/examples/bson_errors/query_element_arr_invalid.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/query_element_arr_invalid.cpp @@ -28,34 +28,34 @@ namespace { // [Example] void example() { bsoncxx::array::value::deleter_type deleter = [](std::uint8_t*) {}; - std::uint8_t data[] = {0u}; // An invalid BSON array. + std::uint8_t data[] = {0u}; // An invalid BSON array. bsoncxx::array::value owner{data, sizeof(data), deleter}; bsoncxx::array::view arr = owner.view(); bsoncxx::array::element e = arr[0]; - EXPECT(!e); // An invalid BSON array returns an invalid element. + EXPECT(!e); // An invalid BSON array returns an invalid element. try { - bsoncxx::stdx::string_view key = e.key(); // Throws. + bsoncxx::stdx::string_view key = e.key(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unset_element); } try { - bsoncxx::type type = e.type(); // Throws. + bsoncxx::type type = e.type(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unset_element); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/query_element_arr_invalid_type.cpp b/examples/api/bsoncxx/examples/bson_errors/query_element_arr_invalid_type.cpp index 774ad7936b..de7da09e57 100644 --- a/examples/api/bsoncxx/examples/bson_errors/query_element_arr_invalid_type.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/query_element_arr_invalid_type.cpp @@ -31,24 +31,24 @@ void example(bsoncxx::array::element e) { EXPECT(e.get_int32().value == 1); try { - bsoncxx::types::b_double d = e.get_double(); // Throws. + bsoncxx::types::b_double d = e.get_double(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_need_element_type_k_double); } try { - bsoncxx::types::b_string str = e.get_string(); // Throws. + bsoncxx::types::b_string str = e.get_string(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_need_element_type_k_string); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(bsoncxx::builder::basic::make_array(1).view()[0]); diff --git a/examples/api/bsoncxx/examples/bson_errors/query_element_doc_invalid.cpp b/examples/api/bsoncxx/examples/bson_errors/query_element_doc_invalid.cpp index b54804a220..654e796c25 100644 --- a/examples/api/bsoncxx/examples/bson_errors/query_element_doc_invalid.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/query_element_doc_invalid.cpp @@ -31,34 +31,34 @@ namespace { // [Example] void example() { bsoncxx::document::value::deleter_type deleter = [](std::uint8_t*) {}; - std::uint8_t data[] = {0u}; // An invalid BSON document. + std::uint8_t data[] = {0u}; // An invalid BSON document. bsoncxx::document::value owner{data, sizeof(data), deleter}; bsoncxx::document::view doc = owner.view(); bsoncxx::document::element e = doc["x"]; - EXPECT(!e); // An invalid BSON document returns an invalid element. + EXPECT(!e); // An invalid BSON document returns an invalid element. try { - bsoncxx::stdx::string_view key = e.key(); // Throws. + bsoncxx::stdx::string_view key = e.key(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unset_element); } try { - bsoncxx::type type = e.type(); // Throws. + bsoncxx::type type = e.type(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_unset_element); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/query_element_doc_invalid_type.cpp b/examples/api/bsoncxx/examples/bson_errors/query_element_doc_invalid_type.cpp index 92ac64ac73..8b3851f8b1 100644 --- a/examples/api/bsoncxx/examples/bson_errors/query_element_doc_invalid_type.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/query_element_doc_invalid_type.cpp @@ -31,27 +31,27 @@ void example(bsoncxx::document::element e) { EXPECT(e.get_int32().value == 1); try { - bsoncxx::types::b_double d = e.get_double(); // Throws. + bsoncxx::types::b_double d = e.get_double(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_need_element_type_k_double); } try { - bsoncxx::types::b_string str = e.get_string(); // Throws. + bsoncxx::types::b_string str = e.get_string(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_need_element_type_k_string); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { - const auto doc = bsoncxx::from_json(R"({"x": 1})"); + auto const doc = bsoncxx::from_json(R"({"x": 1})"); example(doc["x"]); } diff --git a/examples/api/bsoncxx/examples/bson_errors/to_json_invalid_arr.cpp b/examples/api/bsoncxx/examples/bson_errors/to_json_invalid_arr.cpp index 9325c7f785..296907dd01 100644 --- a/examples/api/bsoncxx/examples/bson_errors/to_json_invalid_arr.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/to_json_invalid_arr.cpp @@ -32,22 +32,22 @@ void example() { using bsoncxx::ExtendedJsonMode; bsoncxx::array::value::deleter_type deleter = [](std::uint8_t*) {}; - std::uint8_t data[] = {0u}; // Invalid BSON array. + std::uint8_t data[] = {0u}; // Invalid BSON array. bsoncxx::array::value owner{data, sizeof(data), deleter}; bsoncxx::array::view doc = owner.view(); try { - std::string json = bsoncxx::to_json(doc); // Throws. + std::string json = bsoncxx::to_json(doc); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_failed_converting_bson_to_json); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/bson_errors/to_json_invalid_doc.cpp b/examples/api/bsoncxx/examples/bson_errors/to_json_invalid_doc.cpp index 6d9b8466ed..53be672b2d 100644 --- a/examples/api/bsoncxx/examples/bson_errors/to_json_invalid_doc.cpp +++ b/examples/api/bsoncxx/examples/bson_errors/to_json_invalid_doc.cpp @@ -32,22 +32,22 @@ void example() { using bsoncxx::ExtendedJsonMode; bsoncxx::document::value::deleter_type deleter = [](std::uint8_t*) {}; - std::uint8_t data[] = {0u}; // Invalid BSON document. + std::uint8_t data[] = {0u}; // Invalid BSON document. bsoncxx::document::value owner{data, sizeof(data), deleter}; bsoncxx::document::view doc = owner.view(); try { - std::string json = bsoncxx::to_json(doc); // Throws. + std::string json = bsoncxx::to_json(doc); // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_failed_converting_bson_to_json); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/decimal128/basic_usage.cpp b/examples/api/bsoncxx/examples/decimal128/basic_usage.cpp index 1e70994988..efe6e6be84 100644 --- a/examples/api/bsoncxx/examples/decimal128/basic_usage.cpp +++ b/examples/api/bsoncxx/examples/decimal128/basic_usage.cpp @@ -23,7 +23,7 @@ namespace { // [Example] void example() { - using d128 = bsoncxx::decimal128; // For brevity. + using d128 = bsoncxx::decimal128; // For brevity. // Default ctor. EXPECT(d128{}.to_string() == "0E-6176"); @@ -97,7 +97,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/decimal128/errors.cpp b/examples/api/bsoncxx/examples/decimal128/errors.cpp index c852a93f93..585c8e70c4 100644 --- a/examples/api/bsoncxx/examples/decimal128/errors.cpp +++ b/examples/api/bsoncxx/examples/decimal128/errors.cpp @@ -24,16 +24,16 @@ namespace { // [Example] void example() { try { - bsoncxx::decimal128 d{"invalid"}; // Throws. + bsoncxx::decimal128 d{"invalid"}; // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_invalid_decimal128); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/decimal128/from_bytes.cpp b/examples/api/bsoncxx/examples/decimal128/from_bytes.cpp index d29b46d5d1..81827aaa92 100644 --- a/examples/api/bsoncxx/examples/decimal128/from_bytes.cpp +++ b/examples/api/bsoncxx/examples/decimal128/from_bytes.cpp @@ -23,7 +23,7 @@ namespace { // [Example] void example() { - using d128 = bsoncxx::decimal128; // For brevity. + using d128 = bsoncxx::decimal128; // For brevity. // Default ctor. EXPECT((d128{0u, 0u}) == d128{}); @@ -78,7 +78,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/oid/basic_usage.cpp b/examples/api/bsoncxx/examples/oid/basic_usage.cpp index b58847b891..e40752bc1e 100644 --- a/examples/api/bsoncxx/examples/oid/basic_usage.cpp +++ b/examples/api/bsoncxx/examples/oid/basic_usage.cpp @@ -29,7 +29,7 @@ void example() { bsoncxx::oid a; bsoncxx::oid b; - EXPECT(a != b); // Random and unique per process. + EXPECT(a != b); // Random and unique per process. } { @@ -40,12 +40,11 @@ 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"); } - EXPECT(oid.bytes() != bytes); // Seperate storage. + EXPECT(oid.bytes() != bytes); // Seperate storage. EXPECT(oid.size() == bsoncxx::oid::k_oid_length); EXPECT(std::memcmp(bytes, oid.bytes(), oid.size()) == 0); @@ -62,22 +61,21 @@ 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"); } - EXPECT(oid < bsoncxx::oid{"389622001112131415212223"}); // Timestamp: 2000-02-01 00:00:00 - EXPECT(oid > bsoncxx::oid{"386d43801112131415212223"}); // Timestamp: 2000-01-01 00:00:00 - EXPECT(oid < bsoncxx::oid{"386e94ffffffffffff212223"}); // Value: 1099511627775 - EXPECT(oid > bsoncxx::oid{"386e94ff0000000000212223"}); // Value: 0 - EXPECT(oid < bsoncxx::oid{"386e94ff1112131415ffffff"}); // Counter: 16777215 - EXPECT(oid > bsoncxx::oid{"386e94ff1112131415000000"}); // Counter: 0 + EXPECT(oid < bsoncxx::oid{"389622001112131415212223"}); // Timestamp: 2000-02-01 00:00:00 + EXPECT(oid > bsoncxx::oid{"386d43801112131415212223"}); // Timestamp: 2000-01-01 00:00:00 + EXPECT(oid < bsoncxx::oid{"386e94ffffffffffff212223"}); // Value: 1099511627775 + EXPECT(oid > bsoncxx::oid{"386e94ff0000000000212223"}); // Value: 0 + EXPECT(oid < bsoncxx::oid{"386e94ff1112131415ffffff"}); // Counter: 16777215 + EXPECT(oid > bsoncxx::oid{"386e94ff1112131415000000"}); // Counter: 0 } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/oid/errors.cpp b/examples/api/bsoncxx/examples/oid/errors.cpp index d653a898ac..9dc346fbd1 100644 --- a/examples/api/bsoncxx/examples/oid/errors.cpp +++ b/examples/api/bsoncxx/examples/oid/errors.cpp @@ -24,26 +24,26 @@ namespace { // [Example] void example() { try { - bsoncxx::oid oid{"invalid"}; // Throws. + bsoncxx::oid oid{"invalid"}; // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_invalid_oid); } try { char bytes[1]{}; - bsoncxx::oid oid{bytes, sizeof(bytes)}; // Throws. + bsoncxx::oid oid{bytes, sizeof(bytes)}; // Throws. EXPECT(false && "should not reach this point"); - } catch (const bsoncxx::exception& ex) { + } catch (bsoncxx::exception const& ex) { EXPECT(ex.code() == bsoncxx::error_code::k_invalid_oid); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/validation/basic_usage.cpp b/examples/api/bsoncxx/examples/validation/basic_usage.cpp index f24b88db63..ceaf61f21a 100644 --- a/examples/api/bsoncxx/examples/validation/basic_usage.cpp +++ b/examples/api/bsoncxx/examples/validation/basic_usage.cpp @@ -28,7 +28,7 @@ namespace { // [Example] void example() { { - std::uint8_t bytes[1]{}; // Invalid. + std::uint8_t bytes[1]{}; // Invalid. EXPECT(!bsoncxx::validate(bytes, sizeof(bytes))); @@ -41,8 +41,8 @@ void example() { } bsoncxx::document::value owner = bsoncxx::from_json(R"({"x": 1})"); - const std::uint8_t* data = owner.data(); - const std::size_t length = owner.length(); + std::uint8_t const* data = owner.data(); + std::size_t const length = owner.length(); { auto doc_opt = bsoncxx::validate(data, length); @@ -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); @@ -68,7 +67,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { example(); diff --git a/examples/api/bsoncxx/examples/validation/validator.cpp b/examples/api/bsoncxx/examples/validation/validator.cpp index b6a40ea43d..fa461abb26 100644 --- a/examples/api/bsoncxx/examples/validation/validator.cpp +++ b/examples/api/bsoncxx/examples/validation/validator.cpp @@ -29,7 +29,7 @@ namespace { // "$numberInt": "123" // } // } -void example(const std::uint8_t* bytes, std::size_t length) { +void example(std::uint8_t const* bytes, std::size_t length) { // Default options. { bsoncxx::validator options; @@ -83,7 +83,7 @@ void example(const std::uint8_t* bytes, std::size_t length) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT() { // clang-format off diff --git a/examples/api/db_lock.cpp b/examples/api/db_lock.cpp index 4a624e016b..2f9bfb6e48 100644 --- a/examples/api/db_lock.cpp +++ b/examples/api/db_lock.cpp @@ -30,7 +30,7 @@ namespace { std::unordered_map db_locks; std::mutex db_locks_mut; -} // namespace +} // namespace db_lock::~db_lock() { this->get().drop(wc_majority()); @@ -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/db_lock.hh b/examples/api/db_lock.hh index d37beb21c0..3916529493 100644 --- a/examples/api/db_lock.hh +++ b/examples/api/db_lock.hh @@ -33,8 +33,8 @@ class db_lock { db_lock(db_lock&&) = delete; db_lock& operator=(db_lock&&) = delete; - db_lock(const db_lock&) = delete; - db_lock& operator=(const db_lock&) = delete; + db_lock(db_lock const&) = delete; + db_lock& operator=(db_lock const&) = delete; db_lock(mongocxx::client& client, std::string name); diff --git a/examples/api/mongocxx/examples/change_streams/basic.cpp b/examples/api/mongocxx/examples/change_streams/basic.cpp index 95ec25a5f1..addc23f2d2 100644 --- a/examples/api/mongocxx/examples/change_streams/basic.cpp +++ b/examples/api/mongocxx/examples/change_streams/basic.cpp @@ -66,7 +66,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_REPLICA() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/change_streams/from_client.cpp b/examples/api/mongocxx/examples/change_streams/from_client.cpp index 90825a2ddb..66200b699a 100644 --- a/examples/api/mongocxx/examples/change_streams/from_client.cpp +++ b/examples/api/mongocxx/examples/change_streams/from_client.cpp @@ -59,7 +59,7 @@ void example(mongocxx::client client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_REPLICA() { example(mongocxx::client{mongocxx::uri{}}); diff --git a/examples/api/mongocxx/examples/change_streams/from_collection.cpp b/examples/api/mongocxx/examples/change_streams/from_collection.cpp index 1eb27f76bf..6c94aa54ed 100644 --- a/examples/api/mongocxx/examples/change_streams/from_collection.cpp +++ b/examples/api/mongocxx/examples/change_streams/from_collection.cpp @@ -60,7 +60,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_REPLICA() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/change_streams/from_database.cpp b/examples/api/mongocxx/examples/change_streams/from_database.cpp index 656186c600..ed772af16c 100644 --- a/examples/api/mongocxx/examples/change_streams/from_database.cpp +++ b/examples/api/mongocxx/examples/change_streams/from_database.cpp @@ -60,7 +60,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_REPLICA() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/change_streams/with_pipeline.cpp b/examples/api/mongocxx/examples/change_streams/with_pipeline.cpp index 8a70589753..15a085852e 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})"))); @@ -71,7 +69,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_REPLICA() { mongocxx::client client{mongocxx::uri{}}; @@ -94,7 +92,7 @@ RUNNER_REGISTER_COMPONENT_FOR_REPLICA() { EXPECT(doc["watched"]); EXPECT(doc["watched"].get_bool().value); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { if (std::strstr(ex.what(), "not supported") != nullptr) { // MongoDB 4.2+ required for sharded clusters. } else { diff --git a/examples/api/mongocxx/examples/client_sessions/create/basic.cpp b/examples/api/mongocxx/examples/client_sessions/create/basic.cpp index bf3d683b76..dd41cdf900 100644 --- a/examples/api/mongocxx/examples/client_sessions/create/basic.cpp +++ b/examples/api/mongocxx/examples/client_sessions/create/basic.cpp @@ -35,7 +35,7 @@ void example(mongocxx::client client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { example(mongocxx::client{mongocxx::uri{}}); diff --git a/examples/api/mongocxx/examples/client_sessions/create/with_options.cpp b/examples/api/mongocxx/examples/client_sessions/create/with_options.cpp index 7c6cdd4488..178a54f448 100644 --- a/examples/api/mongocxx/examples/client_sessions/create/with_options.cpp +++ b/examples/api/mongocxx/examples/client_sessions/create/with_options.cpp @@ -35,7 +35,7 @@ void example(mongocxx::client client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { example(mongocxx::client{mongocxx::uri{}}); diff --git a/examples/api/mongocxx/examples/client_sessions/use/basic.cpp b/examples/api/mongocxx/examples/client_sessions/use/basic.cpp index 92dd589937..fb51fe0f70 100644 --- a/examples/api/mongocxx/examples/client_sessions/use/basic.cpp +++ b/examples/api/mongocxx/examples/client_sessions/use/basic.cpp @@ -52,7 +52,7 @@ void example(mongocxx::client_session session, mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/client_sessions/use/transactions.cpp b/examples/api/mongocxx/examples/client_sessions/use/transactions.cpp index 67ad38a987..08dcd40d09 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); @@ -68,7 +67,7 @@ void example(mongocxx::client_session session, mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_REPLICA() { mongocxx::client client{mongocxx::uri{}}; @@ -76,9 +75,8 @@ 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")); - } catch (const mongocxx::exception& ex) { + example(client.start_session(), set_rw_concern_majority(guard.get()).create_collection("coll")); + } catch (mongocxx::exception const& ex) { if (std::strstr(ex.what(), "not supported") != nullptr) { // MongoDB 4.2+ required for sharded clusters. } else { diff --git a/examples/api/mongocxx/examples/clients/create/pool/basic.cpp b/examples/api/mongocxx/examples/clients/create/pool/basic.cpp index a43d256171..0b2de885b0 100644 --- a/examples/api/mongocxx/examples/clients/create/pool/basic.cpp +++ b/examples/api/mongocxx/examples/clients/create/pool/basic.cpp @@ -52,7 +52,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/clients/create/pool/options.cpp b/examples/api/mongocxx/examples/clients/create/pool/options.cpp index a978f226a1..b807cb04f4 100644 --- a/examples/api/mongocxx/examples/clients/create/pool/options.cpp +++ b/examples/api/mongocxx/examples/clients/create/pool/options.cpp @@ -43,7 +43,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { example(); diff --git a/examples/api/mongocxx/examples/clients/create/pool/try_acquire.cpp b/examples/api/mongocxx/examples/clients/create/pool/try_acquire.cpp index 1c32f7feb6..e792792f76 100644 --- a/examples/api/mongocxx/examples/clients/create/pool/try_acquire.cpp +++ b/examples/api/mongocxx/examples/clients/create/pool/try_acquire.cpp @@ -48,7 +48,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { example(); diff --git a/examples/api/mongocxx/examples/clients/create/single/basic.cpp b/examples/api/mongocxx/examples/clients/create/single/basic.cpp index f9dd631946..740075279c 100644 --- a/examples/api/mongocxx/examples/clients/create/single/basic.cpp +++ b/examples/api/mongocxx/examples/clients/create/single/basic.cpp @@ -37,7 +37,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/clients/create/single/options/apm.cpp b/examples/api/mongocxx/examples/clients/create/single/options/apm.cpp index 033b179c55..c84433493a 100644 --- a/examples/api/mongocxx/examples/clients/create/single/options/apm.cpp +++ b/examples/api/mongocxx/examples/clients/create/single/options/apm.cpp @@ -28,7 +28,7 @@ namespace { // [Example] -void on_command_started_callback(const mongocxx::events::command_started_event& event); +void on_command_started_callback(mongocxx::events::command_started_event const& event); void example() { mongocxx::options::apm apm_opts; @@ -45,11 +45,11 @@ void example() { } // [Example] -void on_command_started_callback(const mongocxx::events::command_started_event& event) { +void on_command_started_callback(mongocxx::events::command_started_event const& event) { (void)event; } -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); 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..619773174a 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 @@ -52,7 +52,7 @@ void example(bsoncxx::document::view kms_providers) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { using bsoncxx::builder::basic::kvp; @@ -63,10 +63,8 @@ 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}))))); - } catch (const mongocxx::exception& ex) { + make_document(kvp("key", bsoncxx::types::b_binary{bsoncxx::binary_sub_type::k_binary, 96, local_key}))))); + } catch (mongocxx::exception const& ex) { if (std::strstr(ex.what(), "ENABLE_CLIENT_SIDE_ENCRYPTION") != nullptr) { // Library may not be configured with TLS/SSL support enabled. } else { 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..f4b0697a54 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. @@ -46,7 +45,7 @@ mongocxx::client example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { auto client = example(); diff --git a/examples/api/mongocxx/examples/clients/create/single/options/tls.cpp b/examples/api/mongocxx/examples/clients/create/single/options/tls.cpp index 882bd6cb3c..dc27b8fab6 100644 --- a/examples/api/mongocxx/examples/clients/create/single/options/tls.cpp +++ b/examples/api/mongocxx/examples/clients/create/single/options/tls.cpp @@ -47,7 +47,7 @@ mongocxx::client example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { try { @@ -56,7 +56,7 @@ RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { auto reply = client["admin"].run_command(bsoncxx::from_json(R"({"ping": 1})")); EXPECT(reply["ok"] && reply["ok"].get_double().value == 1.0); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { if (ex.code() == mongocxx::error_code::k_ssl_not_supported) { // Library may not be configured with TLS/SSL support enabled. } else if (std::strstr(ex.what(), "suitable server") != nullptr) { diff --git a/examples/api/mongocxx/examples/clients/create/single/with_uri.cpp b/examples/api/mongocxx/examples/clients/create/single/with_uri.cpp index 363397004f..e018c1bb49 100644 --- a/examples/api/mongocxx/examples/clients/create/single/with_uri.cpp +++ b/examples/api/mongocxx/examples/clients/create/single/with_uri.cpp @@ -30,7 +30,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/clients/errors/auto_encryption.cpp b/examples/api/mongocxx/examples/clients/errors/auto_encryption.cpp index cf237289e6..d2e635ce0d 100644 --- a/examples/api/mongocxx/examples/clients/errors/auto_encryption.cpp +++ b/examples/api/mongocxx/examples/clients/errors/auto_encryption.cpp @@ -36,15 +36,15 @@ 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) { + } catch (mongocxx::exception const& ex) { // CXX-834: libmongoc error code. EXPECT(ex.code().category() == mongocxx::server_error_category()); - EXPECT(ex.code().value() == 58); // MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG + EXPECT(ex.code().value() == 58); // MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG } // Invalid KMS providers. @@ -54,13 +54,13 @@ void example() { mongocxx::options::client{}.auto_encryption_opts( mongocxx::options::auto_encryption{} .key_vault_namespace({"keyvault", "datakeys"}) - .kms_providers(bsoncxx::from_json(R"({"invalid": 1})")))}; // Throws. + .kms_providers(bsoncxx::from_json(R"({"invalid": 1})")))}; // Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { // CXX-834: libmongocrypt error code. EXPECT(ex.code().category() == mongocxx::server_error_category()); - EXPECT(ex.code().value() == 1); // MONGOCRYPT_GENERIC_ERROR_CODE + EXPECT(ex.code().value() == 1); // MONGOCRYPT_GENERIC_ERROR_CODE } // Incompatible options. @@ -68,28 +68,26 @@ 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) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_parameter); } } // [Example] -} // namespace +} // namespace 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{})}; + mongocxx::uri{}, mongocxx::options::client{}.auto_encryption_opts(mongocxx::options::auto_encryption{})}; EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { if (std::strstr(ex.what(), "ENABLE_CLIENT_SIDE_ENCRYPTION") != nullptr) { // Library may not be configured with TLS/SSL support enabled. } else { diff --git a/examples/api/mongocxx/examples/clients/errors/invalid_client.cpp b/examples/api/mongocxx/examples/clients/errors/invalid_client.cpp index 73207997b1..e32bef2c43 100644 --- a/examples/api/mongocxx/examples/clients/errors/invalid_client.cpp +++ b/examples/api/mongocxx/examples/clients/errors/invalid_client.cpp @@ -29,16 +29,16 @@ void example() { EXPECT(!client); try { - mongocxx::uri uri = client.uri(); // DO NOT DO THIS. Throws. + mongocxx::uri uri = client.uri(); // DO NOT DO THIS. Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_client_object); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/clients/errors/stable_api.cpp b/examples/api/mongocxx/examples/clients/errors/stable_api.cpp index c32deff377..f184319e47 100644 --- a/examples/api/mongocxx/examples/clients/errors/stable_api.cpp +++ b/examples/api/mongocxx/examples/clients/errors/stable_api.cpp @@ -25,25 +25,25 @@ namespace { void example() { try { mongocxx::options::server_api::version version = - mongocxx::options::server_api::version_from_string("0"); // Throws. + mongocxx::options::server_api::version_from_string("0"); // Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_parameter); } try { std::string version = mongocxx::options::server_api::version_to_string( - static_cast(1)); // Throws. + static_cast(1)); // Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_parameter); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/clients/errors/tls.cpp b/examples/api/mongocxx/examples/clients/errors/tls.cpp index 3518975f8a..0946d7ac36 100644 --- a/examples/api/mongocxx/examples/clients/errors/tls.cpp +++ b/examples/api/mongocxx/examples/clients/errors/tls.cpp @@ -28,11 +28,10 @@ namespace { void example() { try { mongocxx::client client{ - mongocxx::uri{}, - mongocxx::options::client{}.tls_opts(mongocxx::options::tls{})}; // Throws. + mongocxx::uri{}, mongocxx::options::client{}.tls_opts(mongocxx::options::tls{})}; // Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT( // When TLS/SSL is enabled for both mongocxx and libmongoc. ex.code() == mongocxx::error_code::k_invalid_parameter || @@ -45,7 +44,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); 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..012fc34ad0 100644 --- a/examples/api/mongocxx/examples/clients/errors/wait_queue_timeout.cpp +++ b/examples/api/mongocxx/examples/clients/errors/wait_queue_timeout.cpp @@ -27,23 +27,22 @@ 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(); EXPECT(hold); - mongocxx::pool::entry entry = pool.acquire(); // Throws. + mongocxx::pool::entry entry = pool.acquire(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_pool_wait_queue_timeout); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/clients/use/list_database_names.cpp b/examples/api/mongocxx/examples/clients/use/list_database_names.cpp index b78f55c4cb..a33f2b5b92 100644 --- a/examples/api/mongocxx/examples/clients/use/list_database_names.cpp +++ b/examples/api/mongocxx/examples/clients/use/list_database_names.cpp @@ -37,7 +37,7 @@ void example(mongocxx::client client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { example(mongocxx::client{mongocxx::uri{}}); diff --git a/examples/api/mongocxx/examples/clients/use/list_database_names_with_options.cpp b/examples/api/mongocxx/examples/clients/use/list_database_names_with_options.cpp index c95c76b61c..73bb93c801 100644 --- a/examples/api/mongocxx/examples/clients/use/list_database_names_with_options.cpp +++ b/examples/api/mongocxx/examples/clients/use/list_database_names_with_options.cpp @@ -38,7 +38,7 @@ void example(mongocxx::client client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { example(mongocxx::client{mongocxx::uri{}}); diff --git a/examples/api/mongocxx/examples/clients/use/list_databases.cpp b/examples/api/mongocxx/examples/clients/use/list_databases.cpp index 26300cd568..107e513b71 100644 --- a/examples/api/mongocxx/examples/clients/use/list_databases.cpp +++ b/examples/api/mongocxx/examples/clients/use/list_databases.cpp @@ -43,7 +43,7 @@ void example(mongocxx::client client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { example(mongocxx::client{mongocxx::uri{}}); diff --git a/examples/api/mongocxx/examples/clients/use/list_databases_with_options.cpp b/examples/api/mongocxx/examples/clients/use/list_databases_with_options.cpp index 51b9a5117e..072a1f0a42 100644 --- a/examples/api/mongocxx/examples/clients/use/list_databases_with_options.cpp +++ b/examples/api/mongocxx/examples/clients/use/list_databases_with_options.cpp @@ -48,7 +48,7 @@ void example(mongocxx::client client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { example(mongocxx::client{mongocxx::uri{}}); diff --git a/examples/api/mongocxx/examples/collections/aggregate.cpp b/examples/api/mongocxx/examples/collections/aggregate.cpp index a18aa39395..e860c2ba52 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); } @@ -70,7 +68,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/bulk_write.cpp b/examples/api/mongocxx/examples/collections/bulk_write.cpp index 7baee8cfeb..d5c7ce980d 100644 --- a/examples/api/mongocxx/examples/collections/bulk_write.cpp +++ b/examples/api/mongocxx/examples/collections/bulk_write.cpp @@ -35,8 +35,8 @@ void example(mongocxx::collection coll) { EXPECT(coll.count_documents(bsoncxx::from_json(R"({"x": {"$exists": 1}})")) == 0); mongocxx::model::insert_one insert{bsoncxx::from_json(R"({"x": 10})")}; - mongocxx::model::update_one update{bsoncxx::from_json(R"({"x": {"$exists": 1}})"), - bsoncxx::from_json(R"({"$set": {"x": 20}})")}; + mongocxx::model::update_one update{ + bsoncxx::from_json(R"({"x": {"$exists": 1}})"), bsoncxx::from_json(R"({"$set": {"x": 20}})")}; mongocxx::bulk_write bulk_write = coll.create_bulk_write(); @@ -57,7 +57,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; 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..bafa583791 100644 --- a/examples/api/mongocxx/examples/collections/bulk_write_with_options.cpp +++ b/examples/api/mongocxx/examples/collections/bulk_write_with_options.cpp @@ -46,8 +46,8 @@ void example(mongocxx::collection coll) { auto result_opt = coll.create_bulk_write(opts) .append(mongocxx::model::insert_one{bsoncxx::from_json(R"({"x": 10})")}) - .append(mongocxx::model::update_one{bsoncxx::from_json(R"({"x": {"$exists": 1}})"), - bsoncxx::from_json(R"({"$set": {"x": 20}})")}) + .append(mongocxx::model::update_one{ + bsoncxx::from_json(R"({"x": {"$exists": 1}})"), bsoncxx::from_json(R"({"$set": {"x": 20}})")}) .execute(); EXPECT(result_opt); @@ -61,7 +61,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/count.cpp b/examples/api/mongocxx/examples/collections/count.cpp index 83e45f00be..03517b357c 100644 --- a/examples/api/mongocxx/examples/collections/count.cpp +++ b/examples/api/mongocxx/examples/collections/count.cpp @@ -53,7 +53,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/create_index.cpp b/examples/api/mongocxx/examples/collections/create_index.cpp index 10adf2e066..9fc6e8e00c 100644 --- a/examples/api/mongocxx/examples/collections/create_index.cpp +++ b/examples/api/mongocxx/examples/collections/create_index.cpp @@ -39,7 +39,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; @@ -55,10 +55,10 @@ RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { return std::distance(cursor.begin(), cursor.end()); }; - EXPECT(count_indexes() == 1); // _id_ + EXPECT(count_indexes() == 1); // _id_ example(coll); - EXPECT(count_indexes() == 2); // _id_, key_1 + EXPECT(count_indexes() == 2); // _id_, key_1 } } 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..d309cb3ab2 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"); @@ -64,7 +62,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/delete_many.cpp b/examples/api/mongocxx/examples/collections/delete_many.cpp index 7c594580d4..5e7eb782bc 100644 --- a/examples/api/mongocxx/examples/collections/delete_many.cpp +++ b/examples/api/mongocxx/examples/collections/delete_many.cpp @@ -73,7 +73,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/delete_one.cpp b/examples/api/mongocxx/examples/collections/delete_one.cpp index f89039a003..6ad7f22bbe 100644 --- a/examples/api/mongocxx/examples/collections/delete_one.cpp +++ b/examples/api/mongocxx/examples/collections/delete_one.cpp @@ -71,7 +71,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/distinct.cpp b/examples/api/mongocxx/examples/collections/distinct.cpp index b6ef69e445..b92e560742 100644 --- a/examples/api/mongocxx/examples/collections/distinct.cpp +++ b/examples/api/mongocxx/examples/collections/distinct.cpp @@ -75,7 +75,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/drop.cpp b/examples/api/mongocxx/examples/collections/drop.cpp index 1ea5a24fe0..092d70e512 100644 --- a/examples/api/mongocxx/examples/collections/drop.cpp +++ b/examples/api/mongocxx/examples/collections/drop.cpp @@ -36,7 +36,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/estimate_count.cpp b/examples/api/mongocxx/examples/collections/estimate_count.cpp index 43bc493280..b4d3d6bac9 100644 --- a/examples/api/mongocxx/examples/collections/estimate_count.cpp +++ b/examples/api/mongocxx/examples/collections/estimate_count.cpp @@ -50,7 +50,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/find.cpp b/examples/api/mongocxx/examples/collections/find.cpp index a9f69b48b4..b65933661a 100644 --- a/examples/api/mongocxx/examples/collections/find.cpp +++ b/examples/api/mongocxx/examples/collections/find.cpp @@ -79,7 +79,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/find_one.cpp b/examples/api/mongocxx/examples/collections/find_one.cpp index 136b3803e1..8f57242906 100644 --- a/examples/api/mongocxx/examples/collections/find_one.cpp +++ b/examples/api/mongocxx/examples/collections/find_one.cpp @@ -66,7 +66,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/find_one_and_delete.cpp b/examples/api/mongocxx/examples/collections/find_one_and_delete.cpp index ac7701396a..00d96765ac 100644 --- a/examples/api/mongocxx/examples/collections/find_one_and_delete.cpp +++ b/examples/api/mongocxx/examples/collections/find_one_and_delete.cpp @@ -79,7 +79,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/find_one_and_replace.cpp b/examples/api/mongocxx/examples/collections/find_one_and_replace.cpp index ec7b861db5..17d7629503 100644 --- a/examples/api/mongocxx/examples/collections/find_one_and_replace.cpp +++ b/examples/api/mongocxx/examples/collections/find_one_and_replace.cpp @@ -78,7 +78,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/find_one_and_update.cpp b/examples/api/mongocxx/examples/collections/find_one_and_update.cpp index 2593257c5e..cc0e39a629 100644 --- a/examples/api/mongocxx/examples/collections/find_one_and_update.cpp +++ b/examples/api/mongocxx/examples/collections/find_one_and_update.cpp @@ -85,7 +85,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/incompatible_options.cpp b/examples/api/mongocxx/examples/collections/incompatible_options.cpp index f503c2d6d7..17fdf1d492 100644 --- a/examples/api/mongocxx/examples/collections/incompatible_options.cpp +++ b/examples/api/mongocxx/examples/collections/incompatible_options.cpp @@ -46,13 +46,13 @@ void example(mongocxx::collection coll) { auto name = coll.find_one_and_update(empty.view(), empty.view(), opts); EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_parameter); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/index_views/create.cpp b/examples/api/mongocxx/examples/collections/index_views/create.cpp index 6edfcd65e0..7ca18a257b 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); @@ -51,7 +50,7 @@ void example(mongocxx::index_view indexes) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; @@ -67,10 +66,10 @@ RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { return std::distance(cursor.begin(), cursor.end()); }; - EXPECT(count_indexes() == 1); // _id_ + EXPECT(count_indexes() == 1); // _id_ example(coll.indexes()); - EXPECT(count_indexes() == 3); // _id_, x_1, y_1 + EXPECT(count_indexes() == 3); // _id_, x_1, y_1 } } diff --git a/examples/api/mongocxx/examples/collections/index_views/create_many.cpp b/examples/api/mongocxx/examples/collections/index_views/create_many.cpp index 3b0a6b7a7e..57caac137e 100644 --- a/examples/api/mongocxx/examples/collections/index_views/create_many.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/create_many.cpp @@ -49,14 +49,14 @@ void example(mongocxx::index_view indexes) { EXPECT(result["ok"].get_double().value == 1.0); EXPECT(result["numIndexesBefore"]); - EXPECT(result["numIndexesBefore"].get_int32().value == 1); // _id_ + EXPECT(result["numIndexesBefore"].get_int32().value == 1); // _id_ EXPECT(result["numIndexesAfter"]); - EXPECT(result["numIndexesAfter"].get_int32().value == 3); // _id_, x_1, y_1 + EXPECT(result["numIndexesAfter"].get_int32().value == 3); // _id_, x_1, y_1 } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/index_views/create_with_options.cpp b/examples/api/mongocxx/examples/collections/index_views/create_with_options.cpp index 73ac3ddfac..1367a7c479 100644 --- a/examples/api/mongocxx/examples/collections/index_views/create_with_options.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/create_with_options.cpp @@ -74,7 +74,7 @@ void example(mongocxx::index_view indexes) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/index_views/drop.cpp b/examples/api/mongocxx/examples/collections/index_views/drop.cpp index c64a6dcc00..bc7e4d440a 100644 --- a/examples/api/mongocxx/examples/collections/index_views/drop.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/drop.cpp @@ -49,19 +49,19 @@ void example(mongocxx::index_view indexes) { return std::distance(cursor.begin(), cursor.end()); }; - EXPECT(count_indexes() == 3); // _id_, x_1, custom_name + EXPECT(count_indexes() == 3); // _id_, x_1, custom_name indexes.drop_one("custom_name"); - EXPECT(count_indexes() == 2); // _id_, x_1 + EXPECT(count_indexes() == 2); // _id_, x_1 indexes.drop_one(bsoncxx::from_json(R"({"x": 1})")); - EXPECT(count_indexes() == 1); // _id_ + EXPECT(count_indexes() == 1); // _id_ } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; @@ -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..59a357cc55 100644 --- a/examples/api/mongocxx/examples/collections/index_views/drop_all.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/drop_all.cpp @@ -49,15 +49,15 @@ void example(mongocxx::index_view indexes) { return std::distance(cursor.begin(), cursor.end()); }; - EXPECT(count_indexes() == 3); // _id_, x_1, custom_name + EXPECT(count_indexes() == 3); // _id_, x_1, custom_name indexes.drop_all(); - EXPECT(count_indexes() == 1); // _id_ + EXPECT(count_indexes() == 1); // _id_ } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; @@ -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/index_views/indexes.cpp b/examples/api/mongocxx/examples/collections/index_views/indexes.cpp index 674cc0fa35..6b9d51b4e7 100644 --- a/examples/api/mongocxx/examples/collections/index_views/indexes.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/indexes.cpp @@ -35,7 +35,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/index_views/list.cpp b/examples/api/mongocxx/examples/collections/index_views/list.cpp index ab61cd4c90..4b47e72735 100644 --- a/examples/api/mongocxx/examples/collections/index_views/list.cpp +++ b/examples/api/mongocxx/examples/collections/index_views/list.cpp @@ -41,7 +41,7 @@ void example(mongocxx::index_view indexes) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/insert_many.cpp b/examples/api/mongocxx/examples/collections/insert_many.cpp index 265039d671..37df6a62fe 100644 --- a/examples/api/mongocxx/examples/collections/insert_many.cpp +++ b/examples/api/mongocxx/examples/collections/insert_many.cpp @@ -80,7 +80,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/insert_one.cpp b/examples/api/mongocxx/examples/collections/insert_one.cpp index 1e05b3afde..c4ac079745 100644 --- a/examples/api/mongocxx/examples/collections/insert_one.cpp +++ b/examples/api/mongocxx/examples/collections/insert_one.cpp @@ -61,7 +61,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/invalid.cpp b/examples/api/mongocxx/examples/collections/invalid.cpp index 3d23a3b1be..bb7af11464 100644 --- a/examples/api/mongocxx/examples/collections/invalid.cpp +++ b/examples/api/mongocxx/examples/collections/invalid.cpp @@ -28,16 +28,16 @@ void example() { mongocxx::collection coll; try { - auto name = coll.name(); // DO NOT DO THIS. Throws. + auto name = coll.name(); // DO NOT DO THIS. Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_collection_object); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/collections/invalid_parameter.cpp b/examples/api/mongocxx/examples/collections/invalid_parameter.cpp index e54a1ddccf..dacecbb8c0 100644 --- a/examples/api/mongocxx/examples/collections/invalid_parameter.cpp +++ b/examples/api/mongocxx/examples/collections/invalid_parameter.cpp @@ -39,13 +39,13 @@ void example(mongocxx::collection coll) { auto name = coll.find(bsoncxx::builder::basic::make_document(), opts); EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_parameter); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/list_indexes.cpp b/examples/api/mongocxx/examples/collections/list_indexes.cpp index e0c16c23b0..95dec60906 100644 --- a/examples/api/mongocxx/examples/collections/list_indexes.cpp +++ b/examples/api/mongocxx/examples/collections/list_indexes.cpp @@ -41,7 +41,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/obtain.cpp b/examples/api/mongocxx/examples/collections/obtain.cpp index c9e87cbce3..abdd6e24d4 100644 --- a/examples/api/mongocxx/examples/collections/obtain.cpp +++ b/examples/api/mongocxx/examples/collections/obtain.cpp @@ -33,7 +33,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/rc.cpp b/examples/api/mongocxx/examples/collections/rc.cpp index b366cc8921..e5a09db6b8 100644 --- a/examples/api/mongocxx/examples/collections/rc.cpp +++ b/examples/api/mongocxx/examples/collections/rc.cpp @@ -48,7 +48,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/rename.cpp b/examples/api/mongocxx/examples/collections/rename.cpp index 900488c2e0..2a69da067a 100644 --- a/examples/api/mongocxx/examples/collections/rename.cpp +++ b/examples/api/mongocxx/examples/collections/rename.cpp @@ -42,7 +42,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/replace_one.cpp b/examples/api/mongocxx/examples/collections/replace_one.cpp index ede04211f9..7be020378e 100644 --- a/examples/api/mongocxx/examples/collections/replace_one.cpp +++ b/examples/api/mongocxx/examples/collections/replace_one.cpp @@ -85,7 +85,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/rp.cpp b/examples/api/mongocxx/examples/collections/rp.cpp index ba3fe47349..86a0fb044e 100644 --- a/examples/api/mongocxx/examples/collections/rp.cpp +++ b/examples/api/mongocxx/examples/collections/rp.cpp @@ -46,7 +46,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/update_many.cpp b/examples/api/mongocxx/examples/collections/update_many.cpp index 4533d4cf67..226faf0000 100644 --- a/examples/api/mongocxx/examples/collections/update_many.cpp +++ b/examples/api/mongocxx/examples/collections/update_many.cpp @@ -84,7 +84,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/update_one.cpp b/examples/api/mongocxx/examples/collections/update_one.cpp index 47be0524c9..4949b3c4c4 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); @@ -82,7 +81,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/wc.cpp b/examples/api/mongocxx/examples/collections/wc.cpp index c346a004e4..2bcf304799 100644 --- a/examples/api/mongocxx/examples/collections/wc.cpp +++ b/examples/api/mongocxx/examples/collections/wc.cpp @@ -50,7 +50,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/collections/write.cpp b/examples/api/mongocxx/examples/collections/write.cpp index 57449cc994..8e8fce1106 100644 --- a/examples/api/mongocxx/examples/collections/write.cpp +++ b/examples/api/mongocxx/examples/collections/write.cpp @@ -62,7 +62,7 @@ void example(mongocxx::collection coll) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/create_collection.cpp b/examples/api/mongocxx/examples/databases/create_collection.cpp index 99cb6afb80..f2a5008de9 100644 --- a/examples/api/mongocxx/examples/databases/create_collection.cpp +++ b/examples/api/mongocxx/examples/databases/create_collection.cpp @@ -36,7 +36,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/create_collection_with_options.cpp b/examples/api/mongocxx/examples/databases/create_collection_with_options.cpp index 9f6da98199..10cde67584 100644 --- a/examples/api/mongocxx/examples/databases/create_collection_with_options.cpp +++ b/examples/api/mongocxx/examples/databases/create_collection_with_options.cpp @@ -39,7 +39,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/drop.cpp b/examples/api/mongocxx/examples/databases/drop.cpp index f0538d2cc4..e18a5298b6 100644 --- a/examples/api/mongocxx/examples/databases/drop.cpp +++ b/examples/api/mongocxx/examples/databases/drop.cpp @@ -46,7 +46,7 @@ void example(mongocxx::client& client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/has_collection.cpp b/examples/api/mongocxx/examples/databases/has_collection.cpp index cdec15e0be..102005a882 100644 --- a/examples/api/mongocxx/examples/databases/has_collection.cpp +++ b/examples/api/mongocxx/examples/databases/has_collection.cpp @@ -29,7 +29,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/invalid.cpp b/examples/api/mongocxx/examples/databases/invalid.cpp index 08f7f16419..de102d7e16 100644 --- a/examples/api/mongocxx/examples/databases/invalid.cpp +++ b/examples/api/mongocxx/examples/databases/invalid.cpp @@ -28,16 +28,16 @@ void example() { mongocxx::database db; try { - auto name = db.name(); // DO NOT DO THIS. Throws. + auto name = db.name(); // DO NOT DO THIS. Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_database_object); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/databases/list_collection_names.cpp b/examples/api/mongocxx/examples/databases/list_collection_names.cpp index 5ae39b26f8..0f746c59f7 100644 --- a/examples/api/mongocxx/examples/databases/list_collection_names.cpp +++ b/examples/api/mongocxx/examples/databases/list_collection_names.cpp @@ -36,9 +36,9 @@ void example(mongocxx::database db) { { std::vector names = db.list_collection_names(); - EXPECT(std::count(names.begin(), names.end(), "a") == 1); // Present. - EXPECT(std::count(names.begin(), names.end(), "b") == 1); // Present. - EXPECT(std::count(names.begin(), names.end(), "c") == 0); // Missing. + EXPECT(std::count(names.begin(), names.end(), "a") == 1); // Present. + EXPECT(std::count(names.begin(), names.end(), "b") == 1); // Present. + EXPECT(std::count(names.begin(), names.end(), "c") == 0); // Missing. } // With a filter. @@ -47,14 +47,14 @@ void example(mongocxx::database db) { std::vector names = db.list_collection_names(filter.view()); - EXPECT(std::count(names.begin(), names.end(), "a") == 1); // Present. - EXPECT(std::count(names.begin(), names.end(), "b") == 0); // Filtered. - EXPECT(std::count(names.begin(), names.end(), "c") == 0); // Missing. + EXPECT(std::count(names.begin(), names.end(), "a") == 1); // Present. + EXPECT(std::count(names.begin(), names.end(), "b") == 0); // Filtered. + EXPECT(std::count(names.begin(), names.end(), "c") == 0); // Missing. } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/list_collections.cpp b/examples/api/mongocxx/examples/databases/list_collections.cpp index d37e32634f..e62779d8ac 100644 --- a/examples/api/mongocxx/examples/databases/list_collections.cpp +++ b/examples/api/mongocxx/examples/databases/list_collections.cpp @@ -58,9 +58,9 @@ void example(mongocxx::database db) { { count_fields(db.list_collections()); - EXPECT(a == 1); // Present. - EXPECT(b == 1); // Present. - EXPECT(c == 0); // Missing. + EXPECT(a == 1); // Present. + EXPECT(b == 1); // Present. + EXPECT(c == 0); // Missing. } // With a filter. @@ -69,14 +69,14 @@ void example(mongocxx::database db) { count_fields(db.list_collections(filter.view())); - EXPECT(a == 1); // Present. - EXPECT(b == 0); // Filtered. - EXPECT(c == 0); // Missing. + EXPECT(a == 1); // Present. + EXPECT(b == 0); // Filtered. + EXPECT(c == 0); // Missing. } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/obtain.cpp b/examples/api/mongocxx/examples/databases/obtain.cpp index 039503b019..3ae5ed791d 100644 --- a/examples/api/mongocxx/examples/databases/obtain.cpp +++ b/examples/api/mongocxx/examples/databases/obtain.cpp @@ -32,7 +32,7 @@ void example(mongocxx::client client) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(mongocxx::client{mongocxx::uri{}}); diff --git a/examples/api/mongocxx/examples/databases/rc.cpp b/examples/api/mongocxx/examples/databases/rc.cpp index f58f8acb50..6e73ca0387 100644 --- a/examples/api/mongocxx/examples/databases/rc.cpp +++ b/examples/api/mongocxx/examples/databases/rc.cpp @@ -49,7 +49,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/rp.cpp b/examples/api/mongocxx/examples/databases/rp.cpp index 3af6449d2b..f74125072e 100644 --- a/examples/api/mongocxx/examples/databases/rp.cpp +++ b/examples/api/mongocxx/examples/databases/rp.cpp @@ -46,7 +46,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/run_command.cpp b/examples/api/mongocxx/examples/databases/run_command.cpp index 2308eae49d..6901f853ea 100644 --- a/examples/api/mongocxx/examples/databases/run_command.cpp +++ b/examples/api/mongocxx/examples/databases/run_command.cpp @@ -35,7 +35,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/databases/wc.cpp b/examples/api/mongocxx/examples/databases/wc.cpp index 8aa1810524..1709ddd09c 100644 --- a/examples/api/mongocxx/examples/databases/wc.cpp +++ b/examples/api/mongocxx/examples/databases/wc.cpp @@ -52,7 +52,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/instance/basic_usage.cpp b/examples/api/mongocxx/examples/instance/basic_usage.cpp index addfd04c4d..8b6ca85e5d 100644 --- a/examples/api/mongocxx/examples/instance/basic_usage.cpp +++ b/examples/api/mongocxx/examples/instance/basic_usage.cpp @@ -44,7 +44,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_FORKING_COMPONENT() { example(); diff --git a/examples/api/mongocxx/examples/instance/current.cpp b/examples/api/mongocxx/examples/instance/current.cpp index 238e22e7c7..5eebc8dadd 100644 --- a/examples/api/mongocxx/examples/instance/current.cpp +++ b/examples/api/mongocxx/examples/instance/current.cpp @@ -46,7 +46,7 @@ void example() { // other objects with static lifetime being destroyed. // [Example] -} // namespace +} // namespace RUNNER_REGISTER_FORKING_COMPONENT() { example(); diff --git a/examples/api/mongocxx/examples/instance/destroyed.cpp b/examples/api/mongocxx/examples/instance/destroyed.cpp index 06d48f0940..091b13a773 100644 --- a/examples/api/mongocxx/examples/instance/destroyed.cpp +++ b/examples/api/mongocxx/examples/instance/destroyed.cpp @@ -29,24 +29,24 @@ void example() { } try { - mongocxx::instance instance; // Throws. + mongocxx::instance instance; // Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_cannot_recreate_instance); } try { - auto& instance = mongocxx::instance::current(); // Throws. + auto& instance = mongocxx::instance::current(); // Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_instance_destroyed); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_FORKING_COMPONENT() { example(); diff --git a/examples/api/mongocxx/examples/instance/recreation.cpp b/examples/api/mongocxx/examples/instance/recreation.cpp index 0a2e353332..fa43dfc096 100644 --- a/examples/api/mongocxx/examples/instance/recreation.cpp +++ b/examples/api/mongocxx/examples/instance/recreation.cpp @@ -29,10 +29,10 @@ void example() { EXPECT(&mongocxx::instance::current() == &instance); try { - mongocxx::instance another_instance; // Throws. + mongocxx::instance another_instance; // Throws. EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_cannot_recreate_instance); } @@ -41,7 +41,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_FORKING_COMPONENT() { example(); diff --git a/examples/api/mongocxx/examples/logger/basic_usage.cpp b/examples/api/mongocxx/examples/logger/basic_usage.cpp index f773bb86c0..ad446c96f9 100644 --- a/examples/api/mongocxx/examples/logger/basic_usage.cpp +++ b/examples/api/mongocxx/examples/logger/basic_usage.cpp @@ -32,9 +32,10 @@ class example_logger : public mongocxx::logger { public: explicit example_logger(int* ptr) : counter_ptr(ptr) {} - void operator()(mongocxx::log_level level, - bsoncxx::stdx::string_view domain, - bsoncxx::stdx::string_view message) noexcept override { + void operator()( + mongocxx::log_level level, + bsoncxx::stdx::string_view domain, + bsoncxx::stdx::string_view message) noexcept override { EXPECT(level == mongocxx::log_level::k_info); EXPECT(domain == "mongocxx"); EXPECT(message == "libmongoc logging callback enabled"); @@ -56,7 +57,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_FORKING_COMPONENT() { example(); diff --git a/examples/api/mongocxx/examples/logger/to_string.cpp b/examples/api/mongocxx/examples/logger/to_string.cpp index 6f6030477b..6939bfe8f5 100644 --- a/examples/api/mongocxx/examples/logger/to_string.cpp +++ b/examples/api/mongocxx/examples/logger/to_string.cpp @@ -44,7 +44,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_FORKING_COMPONENT() { example(); diff --git a/examples/api/mongocxx/examples/operation_exceptions/operation.cpp b/examples/api/mongocxx/examples/operation_exceptions/operation.cpp index 6d8f4a7df8..7d7f886add 100644 --- a/examples/api/mongocxx/examples/operation_exceptions/operation.cpp +++ b/examples/api/mongocxx/examples/operation_exceptions/operation.cpp @@ -42,9 +42,9 @@ void example(mongocxx::database db) { auto reply = db.run_command(cmd.view()); EXPECT(false && "should not reach this point"); - } catch (const mongocxx::operation_exception& ex) { + } catch (mongocxx::operation_exception const& ex) { EXPECT(ex.code().category() == mongocxx::server_error_category()); - EXPECT(ex.code().value() == 13); // Unauthorized + EXPECT(ex.code().value() == 13); // Unauthorized EXPECT(std::strstr(ex.what(), "admin") != nullptr); if (auto server_error_opt = ex.raw_server_error()) { @@ -64,7 +64,7 @@ void example(mongocxx::database db) { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/operation_exceptions/regular.cpp b/examples/api/mongocxx/examples/operation_exceptions/regular.cpp index 09c20747b6..4e23c6dedc 100644 --- a/examples/api/mongocxx/examples/operation_exceptions/regular.cpp +++ b/examples/api/mongocxx/examples/operation_exceptions/regular.cpp @@ -40,15 +40,15 @@ void example(mongocxx::database db) { auto reply = db.run_command(cmd.view()); EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code().category() == mongocxx::server_error_category()); - EXPECT(ex.code().value() == 13); // Unauthorized + EXPECT(ex.code().value() == 13); // Unauthorized EXPECT(std::strstr(ex.what(), "admin") != nullptr); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_FOR_SINGLE() { mongocxx::client client{mongocxx::uri{}}; diff --git a/examples/api/mongocxx/examples/uri/all_options.cpp b/examples/api/mongocxx/examples/uri/all_options.cpp index 1ccca6b526..08078a8270 100644 --- a/examples/api/mongocxx/examples/uri/all_options.cpp +++ b/examples/api/mongocxx/examples/uri/all_options.cpp @@ -42,7 +42,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/uri/basic_usage.cpp b/examples/api/mongocxx/examples/uri/basic_usage.cpp index 0fc5936bc0..45f265566a 100644 --- a/examples/api/mongocxx/examples/uri/basic_usage.cpp +++ b/examples/api/mongocxx/examples/uri/basic_usage.cpp @@ -21,7 +21,7 @@ namespace { // [Example] void example() { - const auto uri_str = "mongodb://bob:pwd123@localhost:27017/?tls=true"; + auto const uri_str = "mongodb://bob:pwd123@localhost:27017/?tls=true"; mongocxx::uri uri{uri_str}; @@ -33,7 +33,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/uri/default_value.cpp b/examples/api/mongocxx/examples/uri/default_value.cpp index 6a6d46d5e4..6837281c08 100644 --- a/examples/api/mongocxx/examples/uri/default_value.cpp +++ b/examples/api/mongocxx/examples/uri/default_value.cpp @@ -21,7 +21,7 @@ namespace { // [Example] void example() { - const auto uri_str = "mongodb://localhost:27017"; + auto const uri_str = "mongodb://localhost:27017"; mongocxx::uri a; mongocxx::uri b{uri_str}; @@ -33,7 +33,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/uri/hosts.cpp b/examples/api/mongocxx/examples/uri/hosts.cpp index 0b0dc03986..fbac7d4742 100644 --- a/examples/api/mongocxx/examples/uri/hosts.cpp +++ b/examples/api/mongocxx/examples/uri/hosts.cpp @@ -29,25 +29,25 @@ void example() { EXPECT(hosts.size() == 3u); - const mongocxx::uri::host& first = hosts[0]; - const mongocxx::uri::host& second = hosts[1]; - const mongocxx::uri::host& third = hosts[2]; + mongocxx::uri::host const& first = hosts[0]; + mongocxx::uri::host const& second = hosts[1]; + mongocxx::uri::host const& third = hosts[2]; EXPECT(first.name == "127.0.0.1"); EXPECT(first.port == 27017u); - EXPECT(first.family == 0); // AF_UNSPEC (AP_INET). + EXPECT(first.family == 0); // AF_UNSPEC (AP_INET). EXPECT(second.name == "::1"); EXPECT(second.port == 27018u); - EXPECT(second.family != 0); // AF_INET6. + EXPECT(second.family != 0); // AF_INET6. EXPECT(third.name == "/path/to.socket"); EXPECT(third.port == 27019u); - EXPECT(third.family != 0); // AF_UNIX. + EXPECT(third.family != 0); // AF_UNIX. } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/uri/invalid.cpp b/examples/api/mongocxx/examples/uri/invalid.cpp index aab9a60759..5a0c5f226b 100644 --- a/examples/api/mongocxx/examples/uri/invalid.cpp +++ b/examples/api/mongocxx/examples/uri/invalid.cpp @@ -28,7 +28,7 @@ void example() { mongocxx::uri invalid_uri{"invalid"}; EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_uri); } @@ -37,7 +37,7 @@ void example() { mongocxx::uri invalid_uri{"mongodb://localhost:27017/?tls"}; EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_uri); } @@ -46,13 +46,13 @@ void example() { mongocxx::uri invalid_uri{"mongodb://localhost:27017/?authMechanism=SCRAM-SHA-256"}; EXPECT(false && "should not reach this point"); - } catch (const mongocxx::exception& ex) { + } catch (mongocxx::exception const& ex) { EXPECT(ex.code() == mongocxx::error_code::k_invalid_uri); } } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/uri/optional.cpp b/examples/api/mongocxx/examples/uri/optional.cpp index 42e8d461db..b937825156 100644 --- a/examples/api/mongocxx/examples/uri/optional.cpp +++ b/examples/api/mongocxx/examples/uri/optional.cpp @@ -56,7 +56,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/mongocxx/examples/uri/userpass.cpp b/examples/api/mongocxx/examples/uri/userpass.cpp index e9d57df41e..fce23adf7d 100644 --- a/examples/api/mongocxx/examples/uri/userpass.cpp +++ b/examples/api/mongocxx/examples/uri/userpass.cpp @@ -43,7 +43,7 @@ void example() { } // [Example] -} // namespace +} // namespace RUNNER_REGISTER_COMPONENT_WITH_INSTANCE() { example(); diff --git a/examples/api/runner.cpp b/examples/api/runner.cpp index 4a01574ee3..a31719a41f 100644 --- a/examples/api/runner.cpp +++ b/examples/api/runner.cpp @@ -49,7 +49,7 @@ #include -#endif // !defined(_MSC_VER) +#endif // !defined(_MSC_VER) namespace { @@ -59,9 +59,9 @@ class runner_type { struct component { fn_type fn; - const char* name; + char const* name; - component(fn_type f, const char* n) : fn(f), name(n) {} + component(fn_type f, char const* n) : fn(f), name(n) {} }; private: @@ -82,16 +82,16 @@ class runner_type { std::vector filters; bool verbose = false; - static void run_with_jobs(const std::vector& components, unsigned int jobs) { + static void run_with_jobs(std::vector const& components, unsigned int jobs) { if (jobs == 1) { - for (const auto& component : components) { + for (auto const& component : components) { component.fn(); } } else { std::queue threads; // Rudimentary job scheduler. - for (const auto& component : components) { + for (auto const& component : components) { while (threads.size() >= jobs) { threads.front().join(); threads.pop(); @@ -122,40 +122,38 @@ class runner_type { #if !defined(_MSC_VER) // Forking with threads is difficult and the number of components that require forking // are few in number. Run forking components sequentially. - for (const auto& component : forking_components) { - const auto& fn = component.fn; - const auto& name = component.name; + for (auto const& component : forking_components) { + auto const& fn = component.fn; + auto const& name = component.name; - const pid_t pid = ::fork(); + pid_t const pid = ::fork(); // Child: do nothing more than call the registered function. if (pid == 0) { fn(); - return action::return_from_main; // Return from `main()`. + return action::return_from_main; // Return from `main()`. } // Parent: wait for child and handle returned status values. else { int status; - const int ret = ::waitpid(pid, &status, 0); + int const ret = ::waitpid(pid, &status, 0); // 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; } // For unexpected signals, stop immediately. else if (WIFSIGNALED(status)) { - const int signal = WTERMSIG(status); - const char* const sigstr = ::strsignal(signal); + int const signal = WTERMSIG(status); + char const* 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); @@ -169,7 +167,7 @@ class runner_type { } return action::succeed; -#endif // !defined(_MSC_VER) +#endif // !defined(_MSC_VER) } std::cout << "Skipping API examples that require forked processes" << std::endl; @@ -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})")); + auto const 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; @@ -200,34 +197,33 @@ class runner_type { std::cout << "Running API examples against a live single server" << std::endl; 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; + } catch (mongocxx::exception const& ex) { + std::cout << "Skipping API examples that require a live server: " << ex.what() << std::endl; } } public: - void add_component(fn_type fn, const char* name) { + void add_component(fn_type fn, char const* name) { components.emplace_back(fn, name); } - void add_component_with_instance(fn_type fn, const char* name) { + void add_component_with_instance(fn_type fn, char const* name) { components_with_instance.emplace_back(fn, name); } - void add_component_for_single(fn_type fn, const char* name) { + void add_component_for_single(fn_type fn, char const* name) { components_for_single.emplace_back(fn, name); } - void add_component_for_replica(fn_type fn, const char* name) { + void add_component_for_replica(fn_type fn, char const* name) { components_for_replica.emplace_back(fn, name); } - void add_component_for_sharded(fn_type fn, const char* name) { + void add_component_for_sharded(fn_type fn, char const* name) { components_for_sharded.emplace_back(fn, name); } - void add_forking_component(fn_type fn, const char* name) { + void add_forking_component(fn_type fn, char const* name) { forking_components.emplace_back(fn, name); } @@ -247,7 +243,7 @@ class runner_type { this->use_fork = use_fork; } - void add_filter(const char* filter) { + void add_filter(char const* filter) { this->filters.emplace_back(filter); } @@ -273,7 +269,7 @@ class runner_type { // Unconditionally sort to ensure seed consistency after shuffle. for (auto cptr : all_components) { - std::sort(cptr->begin(), cptr->end(), [](const component& lhs, const component& rhs) { + std::sort(cptr->begin(), cptr->end(), [](component const& lhs, component const& rhs) { return std::strcmp(lhs.name, rhs.name) < 0; }); } @@ -281,15 +277,17 @@ class runner_type { // Filter components to be executed to those containing all filter substrings. for (auto filter : filters) { for (auto cptr : all_components) { - cptr->erase(std::remove_if(cptr->begin(), - cptr->end(), - [&filter](component c) { - if (std::strstr(c.name, filter.c_str()) != nullptr) { - return false; - } - return true; - }), - cptr->end()); + cptr->erase( + std::remove_if( + cptr->begin(), + cptr->end(), + [&filter](component c) { + if (std::strstr(c.name, filter.c_str()) != nullptr) { + return false; + } + return true; + }), + cptr->end()); } } @@ -297,12 +295,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, std::vector const* cptr) { return n + cptr->size(); })); for (auto cptr : all_components) { for (auto c : *cptr) { @@ -327,11 +324,11 @@ class runner_type { switch (run_forking_components()) { case action::succeed: - break; // Continue example coverage. + break; // Continue example coverage. case action::fail: - return EXIT_FAILURE; // A component failed. + return EXIT_FAILURE; // A component failed. case action::return_from_main: - return EXIT_SUCCESS; // Return directly from forked processes. + return EXIT_SUCCESS; // Return directly from forked processes. } run_components_with_instance(); @@ -349,11 +346,10 @@ bool parse_seed(int argc, char** argv, int i, bool& set_seed) { return false; } - char* const seed_str = argv[i + 1]; // Next argument. + char* const seed_str = argv[i + 1]; // Next argument. char* end = nullptr; - const auto seed = - static_cast(std::strtoul(seed_str, &end, 10)); + auto const 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; @@ -374,10 +370,10 @@ bool parse_jobs(int argc, char** argv, int i, bool& set_jobs) { return false; } - char* const jobs_str = argv[i + 1]; // Next argument. + char* const jobs_str = argv[i + 1]; // Next argument. char* end = nullptr; - const auto jobs = std::strtoul(jobs_str, &end, 10); + auto const jobs = std::strtoul(jobs_str, &end, 10); if (static_cast(end - jobs_str) != std::strlen(jobs_str)) { std::cerr << "invalid jobs string: " << jobs_str << std::endl; @@ -402,10 +398,10 @@ bool parse_use_fork(int argc, char** argv, int i, bool& set_use_fork) { return false; } - char* const use_fork_str = argv[i + 1]; // Next argument. + char* const use_fork_str = argv[i + 1]; // Next argument. char* end = nullptr; - const auto flag = std::strtoul(use_fork_str, &end, 10); + auto const flag = std::strtoul(use_fork_str, &end, 10); if (static_cast(end - use_fork_str) != std::strlen(use_fork_str)) { std::cerr << "invalid argument: " << use_fork_str << std::endl; @@ -439,10 +435,10 @@ bool parse_verbose(int argc, char** argv, int i) { return false; } - char* const verbose_str = argv[i + 1]; // Next argument. + char* const verbose_str = argv[i + 1]; // Next argument. char* end = nullptr; - const auto verbose = std::strtoul(verbose_str, &end, 10); + auto const verbose = std::strtoul(verbose_str, &end, 10); if (static_cast(end - verbose_str) != std::strlen(verbose_str)) { std::cerr << "invalid verbose string: " << verbose_str << std::endl; @@ -455,29 +451,29 @@ bool parse_verbose(int argc, char** argv, int i) { return true; } -} // namespace +} // namespace -void runner_register_component(void (*fn)(), const char* name) { +void runner_register_component(void (*fn)(), char const* name) { runner.add_component(fn, name); } -void runner_register_component_with_instance(void (*fn)(), const char* name) { +void runner_register_component_with_instance(void (*fn)(), char const* name) { runner.add_component_with_instance(fn, name); } -void runner_register_component_for_single(void (*fn)(), const char* name) { +void runner_register_component_for_single(void (*fn)(), char const* name) { runner.add_component_for_single(fn, name); } -void runner_register_component_for_replica(void (*fn)(), const char* name) { +void runner_register_component_for_replica(void (*fn)(), char const* name) { runner.add_component_for_replica(fn, name); } -void runner_register_component_for_sharded(void (*fn)(), const char* name) { +void runner_register_component_for_sharded(void (*fn)(), char const* name) { runner.add_component_for_sharded(fn, name); } -void runner_register_forking_component(void (*fn)(), const char* name) { +void runner_register_forking_component(void (*fn)(), char const* name) { runner.add_forking_component(fn, name); } @@ -531,5 +527,5 @@ int EXAMPLES_CDECL main(int argc, char** argv) { runner.set_use_fork(true); } - return runner.run(); // Return directly from forked processes. + return runner.run(); // Return directly from forked processes. } diff --git a/examples/api/runner.hh b/examples/api/runner.hh index 684553624b..294a7f33fd 100644 --- a/examples/api/runner.hh +++ b/examples/api/runner.hh @@ -18,45 +18,40 @@ #include -void runner_register_component(void (*fn)(), const char* name); +void runner_register_component(void (*fn)(), char const* name); -void runner_register_component_with_instance(void (*fn)(), const char* name); +void runner_register_component_with_instance(void (*fn)(), char const* name); -void runner_register_component_for_single(void (*fn)(), const char* name); -void runner_register_component_for_replica(void (*fn)(), const char* name); -void runner_register_component_for_sharded(void (*fn)(), const char* name); +void runner_register_component_for_single(void (*fn)(), char const* name); +void runner_register_component_for_replica(void (*fn)(), char const* name); +void runner_register_component_for_sharded(void (*fn)(), char const* name); -void runner_register_forking_component(void (*fn)(), const char* name); +void runner_register_forking_component(void (*fn)(), char const* name); // Defined by examples/CMakeLists.txt. #if !defined(EXAMPLES_COMPONENT_NAME) #error "EXAMPLES_COMPONENT_NAME is not defined!" -#endif // !defined(EXAMPLES_COMPONENT_NAME) +#endif // !defined(EXAMPLES_COMPONENT_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..ae91cbd814 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"); @@ -60,18 +57,18 @@ int EXAMPLES_CDECL main() { using bsoncxx::builder::basic::sub_array; using bsoncxx::builder::basic::sub_document; - doc.append(kvp("subdocument key", - [](sub_document subdoc) { - subdoc.append(kvp("subdoc key", "subdoc value"), - kvp("another subdoc key", types::b_int64{1212})); - }), - kvp("subarray key", [](sub_array subarr) { - // subarrays work similarly - subarr.append(1, types::b_bool{false}, "hello", 5, [](sub_document subdoc) { - // nesting works too! - subdoc.append(kvp("such", "nesting"), kvp("much", "recurse")); - }); - })); + doc.append( + kvp("subdocument key", + [](sub_document subdoc) { + subdoc.append(kvp("subdoc key", "subdoc value"), kvp("another subdoc key", types::b_int64{1212})); + }), + kvp("subarray key", [](sub_array subarr) { + // subarrays work similarly + subarr.append(1, types::b_bool{false}, "hello", 5, [](sub_document subdoc) { + // nesting works too! + subdoc.append(kvp("such", "nesting"), kvp("much", "recurse")); + }); + })); // We can get a view of the resulting bson by calling view() auto v = doc.view(); diff --git a/examples/bsoncxx/builder_core.cpp b/examples/bsoncxx/builder_core.cpp index ae2627ffd9..7da6e37bcf 100644 --- a/examples/bsoncxx/builder_core.cpp +++ b/examples/bsoncxx/builder_core.cpp @@ -61,10 +61,10 @@ int EXAMPLES_CDECL main() { // Appending values is pretty simple. // Just call append() and pass a value wrapped in the corresponding BSON type. - auto array = builder::core{true}; // we are building an array + auto array = builder::core{true}; // we are building an array - array.append(types::b_string{"hello"}); // append a UTF-8 string - array.append(types::b_double{1.234}); // append a double - array.append(types::b_int32{1234}); // append an int32 + array.append(types::b_string{"hello"}); // append a UTF-8 string + array.append(types::b_double{1.234}); // append a double + array.append(types::b_int32{1234}); // append an int32 // ... etc. } diff --git a/examples/bsoncxx/builder_list.cpp b/examples/bsoncxx/builder_list.cpp index b4bb00b091..be11f61d2d 100644 --- a/examples/bsoncxx/builder_list.cpp +++ b/examples/bsoncxx/builder_list.cpp @@ -91,11 +91,12 @@ int EXAMPLES_CDECL main() { // "4" : { "$regex" : "any", "$options" : "imsx" } // } // - arr = {false, - -123, - std::chrono::milliseconds(123456789), - decimal128{100, 200}, - types::bson_value::value("regex", "imsx" /* opts */)}; + arr = { + false, + -123, + std::chrono::milliseconds(123456789), + decimal128{100, 200}, + types::bson_value::value("regex", "imsx" /* opts */)}; // // The list builder will create a BSON document, if possible. Otherwise, it will create a BSON 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/decimal128.cpp b/examples/bsoncxx/decimal128.cpp index 8ba1ec4ca0..7b2fcd07bd 100644 --- a/examples/bsoncxx/decimal128.cpp +++ b/examples/bsoncxx/decimal128.cpp @@ -29,7 +29,7 @@ int EXAMPLES_CDECL main() { decimal128 d128; try { d128 = decimal128{"1.234E+3456"}; - } catch (const bsoncxx::exception&) { + } catch (bsoncxx::exception const&) { // The example won't fail, but in general, arbitrary strings // might not convert properly. return EXIT_FAILURE; diff --git a/examples/bsoncxx/getting_values.cpp b/examples/bsoncxx/getting_values.cpp index b0a9f6c221..36816bf666 100644 --- a/examples/bsoncxx/getting_values.cpp +++ b/examples/bsoncxx/getting_values.cpp @@ -72,7 +72,7 @@ int EXAMPLES_CDECL main() { auto invalid1 = doc["name"]["middle"]; auto invalid2 = doc["contribs"][1000]; if (invalid1 || invalid2) { - BSONCXX_UNREACHABLE; // Not reached. + BSONCXX_UNREACHABLE; // Not reached. } // Similarly, indexed access (either by string or numeric index) into a type that is not @@ -81,7 +81,7 @@ int EXAMPLES_CDECL main() { auto invalid3 = doc["_id"]["invalid"]; auto invalid4 = doc["name"][3]; if (invalid3 || invalid4) { - BSONCXX_UNREACHABLE; // Not reached. + BSONCXX_UNREACHABLE; // Not reached. } // Values are accessed through get_*() methods. @@ -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..241a95b67f 100644 --- a/examples/mongocxx/automatic_client_side_field_level_encryption.cpp +++ b/examples/mongocxx/automatic_client_side_field_level_encryption.cpp @@ -51,12 +51,13 @@ using namespace mongocxx; namespace { -const int kKeyLength = 96; +int const kKeyLength = 96; using ns_pair = std::pair; -void create_json_schema_file(bsoncxx::document::view_or_value kms_providers, - ns_pair key_vault_ns, - class client* key_vault_client) { +void create_json_schema_file( + bsoncxx::document::view_or_value kms_providers, + ns_pair key_vault_ns, + class client* key_vault_client) { options::client_encryption client_encryption_opts{}; client_encryption_opts.key_vault_namespace(std::move(key_vault_ns)); client_encryption_opts.kms_providers(kms_providers); @@ -68,13 +69,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,13 +90,12 @@ 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); } -} // namespace +} // namespace int EXAMPLES_CDECL main() { instance inst{}; @@ -104,14 +103,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 +119,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 +146,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/bulk_write.cpp b/examples/mongocxx/bulk_write.cpp index b31bf2ed57..d270c67e3b 100644 --- a/examples/mongocxx/bulk_write.cpp +++ b/examples/mongocxx/bulk_write.cpp @@ -97,7 +97,7 @@ int EXAMPLES_CDECL main() { } std::cout << "Upserted IDs" << std::endl; - for (const auto& id : result->upserted_ids()) { + for (auto const& id : result->upserted_ids()) { std::cout << "Bulk write index: " << id.first << std::endl << (id.second.get_oid().value.to_string()) << std::endl; } diff --git a/examples/mongocxx/causal_consistency.cpp b/examples/mongocxx/causal_consistency.cpp index 856b4ac2e2..1cda6a3e4b 100644 --- a/examples/mongocxx/causal_consistency.cpp +++ b/examples/mongocxx/causal_consistency.cpp @@ -40,8 +40,8 @@ using bsoncxx::builder::stream::finalize; using bsoncxx::builder::stream::open_document; int EXAMPLES_CDECL main() { - if (const char* const topology_env = std::getenv("MONGOCXX_TEST_TOPOLOGY")) { - const auto topology = std::string(topology_env); + if (char const* const topology_env = std::getenv("MONGOCXX_TEST_TOPOLOGY")) { + auto const topology = std::string(topology_env); if (topology != "replica") { std::cerr << "Skipping: with_transaction example requires a replica set" << std::endl; return 0; @@ -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..b97b6c9b1e 100644 --- a/examples/mongocxx/change_streams.cpp +++ b/examples/mongocxx/change_streams.cpp @@ -35,20 +35,20 @@ namespace { [[noreturn]] void watch_forever(mongocxx::collection& collection) { mongocxx::options::change_stream options; // Wait up to 1 second before polling again. - const std::chrono::milliseconds await_time{1000}; + std::chrono::milliseconds const await_time{1000}; options.max_await_time(await_time); mongocxx::change_stream stream = collection.watch(options); while (true) { - for (const auto& event : stream) { + for (auto const& event : stream) { std::cout << bsoncxx::to_json(event) << std::endl; } std::cout << "No new notifications. Trying again..." << std::endl; } } -} // namespace +} // namespace int EXAMPLES_CDECL main(int argc, char* argv[]) { if (std::getenv("MONGOCXX_TEST_TOPOLOGY")) { @@ -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,13 +107,12 @@ 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); return EXIT_SUCCESS; - } catch (const std::exception& exception) { + } catch (std::exception const& exception) { std::cerr << "Caught exception \"" << exception.what() << "\"" << std::endl; } catch (...) { std::cerr << "Caught unknown exception type" << std::endl; diff --git a/examples/mongocxx/client_session.cpp b/examples/mongocxx/client_session.cpp index db74ed045d..0017029d54 100644 --- a/examples/mongocxx/client_session.cpp +++ b/examples/mongocxx/client_session.cpp @@ -32,8 +32,8 @@ using bsoncxx::builder::basic::make_document; using namespace mongocxx; int EXAMPLES_CDECL main() { - if (const char* const topology_env = std::getenv("MONGOCXX_TEST_TOPOLOGY")) { - const auto topology = std::string(topology_env); + if (char const* const topology_env = std::getenv("MONGOCXX_TEST_TOPOLOGY")) { + auto const topology = std::string(topology_env); if (topology != "replica") { std::cerr << "Skipping: client_session example requires a replica set" << std::endl; return 0; @@ -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/connect.cpp b/examples/mongocxx/connect.cpp index 95587bba88..6a75c9dde2 100644 --- a/examples/mongocxx/connect.cpp +++ b/examples/mongocxx/connect.cpp @@ -34,9 +34,10 @@ class logger final : public mongocxx::logger { public: explicit logger(std::ostream* stream) : _stream(stream) {} - void operator()(mongocxx::log_level level, - bsoncxx::stdx::string_view domain, - bsoncxx::stdx::string_view message) noexcept override { + void operator()( + mongocxx::log_level level, + bsoncxx::stdx::string_view domain, + bsoncxx::stdx::string_view message) noexcept override { if (level >= mongocxx::log_level::k_trace) return; *_stream << '[' << mongocxx::to_string(level) << '@' << domain << "] " << message << '\n'; @@ -51,7 +52,7 @@ std::unique_ptr make_logger() { return std::unique_ptr(new logger(&std::cout)); } -} // namespace +} // namespace int EXAMPLES_CDECL main(int argc, char* argv[]) { using bsoncxx::builder::basic::kvp; @@ -63,7 +64,7 @@ int EXAMPLES_CDECL main(int argc, char* argv[]) { mongocxx::instance inst{make_logger()}; try { - const auto uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri}; + auto const uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri}; mongocxx::options::client client_options; if (uri.tls()) { @@ -90,7 +91,7 @@ int EXAMPLES_CDECL main(int argc, char* argv[]) { return EXIT_SUCCESS; - } catch (const std::exception& xcp) { + } catch (std::exception const& xcp) { std::cout << "connection failed: " << xcp.what() << "\n"; return EXIT_FAILURE; } diff --git a/examples/mongocxx/create.cpp b/examples/mongocxx/create.cpp index f2730ccd21..a04da81f08 100644 --- a/examples/mongocxx/create.cpp +++ b/examples/mongocxx/create.cpp @@ -42,17 +42,19 @@ int EXAMPLES_CDECL main() { bsoncxx::document::value restaurant_doc = make_document( kvp("address", - make_document(kvp("street", "2 Avenue"), - kvp("zipcode", 10075), - kvp("building", "1480"), - kvp("coord", make_array(-73.9557413, 40.7720266)))), + make_document( + kvp("street", "2 Avenue"), + kvp("zipcode", 10075), + kvp("building", "1480"), + kvp("coord", make_array(-73.9557413, 40.7720266)))), 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{12323}}), + kvp("grade", "A"), + kvp("score", 11)), make_document( kvp("date", bsoncxx::types::b_date{std::chrono::milliseconds{121212}}), kvp("grade", "B"), diff --git a/examples/mongocxx/document_validation.cpp b/examples/mongocxx/document_validation.cpp index 7b864c1484..9f44e0324f 100644 --- a/examples/mongocxx/document_validation.cpp +++ b/examples/mongocxx/document_validation.cpp @@ -50,24 +50,20 @@ 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; - } catch (const mongocxx::exception& e) { + } catch (mongocxx::exception const& e) { std::cout << "Some zombie needs to eat more brains:" << std::endl; std::cout << e.what() << std::endl; } diff --git a/examples/mongocxx/exception.cpp b/examples/mongocxx/exception.cpp index fd5607391c..fc9ca0f078 100644 --- a/examples/mongocxx/exception.cpp +++ b/examples/mongocxx/exception.cpp @@ -38,7 +38,7 @@ int EXAMPLES_CDECL main() { // from causing build failures. There is currently no way to specify // IgnoreStandardErrorWarningFormat=true via CMake or CLI. See: // https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-diagnostic-format-for-tasksIgnoreStandardErrorWarningFormat - const bool print_error_messages = std::getenv("MONGOCXX_TEST_TOPOLOGY") == nullptr; + bool const print_error_messages = std::getenv("MONGOCXX_TEST_TOPOLOGY") == nullptr; // The mongocxx::instance constructor and destructor initialize and shut down the driver, // respectively. Therefore, a mongocxx::instance must be created before using the driver and @@ -51,7 +51,7 @@ int EXAMPLES_CDECL main() { mongocxx::collection coll; try { coll.name(); - } catch (const mongocxx::logic_error& e) { + } catch (mongocxx::logic_error const& e) { std::cout << "Using an uninitialized collection throws:" << std::endl; // Local errors, like those generated by mis-use of the @@ -84,7 +84,7 @@ int EXAMPLES_CDECL main() { coll.drop(); try { coll.rename("coll2"); - } catch (const mongocxx::operation_exception& e) { + } catch (mongocxx::operation_exception const& e) { std::cout << "Renaming a collection that does not exist throws:" << std::endl; // We expect this error to arise from the server @@ -128,7 +128,7 @@ int EXAMPLES_CDECL main() { coll.insert_one(doc.view()); try { coll.insert_one(doc.view()); - } catch (const mongocxx::bulk_write_exception& e) { + } catch (mongocxx::bulk_write_exception const& e) { std::cout << "Adding a document whose _id is already present throws:" << std::endl; // We expect this error to arise from the server diff --git a/examples/mongocxx/explicit_encryption.cpp b/examples/mongocxx/explicit_encryption.cpp index 617f53453d..0ddeb887e6 100644 --- a/examples/mongocxx/explicit_encryption.cpp +++ b/examples/mongocxx/explicit_encryption.cpp @@ -46,7 +46,7 @@ using bsoncxx::types::bson_value::make_value; using namespace mongocxx; -const int kKeyLength = 96; +int const kKeyLength = 96; int EXAMPLES_CDECL main() { instance inst{}; @@ -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..b65fb1cc0a 100644 --- a/examples/mongocxx/explicit_encryption_auto_decryption.cpp +++ b/examples/mongocxx/explicit_encryption_auto_decryption.cpp @@ -46,7 +46,7 @@ using bsoncxx::types::bson_value::make_value; using namespace mongocxx; -const int kKeyLength = 96; +int const kKeyLength = 96; int EXAMPLES_CDECL main() { instance inst{}; @@ -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..9253a30b2a 100644 --- a/examples/mongocxx/get_values_from_documents.cpp +++ b/examples/mongocxx/get_values_from_documents.cpp @@ -51,22 +51,23 @@ 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)); } // Iterate over contents of messagelist. -void iterate_messagelist(const bsoncxx::document::element& ele) { +void iterate_messagelist(bsoncxx::document::element const& ele) { // Check validity and type before trying to iterate. if (ele.type() == type::k_array) { bsoncxx::array::view subarray{ele.get_array().value}; - for (const bsoncxx::array::element& message : subarray) { + for (bsoncxx::array::element const& message : subarray) { // Check correct type before trying to access elements. // Only print out fields if they exist; don't report missing fields. if (message.type() == type::k_document) { @@ -93,7 +94,7 @@ void iterate_messagelist(const bsoncxx::document::element& ele) { } // Print document parts to standard output. -void print_document(const bsoncxx::document::view& doc) { +void print_document(bsoncxx::document::view const& doc) { // Extract _id element as a string. bsoncxx::document::element id_ele = doc["_id"]; if (id_ele.type() == type::k_oid) { @@ -118,12 +119,12 @@ void iterate_documents(mongocxx::collection& coll) { mongocxx::cursor cursor = coll.find({}); // Iterate the cursor into bsoncxx::document::view objects. - for (const bsoncxx::document::view& doc : cursor) { + for (bsoncxx::document::view const& doc : cursor) { print_document(doc); } } -} // namespace +} // namespace int EXAMPLES_CDECL main() { // The mongocxx::instance constructor and destructor initialize and shut down the driver, 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..5e0444958e 100644 --- a/examples/mongocxx/index.cpp +++ b/examples/mongocxx/index.cpp @@ -34,7 +34,7 @@ int EXAMPLES_CDECL main() { auto db = conn["test"]; try { db["restaurants"].drop(); - } catch (const std::exception&) { + } catch (std::exception const&) { // Collection did not exist. } @@ -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/inserted_id.cpp b/examples/mongocxx/inserted_id.cpp index 15a2786adb..e7c7023799 100644 --- a/examples/mongocxx/inserted_id.cpp +++ b/examples/mongocxx/inserted_id.cpp @@ -51,7 +51,7 @@ int EXAMPLES_CDECL main() { } else { std::cout << "Inserted id was not an OID type" << std::endl; } - } catch (const mongocxx::exception& e) { + } catch (mongocxx::exception const& e) { std::cout << "An exception occurred: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/examples/mongocxx/instance_management.cpp b/examples/mongocxx/instance_management.cpp index 73d0d20cbf..e987ef4d48 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))); @@ -94,7 +92,7 @@ bool do_work() { return true; } -} // namespace +} // namespace int EXAMPLES_CDECL main(int argc, char* argv[]) { auto uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri}; diff --git a/examples/mongocxx/mongodb.com/aggregation_examples.cpp b/examples/mongocxx/mongodb.com/aggregation_examples.cpp index 30657bae73..74e899b2d1 100644 --- a/examples/mongocxx/mongodb.com/aggregation_examples.cpp +++ b/examples/mongocxx/mongodb.com/aggregation_examples.cpp @@ -33,7 +33,7 @@ using namespace mongocxx; namespace { -void aggregation_examples(const mongocxx::database& db) { +void aggregation_examples(mongocxx::database const& db) { { // Start Aggregation Example 1 using namespace bsoncxx::builder::basic; @@ -61,8 +61,7 @@ void aggregation_examples(const mongocxx::database& db) { 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.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,9 +84,7 @@ 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), @@ -117,23 +114,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 @@ -145,23 +139,23 @@ void aggregation_examples(const mongocxx::database& db) { } } -} // namespace +} // namespace int EXAMPLES_CDECL main() { // The mongocxx::instance constructor and destructor initialize and shut down the driver, // respectively. Therefore, a mongocxx::instance must be created before using the driver and // must remain alive for as long as the driver is in use. - const mongocxx::instance inst{}; + mongocxx::instance const inst{}; - const mongocxx::client conn{mongocxx::uri{}}; - const auto db = conn["documentation_examples"]; + mongocxx::client const conn{mongocxx::uri{}}; + auto const db = conn["documentation_examples"]; // SERVER-79306: Ensure the database exists for consistent behavior with sharded clusters. conn["documentation_examples"].create_collection("dummy"); try { aggregation_examples(db); - } catch (const std::logic_error& e) { + } catch (std::logic_error const& e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/examples/mongocxx/mongodb.com/documentation_examples.cpp b/examples/mongocxx/mongodb.com/documentation_examples.cpp index ff1d20ac2d..8aa0c76ec7 100644 --- a/examples/mongocxx/mongodb.com/documentation_examples.cpp +++ b/examples/mongocxx/mongodb.com/documentation_examples.cpp @@ -39,55 +39,50 @@ 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( + T const& document, + char const* field, + bool should_have, + int example_no, + char const* 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); } } } template -void check_has_field(const T& document, const char* field, int example_no) { +void check_has_field(T const& document, char const* field, int example_no) { check_field(document, field, true, example_no); } template -void check_has_no_field(const T& document, const char* field, int example_no) { +void check_has_no_field(T const& document, char const* field, int example_no) { check_field(document, field, false, example_no); } template -void check_has_field(const T& document, - const char* field, - int example_no, - const char* example_type) { +void check_has_field(T const& document, char const* field, int example_no, char const* 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(T const& document, char const* field, int example_no, char const* example_type) { check_field(document, field, false, example_no, example_type); } bool should_run_client_side_encryption_test(void) { - const char* const vars[] = { + char const* const vars[] = { "MONGOCXX_TEST_AWS_SECRET_ACCESS_KEY", "MONGOCXX_TEST_AWS_ACCESS_KEY_ID", "MONGOCXX_TEST_AZURE_TENANT_ID", @@ -99,12 +94,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); }); + auto const iter = + std::find_if_not(std::begin(vars), std::end(vars), [](char const* 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; } @@ -112,18 +107,17 @@ bool should_run_client_side_encryption_test(void) { } mongocxx::options::client add_test_server_api(mongocxx::options::client opts = {}) { - const auto api_version = std::getenv("MONGODB_API_VERSION"); + auto const api_version = std::getenv("MONGODB_API_VERSION"); if (!api_version) { return opts; } - const auto api_version_sv = bsoncxx::stdx::string_view(api_version); + auto const api_version_sv = bsoncxx::stdx::string_view(api_version); 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)); } @@ -132,8 +126,8 @@ mongocxx::options::client add_test_server_api(mongocxx::options::client opts = { return opts; } -std::string getenv_or_fail(const char* s) { - const char* env = std::getenv(s); +std::string getenv_or_fail(char const* s) { + char const* env = std::getenv(s); if (!env) { throw std::runtime_error("missing a required environment variable: " + std::string(s)); } @@ -155,7 +149,7 @@ bsoncxx::document::value make_kms_doc(bool include_external = true) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - const uint8_t kLocalMasterKey[] = + uint8_t const kLocalMasterKey[] = "\x32\x78\x34\x34\x2b\x78\x64\x75\x54\x61\x42\x42\x6b\x59\x31\x36\x45\x72" "\x35\x44\x75\x41\x44\x61\x67\x68\x76\x53\x34\x76\x77\x64\x6b\x67\x38\x74" "\x70\x50\x70\x33\x74\x7a\x36\x67\x56\x30\x31\x41\x31\x43\x77\x62\x44\x39" @@ -169,8 +163,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,21 +178,17 @@ 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()}; } -static bsoncxx::document::value get_is_master(const mongocxx::client& client) { +static bsoncxx::document::value get_is_master(mongocxx::client const& client) { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; @@ -207,15 +196,12 @@ static bsoncxx::document::value get_is_master(const mongocxx::client& client) { return reply; } -static bool is_replica_set(const mongocxx::client& client) { +static bool is_replica_set(mongocxx::client const& client) { auto reply = get_is_master(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 +225,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]) { @@ -293,10 +278,11 @@ void insert_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; std::vector docs{ - make_document(kvp("item", "journal"), - 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", "journal"), + 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), @@ -327,18 +313,21 @@ void query_top_level_fields_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; std::vector docs{ - 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", "notebook"), - kvp("qty", 50), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("status", "A")), - make_document(kvp("item", "paper"), - kvp("qty", 100), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("status", "D")), + 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", "notebook"), + kvp("qty", 50), + kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), + kvp("status", "A")), + make_document( + kvp("item", "paper"), + 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), @@ -388,8 +377,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 +391,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 +406,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) { @@ -437,8 +425,9 @@ void query_top_level_fields_examples(mongocxx::database db) { 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"})))))); + 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) { @@ -456,18 +445,21 @@ void query_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; std::vector docs{ - 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", "notebook"), - kvp("qty", 50), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("status", "A")), - make_document(kvp("item", "paper"), - kvp("qty", 100), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("status", "D")), + 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", "notebook"), + kvp("qty", 50), + kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), + kvp("status", "A")), + make_document( + kvp("item", "paper"), + 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), @@ -493,8 +485,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 +499,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 +526,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 +539,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) { @@ -570,26 +559,31 @@ void query_arrays_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; std::vector docs{ - make_document(kvp("item", "journal"), - kvp("qty", 25), - kvp("tags", make_array("blank", "red")), - kvp("dim_cm", make_array(14, 21))), - make_document(kvp("item", "notebook"), - kvp("qty", 50), - kvp("tags", make_array("red", "blank")), - kvp("dim_cm", make_array(14, 21))), - make_document(kvp("item", "paper"), - kvp("qty", 100), - kvp("tags", make_array("red", "blank", "plain")), - kvp("dim_cm", make_array(14, 21))), - make_document(kvp("item", "planner"), - kvp("qty", 75), - kvp("tags", make_array("blank", "red")), - kvp("dim_cm", make_array(22.85, 30))), - make_document(kvp("item", "postcard"), - kvp("qty", 45), - kvp("tags", make_array("blue")), - kvp("dim_cm", make_array(10, 15.25))), + make_document( + kvp("item", "journal"), + kvp("qty", 25), + kvp("tags", make_array("blank", "red")), + kvp("dim_cm", make_array(14, 21))), + make_document( + kvp("item", "notebook"), + kvp("qty", 50), + kvp("tags", make_array("red", "blank")), + kvp("dim_cm", make_array(14, 21))), + make_document( + kvp("item", "paper"), + kvp("qty", 100), + kvp("tags", make_array("red", "blank", "plain")), + kvp("dim_cm", make_array(14, 21))), + make_document( + kvp("item", "planner"), + kvp("qty", 75), + kvp("tags", make_array("blank", "red")), + kvp("dim_cm", make_array(22.85, 30))), + make_document( + kvp("item", "postcard"), + kvp("qty", 45), + kvp("tags", make_array("blue")), + kvp("dim_cm", make_array(10, 15.25))), }; db["inventory"].insert_many(docs); @@ -620,8 +614,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 +641,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 +654,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 +668,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 +681,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 +694,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) { @@ -724,25 +713,33 @@ void query_array_embedded_documents_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; std::vector docs{ - make_document(kvp("item", "journal"), - kvp("instock", - make_array(make_document(kvp("warehouse", "A"), kvp("qty", 5)), - make_document(kvp("warehouse", "C"), kvp("qty", 15))))), + make_document( + kvp("item", "journal"), + 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", "paper"), - kvp("instock", - make_array(make_document(kvp("warehouse", "A"), kvp("qty", 60)), - make_document(kvp("warehouse", "B"), kvp("qty", 15))))), - make_document(kvp("item", "planner"), - kvp("instock", - make_array(make_document(kvp("warehouse", "A"), kvp("qty", 40)), - make_document(kvp("warehouse", "B"), kvp("qty", 5))))), - make_document(kvp("item", "postcard"), - kvp("instock", - make_array(make_document(kvp("warehouse", "B"), kvp("qty", 15)), - make_document(kvp("warehouse", "C"), kvp("qty", 35))))), + make_document( + kvp("item", "paper"), + kvp("instock", + make_array( + make_document(kvp("warehouse", "A"), kvp("qty", 60)), + make_document(kvp("warehouse", "B"), kvp("qty", 15))))), + make_document( + kvp("item", "planner"), + kvp("instock", + make_array( + make_document(kvp("warehouse", "A"), kvp("qty", 40)), + make_document(kvp("warehouse", "B"), kvp("qty", 5))))), + make_document( + kvp("item", "postcard"), + 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); @@ -758,8 +755,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 +769,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 +783,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 +796,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 +810,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 +825,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 +839,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 +853,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 +901,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 +914,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) { @@ -969,8 +958,9 @@ void projection_insertion_example(mongocxx::database db) { 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_array( + make_document(kvp("warehouse", "B"), kvp("qty", 15)), + make_document(kvp("warehouse", "C"), kvp("qty", 35))))), }; db["inventory"].insert_many(docs); @@ -1022,9 +1012,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 +1031,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 +1050,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) { @@ -1087,8 +1076,7 @@ void projection_examples(mongocxx::database db) { 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)))); + make_document(kvp("status", "A")), mongocxx::options::find{}.projection(make_document(kvp("size.uom", 0)))); // End Example 48 for (auto&& document : cursor) { @@ -1111,10 +1099,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.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 +1126,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) { @@ -1180,29 +1167,26 @@ void projection_with_aggregation_example(mongocxx::database db) { kvp("_id", 0), kvp("item", 1), kvp("status", - make_document(kvp( - "$switch", - 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")))), - kvp("default", "No status found"))))), + make_document( + kvp("$switch", + 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")))), + 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_document( + kvp("$concat", + 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 @@ -1232,10 +1216,11 @@ void update_examples(mongocxx::database db) { 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", "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), @@ -1246,14 +1231,16 @@ void update_examples(mongocxx::database db) { 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"))), - kvp("status", "P")), - make_document(kvp("item", "paper"), - kvp("qty", 100), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("status", "D")), + make_document( + kvp("item", "notebook"), + kvp("qty", 50), + kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), + kvp("status", "P")), + make_document( + kvp("item", "paper"), + 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), @@ -1264,10 +1251,11 @@ void update_examples(mongocxx::database db) { 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", "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), @@ -1290,13 +1278,13 @@ void update_examples(mongocxx::database db) { 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))))); + 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"}) { @@ -1313,14 +1301,13 @@ void update_examples(mongocxx::database db) { 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))))); + 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"}) { @@ -1338,10 +1325,12 @@ void update_examples(mongocxx::database db) { db["inventory"].replace_one( make_document(kvp("item", "paper")), - make_document(kvp("item", "paper"), - kvp("instock", - make_array(make_document(kvp("warehouse", "A"), kvp("qty", 60)), - make_document(kvp("warehouse", "B"), kvp("qty", 40)))))); + make_document( + kvp("item", "paper"), + kvp("instock", + make_array( + make_document(kvp("warehouse", "A"), kvp("qty", 60)), + make_document(kvp("warehouse", "B"), kvp("qty", 40)))))); // End Example 54 for (auto&& document : db["inventory"].find(make_document(kvp("item", "paper")))) { @@ -1370,18 +1359,21 @@ void delete_examples(mongocxx::database db) { using bsoncxx::builder::basic::make_document; std::vector docs{ - 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", "notebook"), - kvp("qty", 50), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("status", "P")), - make_document(kvp("item", "paper"), - kvp("qty", 100), - kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), - kvp("status", "D")), + 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", "notebook"), + kvp("qty", 50), + kvp("size", make_document(kvp("h", 8.5), kvp("w", 11), kvp("uom", "in"))), + kvp("status", "P")), + make_document( + kvp("item", "paper"), + 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), @@ -1449,8 +1441,8 @@ static bool is_snapshot_ready(mongocxx::client& client, mongocxx::collection& co if (collection.find_one(session, {})) { return true; } - } catch (const mongocxx::operation_exception& e) { - if (e.code().value() == 246) { // snapshot unavailable + } catch (mongocxx::operation_exception const& e) { + if (e.code().value() == 246) { // snapshot unavailable return false; } throw; @@ -1462,8 +1454,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 (;;) { @@ -1471,11 +1462,11 @@ static void wait_for_snapshot_ready(mongocxx::client& client, for (auto& collection : collections) { if (!is_snapshot_ready(client, collection)) { is_ready = false; - break; // inner + break; // inner } } if (is_ready) { - break; // outer + break; // outer } else { std::this_thread::sleep_for(std::chrono::seconds(sleep_time++)); } @@ -1551,8 +1542,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 +1563,13 @@ 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); @@ -1588,8 +1579,8 @@ static void snapshot_example2(mongocxx::client& client) { // End Snapshot Query Example 2 if (total_daily_sales != 1) { - throw std::logic_error("wrong number of total sales in example 60, expecting 1 got: " + - std::to_string(total_daily_sales)); + throw std::logic_error( + "wrong number of total sales in example 60, expecting 1 got: " + std::to_string(total_daily_sales)); } } @@ -1626,13 +1617,13 @@ 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 +1634,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 +1651,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(); @@ -1700,7 +1688,7 @@ static void queryable_encryption_api(mongocxx::client& client) { // End Queryable Encryption Example } -} // namespace +} // namespace int EXAMPLES_CDECL main() { // The mongocxx::instance constructor and destructor initialize and shut down the driver, @@ -1726,11 +1714,10 @@ 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) { + } catch (std::logic_error const& e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/examples/mongocxx/mongodb.com/index_examples.cpp b/examples/mongocxx/mongodb.com/index_examples.cpp index ecbf1b2b2c..94cd69f84a 100644 --- a/examples/mongocxx/mongodb.com/index_examples.cpp +++ b/examples/mongocxx/mongodb.com/index_examples.cpp @@ -22,7 +22,7 @@ namespace { -void index_examples(const mongocxx::database& db) { +void index_examples(mongocxx::database const& db) { { // Start Index Example 1 using namespace bsoncxx::builder::basic; @@ -35,22 +35,21 @@ 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 } } -} // namespace +} // namespace int EXAMPLES_CDECL main() { // The mongocxx::instance constructor and destructor initialize and shut down the driver, // respectively. Therefore, a mongocxx::instance must be created before using the driver and // must remain alive for as long as the driver is in use. - const mongocxx::instance inst{}; + mongocxx::instance const inst{}; - const mongocxx::client conn{mongocxx::uri{}}; - const auto db = conn["documentation_examples"]; + mongocxx::client const conn{mongocxx::uri{}}; + auto const db = conn["documentation_examples"]; index_examples(db); return EXIT_SUCCESS; diff --git a/examples/mongocxx/mongodb.com/runcommand_examples.cpp b/examples/mongocxx/mongodb.com/runcommand_examples.cpp index def0183b77..b86e249e4c 100644 --- a/examples/mongocxx/mongodb.com/runcommand_examples.cpp +++ b/examples/mongocxx/mongodb.com/runcommand_examples.cpp @@ -37,20 +37,20 @@ void runcommand_examples(mongocxx::database& db) { } } -} // namespace +} // namespace int EXAMPLES_CDECL main() { // The mongocxx::instance constructor and destructor initialize and shut down the driver, // respectively. Therefore, a mongocxx::instance must be created before using the driver and // must remain alive for as long as the driver is in use. - const mongocxx::instance inst{}; + mongocxx::instance const inst{}; - const mongocxx::client conn{mongocxx::uri{}}; + mongocxx::client const conn{mongocxx::uri{}}; auto db = conn["documentation_examples"]; try { runcommand_examples(db); - } catch (const std::logic_error& e) { + } catch (std::logic_error const& e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/examples/mongocxx/mongodb.com/usage_overview.cpp b/examples/mongocxx/mongodb.com/usage_overview.cpp index 62652973bb..f98c8515ed 100644 --- a/examples/mongocxx/mongodb.com/usage_overview.cpp +++ b/examples/mongocxx/mongodb.com/usage_overview.cpp @@ -41,39 +41,37 @@ int EXAMPLES_CDECL main() { // 2. Insert using bsoncxx::builder::basic::kvp; bsoncxx::builder::basic::document doc1; - doc1.append(kvp("name", "Sun Bakery Trattoria"), - kvp("stars", 4), - kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { - arr.append("Pizza", "Pasta", "Italian", "Coffee", "Sandwiches"); - })); + doc1.append( + kvp("name", "Sun Bakery Trattoria"), + kvp("stars", 4), + kvp("categories", [](bsoncxx::builder::basic::sub_array arr) { + arr.append("Pizza", "Pasta", "Italian", "Coffee", "Sandwiches"); + })); 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"); - })); + doc2.append( + kvp("name", "Blue Bagels Grill"), + kvp("stars", 3), + 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 +98,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..26b88ebf17 100644 --- a/examples/mongocxx/server_side_field_level_encryption_enforcement.cpp +++ b/examples/mongocxx/server_side_field_level_encryption_enforcement.cpp @@ -48,7 +48,7 @@ using bsoncxx::types::bson_value::make_value; using namespace mongocxx; -const int kKeyLength = 96; +int const kKeyLength = 96; int EXAMPLES_CDECL main() { instance inst{}; @@ -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"]; @@ -143,7 +138,7 @@ int EXAMPLES_CDECL main() { // Inserting via the unencrypted client fails, because the server // requires that the encryptedField actually be encrypted. unencrypted_client["test"]["coll"].insert_one(to_insert.view()); - } catch (const std::exception& e) { + } catch (std::exception const& e) { std::cout << "Unencrypted insert failed: " << e.what() << std::endl; } } diff --git a/examples/mongocxx/tailable_cursor.cpp b/examples/mongocxx/tailable_cursor.cpp index c06f9e8bcd..35d70e6c51 100644 --- a/examples/mongocxx/tailable_cursor.cpp +++ b/examples/mongocxx/tailable_cursor.cpp @@ -73,7 +73,7 @@ void insert_docs(mongocxx::collection* coll) { } } -} // namespace +} // namespace int EXAMPLES_CDECL main() { // The mongocxx::instance constructor and destructor initialize and shut down the driver, diff --git a/examples/mongocxx/tutorial.cpp b/examples/mongocxx/tutorial.cpp index 2158dd7a8a..ae2e617fd0 100644 --- a/examples/mongocxx/tutorial.cpp +++ b/examples/mongocxx/tutorial.cpp @@ -34,7 +34,7 @@ using bsoncxx::builder::basic::make_array; using bsoncxx::builder::basic::make_document; int EXAMPLES_CDECL main() { - mongocxx::instance instance{}; // This should be done only once. + mongocxx::instance instance{}; // This should be done only once. mongocxx::uri uri("mongodb://localhost:27017"); mongocxx::client client(uri); @@ -53,14 +53,14 @@ int EXAMPLES_CDECL main() { auto doc_view = doc_value.view(); auto element = doc_view["name"]; assert(element.type() == bsoncxx::type::k_string); - auto name = element.get_string().value; // For C++ driver version < 3.7.0, use get_utf8() + auto name = element.get_string().value; // For C++ driver version < 3.7.0, use get_utf8() assert(name == "MongoDB"); } // Insert One Document: { "i": 0 } { auto insert_one_result = collection.insert_one(make_document(kvp("i", 0))); - assert(insert_one_result); // Acknowledged writes return results. + assert(insert_one_result); // Acknowledged writes return results. auto doc_id = insert_one_result->inserted_id(); assert(doc_id.type() == bsoncxx::type::k_oid); } @@ -72,7 +72,7 @@ int EXAMPLES_CDECL main() { documents.push_back(make_document(kvp("i", 2))); auto insert_many_result = collection.insert_many(documents); - assert(insert_many_result); // Acknowledged writes return results. + assert(insert_many_result); // Acknowledged writes return results. auto doc0_id = insert_many_result->inserted_ids().at(0); auto doc1_id = insert_many_result->inserted_ids().at(1); assert(doc0_id.type() == bsoncxx::type::k_oid); @@ -100,8 +100,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 +117,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,34 +126,32 @@ 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"))))); - assert(update_one_result); // Acknowledged writes return results. + 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"))))); - assert(update_many_result); // Acknowledged writes return results. + 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); } // Delete a Single Document { auto delete_one_result = collection.delete_one(make_document(kvp("i", 0))); - assert(delete_one_result); // Acknowledged writes return results. + assert(delete_one_result); // Acknowledged writes return results. assert(delete_one_result->deleted_count() == 1); } // Delete All Documents That Match a Filter { - auto delete_many_result = - collection.delete_many(make_document(kvp("i", make_document(kvp("$gt", 0))))); - assert(delete_many_result); // Acknowledged writes return results. + 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..c1a62d3179 100644 --- a/examples/mongocxx/update.cpp +++ b/examples/mongocxx/update.cpp @@ -39,8 +39,9 @@ int EXAMPLES_CDECL main() { { 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))))); + 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. @@ -54,19 +55,22 @@ int EXAMPLES_CDECL main() { { db["restaurants"].update_many( make_document(kvp("address.zipcode", "10016"), kvp("cuisine", "Other")), - make_document(kvp("$set", make_document(kvp("cuisine", "Category to be determined"))), - kvp("$currentDate", make_document(kvp("lastModified", true))))); + make_document( + kvp("$set", make_document(kvp("cuisine", "Category to be determined"))), + kvp("$currentDate", make_document(kvp("lastModified", true))))); } // 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"))))); + 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/examples/mongocxx/with_transaction.cpp b/examples/mongocxx/with_transaction.cpp index e81af94817..e07779bf1f 100644 --- a/examples/mongocxx/with_transaction.cpp +++ b/examples/mongocxx/with_transaction.cpp @@ -43,8 +43,8 @@ using namespace mongocxx; // conveniently run a custom callback inside of a transaction. // int EXAMPLES_CDECL main() { - if (const char* const topology_env = std::getenv("MONGOCXX_TEST_TOPOLOGY")) { - const auto topology = std::string(topology_env); + if (char const* const topology_env = std::getenv("MONGOCXX_TEST_TOPOLOGY")) { + auto const topology = std::string(topology_env); if (topology != "replica") { std::cerr << "Skipping: with_transaction example requires a replica set" << std::endl; return 0; @@ -82,7 +82,7 @@ int EXAMPLES_CDECL main() { foo.insert_one(make_document(kvp("abc", 0)), opts); bar.insert_one(make_document(kvp("xyz", 0)), opts); - } catch (const mongocxx::exception& e) { + } catch (mongocxx::exception const& e) { std::cout << "An exception occurred while inserting: " << e.what() << std::endl; return EXIT_FAILURE; } @@ -105,7 +105,7 @@ int EXAMPLES_CDECL main() { opts.write_concern(wc_majority); session.with_transaction(callback, opts); - } catch (const mongocxx::exception& e) { + } catch (mongocxx::exception const& e) { std::cout << "An exception occurred: " << e.what() << std::endl; return EXIT_FAILURE; } diff --git a/examples/projects/mongocxx/hello_mongocxx.cpp b/examples/projects/mongocxx/hello_mongocxx.cpp index e45731245c..de6dffa13b 100644 --- a/examples/projects/mongocxx/hello_mongocxx.cpp +++ b/examples/projects/mongocxx/hello_mongocxx.cpp @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) { mongocxx::instance inst; try { - const auto uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri}; + auto const uri = mongocxx::uri{(argc >= 2) ? argv[1] : mongocxx::uri::k_default_uri}; auto client = mongocxx::client{uri}; auto admin = client["admin"]; @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) { std::cout << bsoncxx::to_json(result) << std::endl; return EXIT_SUCCESS; - } catch (const std::exception& xcp) { + } catch (std::exception const& xcp) { std::cout << "connection failed: " << xcp.what() << std::endl; return EXIT_FAILURE; } diff --git a/src/bsoncxx/include/bsoncxx/doc.hpp b/src/bsoncxx/include/bsoncxx/doc.hpp index 4c14a21b7a..42b46dac9a 100644 --- a/src/bsoncxx/include/bsoncxx/doc.hpp +++ b/src/bsoncxx/include/bsoncxx/doc.hpp @@ -14,7 +14,7 @@ #if !defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) #error "This file is for documentation purposes only. It should not be included." -#endif // !defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) +#endif // !defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element-fwd.hpp index 9c8597ebd9..21d6f78394 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element-fwd.hpp @@ -22,17 +22,17 @@ namespace array { class element; -} // namespace array -} // namespace v_noabi -} // namespace bsoncxx +} // namespace array +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace array { using ::bsoncxx::v_noabi::array::element; -} // namespace array -} // namespace bsoncxx +} // namespace array +} // namespace bsoncxx #include 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 46743e7db6..2967978f99 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp @@ -79,12 +79,9 @@ 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(std::uint8_t const* raw, std::uint32_t length, std::uint32_t offset, std::uint32_t keylen); - explicit element(const stdx::string_view key); + explicit element(stdx::string_view const key); }; /// @@ -95,23 +92,23 @@ class element : private document::element { /// @{ /// @relatesalso bsoncxx::v_noabi::array::element -BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const element& elem, const types::bson_value::view& v); +BSONCXX_ABI_EXPORT_CDECL(bool) operator==(element const& elem, types::bson_value::view const& v); /// @relatesalso bsoncxx::v_noabi::array::element -BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const types::bson_value::view& v, const element& elem); +BSONCXX_ABI_EXPORT_CDECL(bool) operator==(types::bson_value::view const& v, element const& elem); /// @relatesalso bsoncxx::v_noabi::array::element -BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const element& elem, const types::bson_value::view& v); +BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(element const& elem, types::bson_value::view const& v); /// @relatesalso bsoncxx::v_noabi::array::element -BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const types::bson_value::view& v, const element& elem); +BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(types::bson_value::view const& v, element const& elem); /// @} /// -} // namespace array -} // namespace v_noabi -} // namespace bsoncxx +} // namespace array +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace array { @@ -119,8 +116,8 @@ namespace array { using ::bsoncxx::v_noabi::array::operator==; using ::bsoncxx::v_noabi::array::operator!=; -} // namespace array -} // namespace bsoncxx +} // namespace array +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value-fwd.hpp index 7d5bdb1e92..8c9c63ed00 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value-fwd.hpp @@ -22,17 +22,17 @@ namespace array { class value; -} // namespace array -} // namespace v_noabi -} // namespace bsoncxx +} // namespace array +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace array { using ::bsoncxx::v_noabi::array::value; -} // namespace array -} // namespace bsoncxx +} // namespace array +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value.hpp index 97356cbbef..8314dee82d 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value.hpp @@ -73,8 +73,8 @@ class value { /// explicit BSONCXX_ABI_EXPORT_CDECL() value(array::view view); - BSONCXX_ABI_EXPORT_CDECL() value(const value&); - BSONCXX_ABI_EXPORT_CDECL(value&) operator=(const value&); + BSONCXX_ABI_EXPORT_CDECL() value(value const&); + BSONCXX_ABI_EXPORT_CDECL(value&) operator=(value const&); value(value&&) = default; value& operator=(value&&) = default; @@ -111,9 +111,9 @@ class value { std::size_t _length{0}; }; -} // namespace array -} // namespace v_noabi -} // namespace bsoncxx +} // namespace array +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view-fwd.hpp index 4008b57798..a34798fe56 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view-fwd.hpp @@ -22,17 +22,17 @@ namespace array { class view; -} // namespace array -} // namespace v_noabi -} // namespace bsoncxx +} // namespace array +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace array { using ::bsoncxx::v_noabi::array::view; -} // namespace array -} // namespace bsoncxx +} // namespace array +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view.hpp index 4f5f911223..63a88d4eaf 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view.hpp @@ -97,14 +97,14 @@ class view { /// @param length /// The size of the buffer, in bytes. /// - BSONCXX_ABI_EXPORT_CDECL() view(const std::uint8_t* data, std::size_t length); + BSONCXX_ABI_EXPORT_CDECL() view(std::uint8_t const* data, std::size_t length); /// /// Access the raw bytes of the underlying array. /// /// @return A (non-owning) pointer to the view's buffer. /// - BSONCXX_ABI_EXPORT_CDECL(const std::uint8_t*) data() const; + BSONCXX_ABI_EXPORT_CDECL(std::uint8_t const*) data() const; /// /// Gets the length of the underlying buffer. @@ -162,7 +162,7 @@ class view::const_iterator { using difference_type = std::ptrdiff_t; BSONCXX_ABI_EXPORT_CDECL() const_iterator(); - BSONCXX_ABI_EXPORT_CDECL(explicit) const_iterator(const element& element); + BSONCXX_ABI_EXPORT_CDECL(explicit) const_iterator(element const& element); BSONCXX_ABI_EXPORT_CDECL(reference) operator*(); BSONCXX_ABI_EXPORT_CDECL(pointer) operator->(); @@ -176,8 +176,8 @@ class view::const_iterator { /// Compare two const_iterators for (in)-equality. /// /// @{ - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const const_iterator&, const const_iterator&); - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const const_iterator&, const const_iterator&); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const_iterator const&, const_iterator const&); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const_iterator const&, const_iterator const&); /// @} /// @@ -185,9 +185,9 @@ class view::const_iterator { element _element; }; -} // namespace array -} // namespace v_noabi -} // namespace bsoncxx +} // namespace array +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp index a5d0f25c9c..6213924eed 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp @@ -30,17 +30,17 @@ namespace array { /// using view_or_value = v_noabi::view_or_value; -} // namespace array -} // namespace v_noabi -} // namespace bsoncxx +} // namespace array +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace array { using ::bsoncxx::v_noabi::array::view_or_value; -} // namespace array -} // namespace bsoncxx +} // namespace array +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array-fwd.hpp index 19fef88c86..e2338e4e8a 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array-fwd.hpp @@ -21,10 +21,10 @@ namespace basic { class array; -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -32,9 +32,9 @@ namespace basic { using ::bsoncxx::v_noabi::builder::basic::array; -} // namespace basic -} // namespace builder -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array.hpp index 2a0939686f..059c8f7a56 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/array.hpp @@ -59,8 +59,8 @@ class array : public sub_array { return *this; } - array(const array&) = delete; - array& operator=(const array&) = delete; + array(array const&) = delete; + array& operator=(array const&) = delete; /// /// @return A view of the BSON array. @@ -120,10 +120,10 @@ bsoncxx::v_noabi::array::value make_array(Args&&... args) { return array.extract(); } -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -131,9 +131,9 @@ namespace basic { using ::bsoncxx::v_noabi::builder::basic::make_array; -} // namespace basic -} // namespace builder -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document-fwd.hpp index 6d75072bba..4dc66722f3 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document-fwd.hpp @@ -21,10 +21,10 @@ namespace basic { class document; -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -32,9 +32,9 @@ namespace basic { using ::bsoncxx::v_noabi::builder::basic::document; -} // namespace basic -} // namespace builder -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document.hpp index 87e93a0857..e5212419b0 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/document.hpp @@ -57,8 +57,8 @@ class document : public sub_document { return *this; } - document(const document&) = delete; - document& operator=(const document&) = delete; + document(document const&) = delete; + document& operator=(document const&) = delete; /// /// @return A view of the BSON document. @@ -118,10 +118,10 @@ bsoncxx::v_noabi::document::value make_document(Args&&... args) { return document.extract(); } -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -129,9 +129,9 @@ namespace basic { using ::bsoncxx::v_noabi::builder::basic::make_document; -} // namespace basic -} // namespace builder -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/helpers.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/helpers.hpp index 108eb98088..c15e203d41 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/helpers.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/helpers.hpp @@ -25,10 +25,10 @@ namespace basic { using ::bsoncxx::v_noabi::builder::concatenate; -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -36,9 +36,9 @@ namespace basic { using ::bsoncxx::v_noabi::builder::basic::concatenate; -} // namespace basic -} // namespace builder -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace bsoncxx #include 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..578a41ae7e 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,14 +27,13 @@ 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(); } -template // placeholder 'void' for VS2015 compat +template // placeholder 'void' for VS2015 compat detail::requires_t> generic_append(core* core, T&& func) { core->open_array(); detail::invoke(std::forward(func), sub_array(core)); @@ -42,10 +41,9 @@ 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)); } @@ -54,11 +52,11 @@ void value_append(core* core, T&& t) { generic_append(core, std::forward(t)); } -} // namespace impl -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace impl +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/kvp.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/kvp.hpp index 4c2aee57e3..36eeaf57b3 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/kvp.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/kvp.hpp @@ -32,10 +32,10 @@ std::tuple kvp(T&& t, U&& u) { return std::tuple(std::forward(t), std::forward(u)); } -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -43,9 +43,9 @@ namespace basic { using ::bsoncxx::v_noabi::builder::basic::kvp; -} // namespace basic -} // namespace builder -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array-fwd.hpp index 0697df3f5d..7bfc8cff32 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array-fwd.hpp @@ -21,10 +21,10 @@ namespace basic { class sub_array; -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -32,9 +32,9 @@ namespace basic { using ::bsoncxx::v_noabi::builder::basic::sub_array; -} // namespace basic -} // namespace builder -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array.hpp index 5b25afd4ea..4d971ea4f0 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array.hpp @@ -32,7 +32,7 @@ namespace impl { template void value_append(core* core, T&& t); -} // namespace impl +} // namespace impl /// /// An internal class of builder::basic. @@ -78,10 +78,10 @@ class sub_array { core* _core; }; -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document-fwd.hpp index 9f2815831b..8891d1e830 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document-fwd.hpp @@ -21,10 +21,10 @@ namespace basic { class sub_document; -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -32,9 +32,9 @@ namespace basic { using ::bsoncxx::v_noabi::builder::basic::sub_document; -} // namespace basic -} // namespace builder -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document.hpp index 0864dc8495..38e8619fb3 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document.hpp @@ -34,7 +34,7 @@ namespace impl { template void value_append(core* core, T&& t); -} // namespace impl +} // namespace impl /// /// An internal class of builder::basic. @@ -81,7 +81,7 @@ class sub_document { // Appends a basic::kvp where the key is a string literal // template - void append_(std::tuple&& t) { + void append_(std::tuple&& t) { _core->key_view(stdx::string_view{std::get<0>(t), n - 1}); impl::value_append(_core, std::forward(std::get<1>(t))); } @@ -96,10 +96,10 @@ class sub_document { core* _core; }; -} // namespace basic -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace basic +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/concatenate-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/concatenate-fwd.hpp index 3460e68a37..e98b09b6d6 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/concatenate-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/concatenate-fwd.hpp @@ -21,9 +21,9 @@ namespace builder { struct concatenate_doc; struct concatenate_array; -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -31,8 +31,8 @@ namespace builder { using ::bsoncxx::v_noabi::builder::concatenate_array; using ::bsoncxx::v_noabi::builder::concatenate_doc; -} // namespace builder -} // namespace bsoncxx +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/concatenate.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/concatenate.hpp index 48d1e3a5c9..a62e052ce2 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/concatenate.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/concatenate.hpp @@ -119,17 +119,17 @@ inline concatenate_array concatenate(array::view_or_value array) { return {std::move(array)}; } -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { using ::bsoncxx::v_noabi::builder::concatenate; -} // namespace builder -} // namespace bsoncxx +} // namespace builder +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core-fwd.hpp index b30f09918b..05326c81bc 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core-fwd.hpp @@ -22,17 +22,17 @@ namespace builder { class core; -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { using ::bsoncxx::v_noabi::builder::core; -} // namespace builder -} // namespace bsoncxx +} // namespace builder +} // namespace bsoncxx #include 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..2c04a739fc 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/core.hpp @@ -60,8 +60,8 @@ class core { BSONCXX_ABI_EXPORT_CDECL() ~core(); - core(const core&) = delete; - core& operator=(const core&) = delete; + core(core const&) = delete; + core& operator=(core const&) = delete; /// /// Appends a key passed as a non-owning stdx::string_view. @@ -165,7 +165,7 @@ class core { /// @throws /// bsoncxx::v_noabi::exception if one of the keys fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) concatenate(const bsoncxx::v_noabi::document::view& view); + BSONCXX_ABI_EXPORT_CDECL(core&) concatenate(bsoncxx::v_noabi::document::view const& view); /// /// Appends a BSON double. @@ -179,7 +179,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the double fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_double& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_double const& value); /// /// Append a BSON UTF-8 string. @@ -193,7 +193,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the string fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_string& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_string const& value); /// /// Appends a BSON document. @@ -207,7 +207,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the document fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_document& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_document const& value); /// /// Appends a BSON array. @@ -221,7 +221,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the array fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_array& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_array const& value); /// /// Appends a BSON binary datum. @@ -235,7 +235,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the binary fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_binary& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_binary const& value); /// /// Appends a BSON undefined. @@ -249,7 +249,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if undefined fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_undefined& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_undefined const& value); /// /// Appends a BSON ObjectId. @@ -263,7 +263,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the ObjectId fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_oid& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_oid const& value); /// /// Appends a BSON boolean. @@ -277,7 +277,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the boolean fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_bool& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_bool const& value); /// /// Appends a BSON date. @@ -291,7 +291,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the date fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_date& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_date const& value); /// /// Appends a BSON null. @@ -305,7 +305,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if null fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_null& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_null const& value); /// /// Appends a BSON regex. @@ -319,7 +319,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the regex fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_regex& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_regex const& value); /// /// Appends a BSON DBPointer. @@ -333,7 +333,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the DBPointer fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_dbpointer& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_dbpointer const& value); /// /// Appends a BSON JavaScript code. @@ -347,7 +347,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the JavaScript code fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_code& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_code const& value); /// /// Appends a BSON symbol. @@ -361,7 +361,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the symbol fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_symbol& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_symbol const& value); /// /// Appends a BSON JavaScript code with scope. @@ -375,7 +375,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the JavaScript code with scope fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_codewscope& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_codewscope const& value); /// /// Appends a BSON 32-bit signed integer. @@ -389,7 +389,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the 32-bit signed integer fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_int32& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_int32 const& value); /// /// Appends a BSON replication timestamp. @@ -403,7 +403,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the timestamp fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_timestamp& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_timestamp const& value); /// /// Appends a BSON 64-bit signed integer. @@ -417,7 +417,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the 64-bit signed integer fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_int64& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_int64 const& value); /// /// Appends a BSON Decimal128. @@ -431,7 +431,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the Decimal128 fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_decimal128& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_decimal128 const& value); /// /// Appends a BSON min-key. @@ -445,7 +445,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the min-key fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_minkey& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_minkey const& value); /// /// Appends a BSON max-key. @@ -459,7 +459,7 @@ class core { /// key to be appended to start a new key/value pair. /// bsoncxx::v_noabi::exception if the max-key fails to append. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_maxkey& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_maxkey const& value); /// /// Appends a BSON variant value. @@ -472,7 +472,7 @@ class core { /// bsoncxx::v_noabi::exception if the current BSON datum is a document that is waiting for a /// key to be appended to start a new key/value pair. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::bson_value::view& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(types::bson_value::view const& value); /// /// Appends an STL string as a BSON UTF-8 string. @@ -501,7 +501,7 @@ class core { BSONCXX_ABI_EXPORT_CDECL(core&) append(stdx::string_view str); /// - /// Appends a char* or const char*. + /// Appends a char* or char const*. /// /// We disable all other pointer types to prevent the surprising implicit conversion to bool. /// @@ -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; @@ -585,7 +584,7 @@ class core { /// bsoncxx::v_noabi::exception if the current BSON datum is a document that is waiting for a /// key to be appended to start a new key/value pair. /// - BSONCXX_ABI_EXPORT_CDECL(core&) append(const oid& value); + BSONCXX_ABI_EXPORT_CDECL(core&) append(oid const& value); /// /// Appends a decimal128 object as a BSON Decimal128. @@ -698,9 +697,9 @@ class core { std::unique_ptr _impl; }; -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list-fwd.hpp index 7977dd783c..f7e1adbb24 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list-fwd.hpp @@ -22,9 +22,9 @@ class list; class document; class array; -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -33,8 +33,8 @@ using ::bsoncxx::v_noabi::builder::array; using ::bsoncxx::v_noabi::builder::document; using ::bsoncxx::v_noabi::builder::list; -} // namespace builder -} // namespace bsoncxx +} // namespace builder +} // namespace bsoncxx /// /// @file 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..92da27af3c 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()}; } } }; @@ -193,9 +192,9 @@ class array : public list { /// array(initializer_list_t init) : list(init, false, true) {} }; -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array-fwd.hpp index 00064a6b34..89dcc74678 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array-fwd.hpp @@ -21,10 +21,10 @@ namespace stream { class array; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -32,9 +32,9 @@ namespace stream { using ::bsoncxx::v_noabi::builder::stream::array; -} // namespace stream -} // namespace builder -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array.hpp index fecf813a21..f26b189b47 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array.hpp @@ -84,10 +84,10 @@ class array : public array_context<> { core _core; }; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context-fwd.hpp index 6a4dd0024c..b486f0f64a 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context-fwd.hpp @@ -24,10 +24,10 @@ namespace stream { template class array_context; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -35,9 +35,9 @@ namespace stream { using ::bsoncxx::v_noabi::builder::stream::array_context; -} // namespace stream -} // namespace builder -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace bsoncxx /// /// @file 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..ef6bcaf66d 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 @@ -66,10 +66,11 @@ class array_context { /// The value to append /// template - detail::requires_not_t>, - detail::is_invocable, - detail::is_alike> + detail::requires_not_t< + array_context&, + detail::is_invocable>, + detail::is_invocable, + detail::is_alike> operator<<(T&& t) { _core->append(std::forward(t)); return *this; @@ -84,9 +85,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; @@ -103,9 +104,10 @@ class array_context { /// @return A value type which holds the complete bson document. /// template - detail::requires_t, - detail::is_alike> + detail::requires_t< + bsoncxx::v_noabi::array::value, + std::is_same, + detail::is_alike> // VS2015U1 can't resolve the name. operator<<(T&&) { return _core->extract_array(); @@ -116,7 +118,7 @@ class array_context { /// /// The argument must be an open_document_type token (it is otherwise ignored). /// - key_context operator<<(const open_document_type) { + key_context operator<<(open_document_type const) { _core->open_document(); return wrap_document(); } @@ -140,7 +142,7 @@ class array_context { /// /// The argument must be an open_document_type token (it is otherwise ignored). /// - array_context operator<<(const open_array_type) { + array_context operator<<(open_array_type const) { _core->open_array(); return wrap_array(); } @@ -150,7 +152,7 @@ class array_context { /// /// The argument must be a close_array_type token (it is otherwise ignored). /// - base operator<<(const close_array_type) { + base operator<<(close_array_type const) { _core->close_array(); return unwrap(); } @@ -187,10 +189,10 @@ class array_context { core* _core; }; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context-fwd.hpp index b72bee6718..393aaac406 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context-fwd.hpp @@ -21,10 +21,10 @@ namespace stream { struct closed_context; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -32,9 +32,9 @@ namespace stream { using ::bsoncxx::v_noabi::builder::stream::closed_context; -} // namespace stream -} // namespace builder -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context.hpp index 59e737b352..e2cd6976fa 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context.hpp @@ -35,10 +35,10 @@ struct closed_context { closed_context(core*) {} }; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document-fwd.hpp index ca13c57141..455218a3c0 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document-fwd.hpp @@ -21,10 +21,10 @@ namespace stream { class document; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -32,9 +32,9 @@ namespace stream { using ::bsoncxx::v_noabi::builder::stream::document; -} // namespace stream -} // namespace builder -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document.hpp index 1bf9f4a537..b198851a27 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/document.hpp @@ -82,10 +82,10 @@ class document : public key_context<> { core _core; }; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers-fwd.hpp index 9c8b8fd473..8b4ac4c0cf 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers-fwd.hpp @@ -27,10 +27,10 @@ struct open_array_type; struct close_array_type; struct finalize_type; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers.hpp index e8269a0d6c..36fc524db3 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers.hpp @@ -87,10 +87,10 @@ struct finalize_type { /// constexpr finalize_type finalize; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -102,9 +102,9 @@ using ::bsoncxx::v_noabi::builder::stream::finalize; using ::bsoncxx::v_noabi::builder::stream::open_array; using ::bsoncxx::v_noabi::builder::stream::open_document; -} // namespace stream -} // namespace builder -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context-fwd.hpp index 0c35610e24..801aaed168 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context-fwd.hpp @@ -24,10 +24,10 @@ namespace stream { template class key_context; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -35,9 +35,9 @@ namespace stream { using ::bsoncxx::v_noabi::builder::stream::key_context; -} // namespace stream -} // namespace builder -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp index 647f18c54c..d40256e89a 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp @@ -1,4 +1,3 @@ - // Copyright 2009-present MongoDB, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -69,7 +68,7 @@ class key_context { /// key. /// template - value_context operator<<(const char (&v)[n]) { + value_context operator<<(char const (&v)[n]) { _core->key_view(stdx::string_view{v, n - 1}); return value_context(_core); } @@ -129,9 +128,10 @@ class key_context { /// @return A value type which holds the complete bson document. /// template - detail::requires_t, - detail::is_alike> + detail::requires_t< + bsoncxx::v_noabi::document::value, + std::is_same, + detail::is_alike> operator<<(T&&) { return _core->extract_document(); } @@ -155,7 +155,7 @@ class key_context { /// /// The argument must be a close_document_type token (it is otherwise ignored). /// - base operator<<(const close_document_type) { + base operator<<(close_document_type const) { _core->close_document(); return unwrap(); } @@ -176,10 +176,10 @@ class key_context { core* _core; }; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context-fwd.hpp index 9e4265b181..08171e4f25 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context-fwd.hpp @@ -23,10 +23,10 @@ namespace stream { class single_context; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -34,9 +34,9 @@ namespace stream { using ::bsoncxx::v_noabi::builder::stream::single_context; -} // namespace stream -} // namespace builder -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context.hpp index 2196b3626f..4a0b264830 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context.hpp @@ -107,10 +107,10 @@ value_context::operator single_context() { return single_context(_core); } -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context-fwd.hpp index 57f0a99b48..60eebc2bd5 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context-fwd.hpp @@ -24,10 +24,10 @@ namespace stream { template class value_context; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace builder { @@ -35,9 +35,9 @@ namespace stream { using ::bsoncxx::v_noabi::builder::stream::value_context; -} // namespace stream -} // namespace builder -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace bsoncxx #include 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..366abf03a5 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 @@ -88,7 +88,7 @@ class value_context { /// /// The argument must be an open_document_type token (it is otherwise ignored). /// - key_context operator<<(const open_document_type) { + key_context operator<<(open_document_type const) { _core->open_document(); return wrap_document(); } @@ -98,7 +98,7 @@ class value_context { /// /// The argument must be an open_array_type token (it is otherwise ignored). /// - array_context operator<<(const open_array_type) { + array_context operator<<(open_array_type const) { _core->open_array(); return wrap_array(); } @@ -134,10 +134,10 @@ class value_context { core* _core; }; -} // namespace stream -} // namespace builder -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stream +} // namespace builder +} // namespace v_noabi +} // namespace bsoncxx #include 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/decimal128-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/decimal128-fwd.hpp index ca10c4c1ca..852526d143 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/decimal128-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/decimal128-fwd.hpp @@ -21,14 +21,14 @@ namespace v_noabi { class decimal128; -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { using ::bsoncxx::v_noabi::decimal128; -} // namespace bsoncxx +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/decimal128.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/decimal128.hpp index 2eb0092137..e140dd0168 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/decimal128.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/decimal128.hpp @@ -70,8 +70,8 @@ class decimal128 { /// Relational operators for decimal128 /// /// @{ - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const decimal128& lhs, const decimal128& rhs); - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const decimal128& lhs, const decimal128& rhs); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(decimal128 const& lhs, decimal128 const& rhs); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(decimal128 const& lhs, decimal128 const& rhs); /// @} /// @@ -94,8 +94,8 @@ class decimal128 { uint64_t _low = 0; }; -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element-fwd.hpp index 5236776e3b..648eccb064 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element-fwd.hpp @@ -22,17 +22,17 @@ namespace document { class element; -} // namespace document -} // namespace v_noabi -} // namespace bsoncxx +} // namespace document +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace document { using ::bsoncxx::v_noabi::document::element; -} // namespace document -} // namespace bsoncxx +} // namespace document +} // namespace bsoncxx #include 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 fad06111eb..60e91e10ce 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp @@ -64,7 +64,7 @@ class element { /// /// @return a pointer to the raw bson bytes. /// - BSONCXX_ABI_EXPORT_CDECL(const std::uint8_t*) raw() const; + BSONCXX_ABI_EXPORT_CDECL(std::uint8_t const*) raw() const; /// /// Getter for length of the raw bson bytes the element points to. @@ -355,18 +355,15 @@ 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(std::uint8_t const* 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); + explicit element(stdx::string_view const key); friend ::bsoncxx::v_noabi::array::element; friend ::bsoncxx::v_noabi::document::view; - const std::uint8_t* _raw; + std::uint8_t const* _raw; std::uint32_t _length; std::uint32_t _offset; std::uint32_t _keylen; @@ -384,23 +381,23 @@ class element { /// @{ /// @relatesalso bsoncxx::v_noabi::document::element -BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const element& elem, const types::bson_value::view& v); +BSONCXX_ABI_EXPORT_CDECL(bool) operator==(element const& elem, types::bson_value::view const& v); /// @relatesalso bsoncxx::v_noabi::document::element -BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const types::bson_value::view& v, const element& elem); +BSONCXX_ABI_EXPORT_CDECL(bool) operator==(types::bson_value::view const& v, element const& elem); /// @relatesalso bsoncxx::v_noabi::document::element -BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const element& elem, const types::bson_value::view& v); +BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(element const& elem, types::bson_value::view const& v); /// @relatesalso bsoncxx::v_noabi::document::element -BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const types::bson_value::view& v, const element& elem); +BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(types::bson_value::view const& v, element const& elem); /// @} /// -} // namespace document -} // namespace v_noabi -} // namespace bsoncxx +} // namespace document +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace document { @@ -408,8 +405,8 @@ namespace document { using ::bsoncxx::v_noabi::document::operator==; using ::bsoncxx::v_noabi::document::operator!=; -} // namespace document -} // namespace bsoncxx +} // namespace document +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/value-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/value-fwd.hpp index 6b7387bd49..d10d6e4c0c 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/value-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/value-fwd.hpp @@ -22,17 +22,17 @@ namespace document { class value; -} // namespace document -} // namespace v_noabi -} // namespace bsoncxx +} // namespace document +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace document { using ::bsoncxx::v_noabi::document::value; -} // namespace document -} // namespace bsoncxx +} // namespace document +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/value.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/value.hpp index 1a3dda897b..cc57cad762 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/value.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/value.hpp @@ -77,8 +77,8 @@ class value { ~value() = default; - BSONCXX_ABI_EXPORT_CDECL() value(const value&); - BSONCXX_ABI_EXPORT_CDECL(value&) operator=(const value&); + BSONCXX_ABI_EXPORT_CDECL() value(value const&); + BSONCXX_ABI_EXPORT_CDECL(value&) operator=(value const&); value(value&&) = default; value& operator=(value&&) = default; @@ -92,11 +92,11 @@ class value { /// A user-defined object to serialize into a BSON object. /// template > = 0> - explicit value(const T& t) : value({}) { + explicit value(T const& t) : value({}) { to_bson(t, *this); } template - value& operator=(const T& t) { + value& operator=(T const& t) { *this = value{t}; return *this; } @@ -155,7 +155,7 @@ class value { /// /// @return A pointer to the value's buffer. /// - BSONCXX_ABI_EXPORT_CDECL(const std::uint8_t*) data() const; + BSONCXX_ABI_EXPORT_CDECL(std::uint8_t const*) data() const; /// /// Gets the length of the underlying buffer. @@ -198,7 +198,7 @@ class value { /// /// Constructs an object of type T from this document object. This method uses /// argument-dependent lookup to find the function declaration - /// `void from_bson(T& t, const bsoncxx::v_noabi::document::view& doc)`. + /// `void from_bson(T& t, bsoncxx::v_noabi::document::view const& doc)`. /// /// @note Type T must be default-constructible. Otherwise, use `void get(T& t)`. /// @@ -212,7 +212,7 @@ class value { /// /// Constructs an object of type T from this document object. This method uses /// argument-dependent lookup to find the function declaration - /// `void from_bson(T& t, const bsoncxx::v_noabi::document::view& doc)`. + /// `void from_bson(T& t, bsoncxx::v_noabi::document::view const& doc)`. /// /// @param t /// The object to construct. The contents of the document object will be deserialized @@ -251,21 +251,21 @@ class value { /// @{ /// @relatesalso bsoncxx::v_noabi::document::value -inline bool operator==(const value& lhs, const value& rhs) { +inline bool operator==(value const& lhs, value const& rhs) { return (lhs.view() == rhs.view()); } /// @relatesalso bsoncxx::v_noabi::document::value -inline bool operator!=(const value& lhs, const value& rhs) { +inline bool operator!=(value const& lhs, value const& rhs) { return !(lhs == rhs); } /// @} /// -} // namespace document -} // namespace v_noabi -} // namespace bsoncxx +} // namespace document +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace document { @@ -273,8 +273,8 @@ namespace document { using ::bsoncxx::v_noabi::document::operator==; using ::bsoncxx::v_noabi::document::operator!=; -} // namespace document -} // namespace bsoncxx +} // namespace document +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view-fwd.hpp index 0764d4cd04..4fc7fae2ec 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view-fwd.hpp @@ -22,17 +22,17 @@ namespace document { class view; -} // namespace document -} // namespace v_noabi -} // namespace bsoncxx +} // namespace document +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace document { using ::bsoncxx::v_noabi::document::view; -} // namespace document -} // namespace bsoncxx +} // namespace document +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view.hpp index 458215c095..5c14099eb0 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view.hpp @@ -52,7 +52,7 @@ class view { /// @param length /// The size of the buffer, in bytes. /// - BSONCXX_ABI_EXPORT_CDECL() view(const std::uint8_t* data, std::size_t length); + BSONCXX_ABI_EXPORT_CDECL() view(std::uint8_t const* data, std::size_t length); /// /// @returns A const_iterator to the first element of the document. @@ -108,7 +108,7 @@ class view { /// /// @return A (non-owning) pointer to the view's buffer. /// - BSONCXX_ABI_EXPORT_CDECL(const std::uint8_t*) data() const; + BSONCXX_ABI_EXPORT_CDECL(std::uint8_t const*) data() const; /// /// Gets the length of the underlying buffer. @@ -140,7 +140,7 @@ class view { /// private: - const std::uint8_t* _data; + std::uint8_t const* _data; std::size_t _length; }; @@ -162,7 +162,7 @@ class view::const_iterator { using difference_type = std::ptrdiff_t; BSONCXX_ABI_EXPORT_CDECL() const_iterator(); - explicit BSONCXX_ABI_EXPORT_CDECL() const_iterator(const element& element); + explicit BSONCXX_ABI_EXPORT_CDECL() const_iterator(element const& element); BSONCXX_ABI_EXPORT_CDECL(reference) operator*(); BSONCXX_ABI_EXPORT_CDECL(pointer) operator->(); @@ -176,8 +176,8 @@ class view::const_iterator { /// Compares two const_iterators for (in)-equality. /// /// @{ - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const const_iterator&, const const_iterator&); - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const const_iterator&, const const_iterator&); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const_iterator const&, const_iterator const&); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const_iterator const&, const_iterator const&); /// @} /// @@ -185,9 +185,9 @@ class view::const_iterator { element _element; }; -} // namespace document -} // namespace v_noabi -} // namespace bsoncxx +} // namespace document +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view_or_value.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view_or_value.hpp index 046d8cbce7..1e14ef69d9 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view_or_value.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/view_or_value.hpp @@ -29,17 +29,17 @@ namespace document { /// using view_or_value = v_noabi::view_or_value; -} // namespace document -} // namespace v_noabi -} // namespace bsoncxx +} // namespace document +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { namespace document { using ::bsoncxx::v_noabi::document::view_or_value; -} // namespace document -} // namespace bsoncxx +} // namespace document +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code-fwd.hpp index 894fb5b4e6..bd0d18dde0 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code-fwd.hpp @@ -22,21 +22,21 @@ namespace v_noabi { enum class error_code : std::int32_t; -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { using ::bsoncxx::v_noabi::error_code; -} // namespace bsoncxx +} // namespace bsoncxx namespace std { template <> struct is_error_code_enum; -} // namespace std +} // namespace std /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp index ded224bd70..925adc4305 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp @@ -151,7 +151,7 @@ enum class error_code : std::int32_t { /// /// @return The bsoncxx error_category /// -BSONCXX_ABI_EXPORT_CDECL(const std::error_category&) error_category(); +BSONCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category(); /// /// Translate a bsoncxx::v_noabi::error_code into a std::error_code. @@ -163,15 +163,15 @@ inline std::error_code make_error_code(error_code error) { return {static_cast(error), error_category()}; } -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { using ::bsoncxx::v_noabi::error_category; using ::bsoncxx::v_noabi::make_error_code; -} // namespace bsoncxx +} // namespace bsoncxx #include @@ -182,7 +182,7 @@ template <> struct is_error_code_enum : public true_type {}; // @endcond -} // namespace std +} // namespace std /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception-fwd.hpp index 880b976a2b..be22eef64e 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception-fwd.hpp @@ -21,14 +21,14 @@ namespace v_noabi { class BSONCXX_ABI_EXPORT exception; -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { using ::bsoncxx::v_noabi::exception; -} // namespace bsoncxx +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception.hpp index 0362233919..a05629edb7 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/exception.hpp @@ -37,16 +37,16 @@ class exception : public std::system_error { exception(exception&&) = default; exception& operator=(exception&&) = default; - exception(const exception&) = default; - exception& operator=(const exception&) = default; + exception(exception const&) = default; + exception& operator=(exception const&) = default; using std::system_error::system_error; }; BSONCXX_POP_WARNINGS(); -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json-fwd.hpp index 6f92edbe99..672d22b043 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json-fwd.hpp @@ -21,14 +21,14 @@ namespace v_noabi { enum class ExtendedJsonMode : std::uint8_t; -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { using ::bsoncxx::v_noabi::ExtendedJsonMode; -} // namespace bsoncxx +} // namespace bsoncxx /// /// @file diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp index 1dc41083f0..ec22e605f8 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp @@ -31,9 +31,9 @@ namespace v_noabi { /// /// An enumeration of the types of Extended JSON that the to_json function accepts enum class ExtendedJsonMode : std::uint8_t { - k_legacy, ///< to produce Legacy Extended JSON - k_canonical, ///< to produce Canonical Extended JSON - k_relaxed, ///< to produce Relaxed Extended JSON + k_legacy, ///< to produce Legacy Extended JSON + k_canonical, ///< to produce Canonical Extended JSON + k_relaxed, ///< to produce Relaxed Extended JSON }; /// @@ -82,10 +82,10 @@ BSONCXX_ABI_EXPORT_CDECL(document::value) from_json(stdx::string_view json); /// /// @throws bsoncxx::v_noabi::exception with error details if the conversion failed. /// -BSONCXX_ABI_EXPORT_CDECL(document::value) operator"" _bson(const char* json, size_t len); +BSONCXX_ABI_EXPORT_CDECL(document::value) operator"" _bson(char const* json, size_t len); -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { @@ -94,7 +94,7 @@ using ::bsoncxx::v_noabi::to_json; using ::bsoncxx::v_noabi::operator"" _bson; -} // namespace bsoncxx +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid-fwd.hpp index a99572b4bb..11338fbcec 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid-fwd.hpp @@ -21,14 +21,14 @@ namespace v_noabi { class oid; -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx namespace bsoncxx { using ::bsoncxx::v_noabi::oid; -} // namespace bsoncxx +} // namespace bsoncxx #include diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid.hpp index ec9efa4402..651ae03591 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid.hpp @@ -57,7 +57,7 @@ class oid { /// /// @throws bsoncxx::v_noabi::exception if the length is not equal to oid::size(). /// - explicit BSONCXX_ABI_EXPORT_CDECL() oid(const char* bytes, std::size_t len); + explicit BSONCXX_ABI_EXPORT_CDECL() oid(char const* bytes, std::size_t len); /// /// Constructs an oid and initializes it from the provided hex string. @@ -68,7 +68,7 @@ class oid { /// @throws bsoncxx::v_noabi::exception if the string isn't an OID-sized hex /// string. /// - explicit BSONCXX_ABI_EXPORT_CDECL() oid(const stdx::string_view& str); + explicit BSONCXX_ABI_EXPORT_CDECL() oid(stdx::string_view const& str); /// /// Converts this oid to a hexadecimal string. @@ -92,12 +92,12 @@ class oid { /// Relational operators for OIDs. /// /// @{ - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator<(const oid& lhs, const oid& rhs); - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator>(const oid& lhs, const oid& rhs); - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator<=(const oid& lhs, const oid& rhs); - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator>=(const oid& lhs, const oid& rhs); - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(const oid& lhs, const oid& rhs); - friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(const oid& lhs, const oid& rhs); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator<(oid const& lhs, oid const& rhs); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator>(oid const& lhs, oid const& rhs); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator<=(oid const& lhs, oid const& rhs); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator>=(oid const& lhs, oid const& rhs); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator==(oid const& lhs, oid const& rhs); + friend BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(oid const& lhs, oid const& rhs); /// @} /// @@ -114,16 +114,16 @@ class oid { /// /// @return A pointer to the internal buffer holding the oid bytes. /// - BSONCXX_ABI_EXPORT_CDECL(const char*) bytes() const; + BSONCXX_ABI_EXPORT_CDECL(char const*) bytes() const; private: - friend int oid_compare(const oid& lhs, const oid& rhs); + friend int oid_compare(oid const& lhs, oid const& rhs); std::array _bytes; }; -} // namespace v_noabi -} // namespace bsoncxx +} // namespace v_noabi +} // namespace bsoncxx #include 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..f3cf7868eb 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/operators.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/operators.hpp @@ -32,10 +32,8 @@ BSONCXX_PUSH_WARNINGS(); BSONCXX_DISABLE_WARNING(GNU("-Wfloat-equal")); template auto is_equality_comparable_f(int, bool b = false) - -> true_t() == std::declval()) ? 0 : 0, - (std::declval() == std::declval()) ? 0 : 0, - (std::declval() != std::declval()) ? 0 : 0, - (std::declval() != std::declval()) ? 0 : 0)>; + -> true_t< + decltype((std::declval() == std::declval()) ? 0 : 0, (std::declval() == std::declval()) ? 0 : 0, (std::declval() != std::declval()) ? 0 : 0, (std::declval() != std::declval()) ? 0 : 0)>; BSONCXX_POP_WARNINGS(); // Detect whether two types are equality-comparable. @@ -47,8 +45,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; } }; @@ -64,13 +61,13 @@ class equality_operators { // @cond DOXYGEN_DISABLE "Found ';' while parsing initializer list!" template - constexpr friend auto operator==(const Left& self, const Other& other) + constexpr friend auto operator==(Left const& self, Other const& other) BSONCXX_RETURNS(equality_operators::impl(rank<1>{}, self, other)); // @endcond // @cond DOXYGEN_DISABLE "Found ';' while parsing initializer list!" template - constexpr friend auto operator!=(const Left& self, const Other& other) + constexpr friend auto operator!=(Left const& self, Other const& other) BSONCXX_RETURNS(!equality_operators::impl(rank<1>{}, self, other)); // @endcond }; @@ -85,10 +82,10 @@ class strong_ordering { constexpr strong_ordering(_construct, signed char c) noexcept : _c(c) {} public: - static const strong_ordering less; - static const strong_ordering greater; - static const strong_ordering equivalent; - static const strong_ordering equal; + static strong_ordering const less; + static strong_ordering const greater; + static strong_ordering const equivalent; + static strong_ordering const equal; constexpr strong_ordering(std::nullptr_t) noexcept : strong_ordering(_construct{}, 0) {} @@ -123,14 +120,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") @@ -140,45 +133,43 @@ INLINE_VAR const strong_ordering strong_ordering::equal = struct compare_three_way { BSONCXX_PUSH_WARNINGS(); BSONCXX_DISABLE_WARNING(GNU("-Wfloat-equal")); - template () < 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); + template < + typename L, + typename R, + typename = decltype(std::declval() < std::declval()), + typename = decltype(std::declval() == std::declval())> + constexpr static strong_ordering impl(L const& l, R const& r, rank<1>) { + return (l < r) ? strong_ordering::less : (l == r ? strong_ordering::equal : strong_ordering::greater); } BSONCXX_POP_WARNINGS(); - template (), std::declval(), std::declval()))> - constexpr static strong_ordering impl(const L& l, const R& r, rank<2>) { + template < + typename L, + typename R, + typename = decltype(tag_invoke(std::declval(), std::declval(), std::declval()))> + constexpr static strong_ordering impl(L const& l, R const& 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()(L const& l, R const& 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(L const& l, R const& 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>) + constexpr static auto impl(L const& l, R const& r, rank<0>) BSONCXX_RETURNS(tag_invoke(compare_three_way{}, r, l).inverted()); #pragma push_macro("DEFOP") #undef DEFOP #define DEFOP(Oper) \ template \ - constexpr friend auto operator Oper(const L& l, const R& r) \ + constexpr friend auto operator Oper(L const& l, R const& r) \ BSONCXX_RETURNS(ordering_operators::impl(l, r, rank<1>{}) Oper nullptr) DEFOP(<); DEFOP(>); @@ -191,31 +182,31 @@ 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< + 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()), + 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, - is_totally_ordered, - is_equality_comparable, - is_partially_ordered_with> {}; - -} // namespace detail -} // namespace bsoncxx +struct is_totally_ordered_with : conjunction< + is_totally_ordered, + is_totally_ordered, + is_equality_comparable, + is_partially_ordered_with> {}; + +} // namespace detail +} // namespace bsoncxx #include 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..5e77c64ea5 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp @@ -31,9 +31,9 @@ using ::std::nullopt; using ::std::nullopt_t; using ::std::optional; -} // namespace stdx -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx #elif defined(BSONCXX_POLY_USE_IMPLS) @@ -65,7 +65,7 @@ BSONCXX_DISABLE_WARNING(Clang("-Wweak-vtables")); // API. class bad_optional_access : public std::exception { public: - const char* what() const noexcept override { + char const* what() const noexcept override { return "bad_optional_access()"; } }; @@ -86,7 +86,7 @@ static constexpr struct in_place_t { namespace detail { // Terminates the program when an illegal use of optional is attempted. -[[noreturn]] inline void terminate_disengaged_optional(const char* what) noexcept { +[[noreturn]] inline void terminate_disengaged_optional(char const* what) noexcept { (void)std::fprintf(stderr, "%s: Invalid attempted use of disengaged optional\n", what); std::terminate(); } @@ -102,33 +102,33 @@ struct optional_base_class; // Base case: Things are not optionals. template -std::true_type not_an_optional_f(const T&); +std::true_type not_an_optional_f(T const&); // More-specialized if given an optional or any class derived from a template // specialization thereof. template -std::false_type not_an_optional_f(const optional&); +std::false_type not_an_optional_f(optional const&); // Utility trait to detect specializations of stdx::optional. template -struct not_an_optional : decltype(not_an_optional_f(std::declval())){}; +struct not_an_optional : decltype(not_an_optional_f(std::declval())){}; template -struct enable_opt_conversion - : bsoncxx::detail::conjunction< - std::is_constructible, - bsoncxx::detail::disjunction, +struct enable_opt_conversion : bsoncxx::detail::conjunction< + std::is_constructible, + bsoncxx::detail::disjunction< + std::is_same, bsoncxx::detail::negation&>, - std::is_constructible&>, + std::is_constructible const&>, std::is_constructible&&>, - std::is_constructible&&>, + std::is_constructible const&&>, std::is_convertible&, T>, - std::is_convertible&, T>, + std::is_convertible const&, T>, std::is_convertible&&, T>, - std::is_convertible&&, T>>>>> {}; + std::is_convertible const&&, T>>>>> {}; template -struct enable_opt_value_conversion // +struct enable_opt_value_conversion // : bsoncxx::detail::conjunction< std::is_constructible, bsoncxx::detail::negation>, @@ -137,7 +137,7 @@ struct enable_opt_value_conversion // bsoncxx::detail::negation>, detail::not_an_optional>>> {}; -} // namespace detail +} // namespace detail template class optional : bsoncxx::detail::equality_operators, @@ -146,13 +146,11 @@ 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; + using const_pointer = bsoncxx::detail::add_pointer_t; // Constructors [1]. @@ -161,28 +159,25 @@ class optional : bsoncxx::detail::equality_operators, // Ctor [2] and [3] are provided by base classes. - optional(const optional&) = default; + optional(optional const&) = default; optional(optional&&) = default; // Same with assignments - optional& operator=(const optional&) = default; + optional& operator=(optional const&) = default; optional& operator=(optional&&) = default; ~optional() = default; // 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)...); } @@ -190,40 +185,42 @@ class optional : bsoncxx::detail::equality_operators, // 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) + bsoncxx::detail::requires_t< + int, + detail::enable_opt_value_conversion, + 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_cxx14_constexpr explicit optional(const optional& other) noexcept( - std::is_nothrow_constructible>::value) { + template < + typename U, + bsoncxx::detail::requires_t< + int, + detail::enable_opt_conversion, + bsoncxx::detail::negation>> = 0> + bsoncxx_cxx14_constexpr explicit optional(optional const& other) noexcept( + std::is_nothrow_constructible>::value) { if (other.has_value()) { this->emplace(*other); } } - template , - std::is_convertible> = 0> - bsoncxx_cxx14_constexpr optional(const optional& other) noexcept( - std::is_nothrow_constructible>::value) { + template < + typename U, + bsoncxx::detail::requires_t< + int, + detail::enable_opt_conversion, + std::is_convertible> = 0> + bsoncxx_cxx14_constexpr optional(optional const& other) noexcept( + std::is_nothrow_constructible>::value) { if (other.has_value()) { this->emplace(*other); } @@ -231,9 +228,10 @@ class optional : bsoncxx::detail::equality_operators, template < typename U, - bsoncxx::detail::requires_t, - bsoncxx::detail::negation>> = 0> + bsoncxx::detail::requires_t< + int, + detail::enable_opt_conversion, + bsoncxx::detail::negation>> = 0> bsoncxx_cxx14_constexpr explicit optional(optional&& other) noexcept( std::is_nothrow_constructible>::value) { if (other.has_value()) { @@ -241,10 +239,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()) { @@ -329,7 +326,7 @@ class optional : bsoncxx::detail::equality_operators, } private: - bsoncxx_cxx14_constexpr void _assert_has_value(const char* msg) const noexcept { + bsoncxx_cxx14_constexpr void _assert_has_value(char const* msg) const noexcept { if (!this->has_value()) { detail::terminate_disengaged_optional(msg); } @@ -364,8 +361,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)...); } @@ -386,8 +382,8 @@ union storage_for { // Empty special members allow the union to be used in semiregular contexts, // but it is the responsibility of the using class to implement them properly ~storage_for() {} - storage_for(const storage_for&) = delete; - storage_for& operator=(const storage_for&) = delete; + storage_for(storage_for const&) = delete; + storage_for& operator=(storage_for const&) = delete; }; template @@ -395,8 +391,8 @@ union storage_for { char nothing; T value; storage_for() noexcept : nothing(0) {} - storage_for(const storage_for&) = delete; - storage_for& operator=(const storage_for&) = delete; + storage_for(storage_for const&) = delete; + storage_for& operator=(storage_for const&) = delete; }; // Whether a type is copyable, moveable, or immobile. @@ -407,17 +403,19 @@ enum copymove_classification { }; // Classify the constructibility of the given type. -template ::value, - bool CanMove = std::is_move_constructible::value> +template < + typename T, + bool CanCopy = std::is_copy_constructible::value, + bool CanMove = std::is_move_constructible::value> constexpr copymove_classification classify_construct() { return CanCopy ? copyable : CanMove ? movable : immobile; } // Classify the assignability of the given type. -template ::value, - bool CanMove = std::is_move_assignable::value> +template < + typename T, + bool CanCopy = std::is_copy_assignable::value, + bool CanMove = std::is_move_assignable::value> constexpr copymove_classification classify_assignment() { return CanCopy ? copyable : CanMove ? movable : immobile; } @@ -451,13 +449,13 @@ struct optional_assign_base : optional_construct_base { // Constructors defer to base. optional_assign_base() = default; - optional_assign_base(const optional_assign_base&) = default; + optional_assign_base(optional_assign_base const&) = default; optional_assign_base(optional_assign_base&&) = default; ~optional_assign_base() = default; // Disallow copies. - bsoncxx_cxx14_constexpr optional_assign_base& operator=(const optional_assign_base&) = delete; + bsoncxx_cxx14_constexpr optional_assign_base& operator=(optional_assign_base const&) = delete; // Allow move-assignment. @@ -467,12 +465,12 @@ struct optional_assign_base : optional_construct_base { template struct optional_assign_base : optional_construct_base { optional_assign_base() = default; - optional_assign_base(const optional_assign_base&) = default; + optional_assign_base(optional_assign_base const&) = default; optional_assign_base(optional_assign_base&&) = default; ~optional_assign_base() = default; // No assignment at all - optional_assign_base& operator=(const optional_assign_base&) = delete; + optional_assign_base& operator=(optional_assign_base const&) = delete; optional_assign_base& operator=(optional_assign_base&&) = delete; }; @@ -483,17 +481,17 @@ template struct optional_construct_base : optional_destruct_base { optional_construct_base() = default; - optional_construct_base(const optional_construct_base&) = delete; + optional_construct_base(optional_construct_base const&) = delete; optional_construct_base(optional_construct_base&&) = default; - optional_construct_base& operator=(const optional_construct_base&) = default; + optional_construct_base& operator=(optional_construct_base const&) = default; optional_construct_base& operator=(optional_construct_base&&) = default; }; template struct optional_construct_base : optional_destruct_base { optional_construct_base() = default; - optional_construct_base(const optional_construct_base&) = delete; - optional_construct_base& operator=(const optional_construct_base&) = default; + optional_construct_base(optional_construct_base const&) = delete; + optional_construct_base& operator=(optional_construct_base const&) = default; optional_construct_base& operator=(optional_construct_base&&) = default; }; @@ -504,9 +502,9 @@ struct optional_destruct_helper { // Special members defer to base. base() = default; - base(const base&) = default; + base(base const&) = default; base(base&&) = default; - base& operator=(const base&) = default; + base& operator=(base const&) = default; base& operator=(base&&) = default; ~base() { @@ -527,9 +525,8 @@ struct optional_destruct_helper { // Optional's ADL-only operators are defined here. struct optional_operators_base { template - friend bsoncxx_cxx14_constexpr auto tag_invoke(bsoncxx::detail::equal_to, - const optional& left, - const optional& right) noexcept + friend bsoncxx_cxx14_constexpr auto + tag_invoke(bsoncxx::detail::equal_to, optional const& left, optional const& right) noexcept -> bsoncxx::detail::requires_t> { if (left.has_value() != right.has_value()) { return false; @@ -542,12 +539,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, optional const& left, U const& 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,18 +548,16 @@ 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, optional const& opt, nullopt_t) noexcept { return !opt.has_value(); } template - bsoncxx_cxx14_constexpr friend auto tag_invoke(bsoncxx::detail::compare_three_way compare, - const optional& left, - const optional& right) - -> bsoncxx::detail::requires_t> { + bsoncxx_cxx14_constexpr friend auto + tag_invoke(bsoncxx::detail::compare_three_way compare, optional const& left, optional const& right) + -> bsoncxx::detail::requires_t< + bsoncxx::detail::strong_ordering, + bsoncxx::detail::is_totally_ordered_with> { if (left.has_value()) { if (right.has_value()) { return compare(*left, *right); @@ -586,12 +577,12 @@ struct optional_operators_base { } template - bsoncxx_cxx14_constexpr friend auto tag_invoke(bsoncxx::detail::compare_three_way compare, - const optional& left, - const U& right) - -> bsoncxx::detail::requires_t, - bsoncxx::detail::is_totally_ordered_with> { + bsoncxx_cxx14_constexpr friend auto + tag_invoke(bsoncxx::detail::compare_three_way compare, optional const& left, U const& right) + -> bsoncxx::detail::requires_t< + bsoncxx::detail::strong_ordering, + not_an_optional, + bsoncxx::detail::is_totally_ordered_with> { if (left.has_value()) { return compare(*left, right); } @@ -600,8 +591,8 @@ 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, optional const& left, nullopt_t) { return compare(left.has_value(), false); } }; @@ -613,8 +604,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,28 +618,25 @@ 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(optional_common_base const& 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); } } - optional_common_base& operator=(const optional_common_base& other) noexcept( + optional_common_base& operator=(optional_common_base const& other) noexcept( std::is_nothrow_copy_assignable::value) { this->_assign(BSONCXX_FWD(other)); 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 +669,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 +696,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; } @@ -740,9 +725,9 @@ struct optional_base_class { using type = optional_assign_base; }; -template >>::value> +template < + typename T, + 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 @@ -750,33 +735,32 @@ struct optional_hash; template struct optional_hash { optional_hash() = delete; - optional_hash(const optional_hash&) = delete; + optional_hash(optional_hash const&) = delete; }; template struct optional_hash { using Td = bsoncxx::detail::remove_const_t; - constexpr std::size_t operator()(const optional& opt) const - noexcept(noexcept(std::hash()(std::declval()))) { + constexpr std::size_t operator()(optional const& opt) const + noexcept(noexcept(std::hash()(std::declval()))) { return opt.has_value() ? std::hash()(*opt) : std::hash()(nullptr); } }; -} // namespace detail +} // namespace detail -} // namespace stdx +} // namespace stdx -} // namespace v_noabi +} // namespace v_noabi -} // namespace bsoncxx +} // namespace bsoncxx namespace std { template -struct hash> - : bsoncxx::v_noabi::stdx::detail::optional_hash {}; +struct hash> : bsoncxx::v_noabi::stdx::detail::optional_hash {}; -} // namespace std +} // namespace std #else #error "Cannot find a valid polyfill for optional" @@ -794,8 +778,8 @@ using ::bsoncxx::v_noabi::stdx::nullopt; using ::bsoncxx::v_noabi::stdx::nullopt_t; using ::bsoncxx::v_noabi::stdx::optional; -} // namespace stdx -} // namespace bsoncxx +} // namespace stdx +} // namespace bsoncxx /// /// @file @@ -825,8 +809,8 @@ namespace stdx { template class optional {}; -} // namespace stdx -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx -#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) +#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) 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..2a458c4064 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 @@ -27,9 +27,9 @@ namespace stdx { using ::std::basic_string_view; using ::std::string_view; -} // namespace stdx -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx #elif defined(BSONCXX_POLY_USE_IMPLS) @@ -52,7 +52,7 @@ template > class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail::ordering_operators { public: using pointer = Char*; - using const_pointer = const Char*; + using const_pointer = Char const*; using size_type = std::size_t; using difference_type = std::ptrdiff_t; using value_type = Char; @@ -69,24 +69,22 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: public: using traits_type = Traits; using reference = Char&; - using const_reference = const Char&; + using const_reference = Char const&; using const_iterator = const_pointer; using iterator = const_iterator; using const_reverse_iterator = std::reverse_iterator; using reverse_iterator = const_reverse_iterator; 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; + constexpr basic_string_view(basic_string_view const&) noexcept = default; + bsoncxx_cxx14_constexpr basic_string_view& operator=(basic_string_view const&) 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(std::basic_string const& 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,10 +234,9 @@ 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; + size_type const substr_size = pos != npos ? pos + infix.size() : pos; if (infix.empty()) { return (std::min)(pos, size()); } @@ -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; }); } @@ -319,22 +306,18 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: } // Implementation of equality comparison. - constexpr friend bool tag_invoke(bsoncxx::detail::equal_to, - basic_string_view left, - basic_string_view right) noexcept { + constexpr friend bool + tag_invoke(bsoncxx::detail::equal_to, basic_string_view left, basic_string_view right) noexcept { return left.size() == right.size() && left.compare(right) == 0; } // 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; } @@ -343,8 +326,8 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: // returns true for substr(I). If no index exists, returns npos. template bsoncxx_cxx14_constexpr size_type _find_if(size_type pos, F pred) const noexcept { - const auto sub = substr(pos); - const iterator found = std::find_if(sub.begin(), sub.end(), pred); + auto const sub = substr(pos); + iterator const found = std::find_if(sub.begin(), sub.end(), pred); if (found == end()) { return npos; } @@ -356,10 +339,10 @@ class basic_string_view : bsoncxx::detail::equality_operators, bsoncxx::detail:: template bsoncxx_cxx14_constexpr size_type _rfind_if(size_type pos, F pred) const noexcept { // Adjust 'pos' for an inclusive range in substr() - const auto rpos = pos == npos ? npos : pos + 1; + auto const rpos = pos == npos ? npos : pos + 1; // The substring that will be searched: - const auto prefix = substr(0, rpos); - const const_reverse_iterator found = std::find_if(prefix.rbegin(), prefix.rend(), pred); + auto const prefix = substr(0, rpos); + const_reverse_iterator const found = std::find_if(prefix.rbegin(), prefix.rend(), pred); if (found == rend()) { return npos; } @@ -375,23 +358,22 @@ constexpr std::size_t basic_string_view::npos; using string_view = basic_string_view; -} // namespace stdx -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx 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()(bsoncxx::v_noabi::stdx::basic_string_view const& str) const { return std::hash>::operator()( std::basic_string(str.data(), str.size())); } }; -} // namespace std +} // namespace std #else #error "Cannot find a valid polyfill for string_view" @@ -405,8 +387,8 @@ namespace stdx { using ::bsoncxx::v_noabi::stdx::basic_string_view; using ::bsoncxx::v_noabi::stdx::string_view; -} // namespace stdx -} // namespace bsoncxx +} // namespace stdx +} // namespace bsoncxx /// /// @file @@ -435,8 +417,8 @@ namespace stdx { /// class string_view {}; -} // namespace stdx -} // namespace v_noabi -} // namespace bsoncxx +} // namespace stdx +} // namespace v_noabi +} // namespace bsoncxx -#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) +#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) 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..670302fedf 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 @@ -62,7 +62,7 @@ using remove_cvref_t = remove_cv_t>; // Create a reference-to-const for the given type template -using const_reference_t = add_lvalue_reference_t>; +using const_reference_t = add_lvalue_reference_t const>; // Workaround for CWG issue 1558. template @@ -144,13 +144,13 @@ struct vc140_detection>, Oper, Args...> { using type = Oper; }; -} // namespace impl_detection +} // namespace impl_detection // The type yielded by detected_t if the given type operator does not yield a type. struct nonesuch { ~nonesuch() = delete; - nonesuch(const nonesuch&) = delete; - void operator=(const nonesuch&) = delete; + nonesuch(nonesuch const&) = delete; + void operator=(nonesuch const&) = delete; }; // Results in true_type if the given metafunction yields a valid type when applied to the given @@ -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