3333#include < mongocxx/options/server_api.hpp>
3434#include < mongocxx/uri.hpp>
3535
36- // NOTE: Any time this file is modified, a DOCS ticket should be opened to sync the changes with the
37- // corresponding page on mongodb.com/docs. See CXX-1249 and DRIVERS-356 for more info.
36+ namespace {
3837
3938template <typename T>
4039void check_field (const T& document,
@@ -141,7 +140,7 @@ std::string getenv_or_fail(const char* s) {
141140// Returns a document with credentials for KMS providers.
142141// If include_external is true, all KMS providers are set.
143142// If include_external is false, only the local provider is set.
144- bsoncxx::document::value _make_kms_doc (bool include_external = true ) {
143+ bsoncxx::document::value make_kms_doc (bool include_external = true ) {
145144 using bsoncxx::builder::basic::sub_document;
146145 using bsoncxx::builder::stream::close_array;
147146 using bsoncxx::builder::stream::close_document;
@@ -1442,19 +1441,19 @@ static bool is_snapshot_ready(mongocxx::client& client, mongocxx::collection& co
14421441 opts.snapshot (true );
14431442
14441443 auto session = client.start_session (opts);
1444+
14451445 try {
1446- auto maybe_value = collection.find_one (session, {});
1447- if (maybe_value) {
1446+ if (collection.find_one (session, {})) {
14481447 return true ;
14491448 }
1450- return false ;
14511449 } catch (const mongocxx::operation_exception& e) {
14521450 if (e.code ().value () == 246 ) { // snapshot unavailable
14531451 return false ;
14541452 }
14551453 throw ;
14561454 }
1457- return true ;
1455+
1456+ return false ;
14581457}
14591458
14601459// Seed the pets database and wait for the snapshot to become available.
@@ -1612,7 +1611,7 @@ static void queryable_encryption_api(mongocxx::client& client) {
16121611 options::client_encryption ce_opts;
16131612 ce_opts.key_vault_client (&key_vault_client);
16141613 ce_opts.key_vault_namespace ({" keyvault" , " datakeys" });
1615- ce_opts.kms_providers (_make_kms_doc (false ));
1614+ ce_opts.kms_providers (make_kms_doc (false ));
16161615 client_encryption client_encryption (std::move (ce_opts));
16171616
16181617 auto key1_id = client_encryption.create_data_key (" local" );
@@ -1634,7 +1633,7 @@ static void queryable_encryption_api(mongocxx::client& client) {
16341633 // Create an Queryable Encryption collection.
16351634 options::auto_encryption auto_encrypt_opts{};
16361635 auto_encrypt_opts.key_vault_namespace ({" keyvault" , " datakeys" });
1637- auto_encrypt_opts.kms_providers (_make_kms_doc (false ));
1636+ auto_encrypt_opts.kms_providers (make_kms_doc (false ));
16381637 auto_encrypt_opts.encrypted_fields_map (encrypted_fields_map.view ());
16391638
16401639 // Optional, If mongocryptd is not in PATH, then find the binary at MONGOCRYPTD_PATH.
@@ -1699,6 +1698,8 @@ static void queryable_encryption_api(mongocxx::client& client) {
16991698 // End Queryable Encryption Example
17001699}
17011700
1701+ } // namespace
1702+
17021703int main () {
17031704 // The mongocxx::instance constructor and destructor initialize and shut down the driver,
17041705 // respectively. Therefore, a mongocxx::instance must be created before using the driver and
0 commit comments