From d240a1c0fe3cbfb9486dbecdd0f6852b00714fe9 Mon Sep 17 00:00:00 2001 From: L101Danzan Date: Tue, 13 Feb 2024 14:06:29 +0200 Subject: [PATCH] Headers for functions --- ToToCinema/AT.cpp | 0 ToToCinema/AT.h | 0 ToToCinema/DD.cpp | 11 +++++++++++ ToToCinema/DD.h | 17 +++++++++++++++++ ToToCinema/EN.cpp | 0 ToToCinema/EN.h | 0 ToToCinema/Source.cpp | 36 +++++------------------------------- ToToCinema/VE.cpp | 0 ToToCinema/VE.h | 0 9 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 ToToCinema/AT.cpp create mode 100644 ToToCinema/AT.h create mode 100644 ToToCinema/DD.cpp create mode 100644 ToToCinema/DD.h create mode 100644 ToToCinema/EN.cpp create mode 100644 ToToCinema/EN.h create mode 100644 ToToCinema/VE.cpp create mode 100644 ToToCinema/VE.h diff --git a/ToToCinema/AT.cpp b/ToToCinema/AT.cpp new file mode 100644 index 0000000..e69de29 diff --git a/ToToCinema/AT.h b/ToToCinema/AT.h new file mode 100644 index 0000000..e69de29 diff --git a/ToToCinema/DD.cpp b/ToToCinema/DD.cpp new file mode 100644 index 0000000..a432fed --- /dev/null +++ b/ToToCinema/DD.cpp @@ -0,0 +1,11 @@ +//#include +//#include +//#include "DD.h" +//using namespace std; +// +//int main() { +// string database = "mongodb+srv://Danzan:@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority"; +// database = getDatabaseLink(database); +// cout << database; +// return 0; +//} \ No newline at end of file diff --git a/ToToCinema/DD.h b/ToToCinema/DD.h new file mode 100644 index 0000000..6054e98 --- /dev/null +++ b/ToToCinema/DD.h @@ -0,0 +1,17 @@ +#include +#include +#include "config.h" +using namespace std; + + +string getDatabaseLink(string database) { + string password = get_password(); + cout << password << endl; + try { + database.replace(21, 10, password); + } + catch (...) { + cout << "Error finding password\n"; + } + return database; +} \ No newline at end of file diff --git a/ToToCinema/EN.cpp b/ToToCinema/EN.cpp new file mode 100644 index 0000000..e69de29 diff --git a/ToToCinema/EN.h b/ToToCinema/EN.h new file mode 100644 index 0000000..e69de29 diff --git a/ToToCinema/Source.cpp b/ToToCinema/Source.cpp index a92ec44..7449b95 100644 --- a/ToToCinema/Source.cpp +++ b/ToToCinema/Source.cpp @@ -1,38 +1,12 @@ #include #include -#include "config.h" -#include -#include -#include +#include "DD.h" + using namespace std; -string password = db_password; - int main() { - string database = "mongodb+srv://Danzan:@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority"; - database.replace(21, 10, password); - cout << database; - try - { - // Create an instance. - mongocxx::instance inst{}; - const auto uri = mongocxx::uri{ "mongodb+srv://Danzan:@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority" }; - // Set the version of the Stable API on the client - mongocxx::options::client client_options; - const auto api = mongocxx::options::server_api{ mongocxx::options::server_api::version::k_version_1 }; - client_options.server_api_opts(api); - // Setup the connection and get a handle on the "admin" database. - mongocxx::client conn{ uri, client_options }; - mongocxx::database db = conn["admin"]; - // Ping the database. - const auto ping_cmd = bsoncxx::builder::basic::make_document(bsoncxx::builder::basic::kvp("ping", 1)); - db.run_command(ping_cmd.view()); - std::cout << "Pinged your deployment. You successfully connected to MongoDB!" << std::endl; - } - catch (const std::exception& e) - { - // Handle errors - std::cout << "Exception: " << e.what() << std::endl; - //} + string database = "mongodb+srv://Danzan:@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority"; + database = getDatabaseLink(database); + cout << database; return 0; } \ No newline at end of file diff --git a/ToToCinema/VE.cpp b/ToToCinema/VE.cpp new file mode 100644 index 0000000..e69de29 diff --git a/ToToCinema/VE.h b/ToToCinema/VE.h new file mode 100644 index 0000000..e69de29