Alison Craig | 2a4d528 | 2015-04-10 12:00:02 -0600 | [diff] [blame] | 1 | /** NDN-Atmos: Cataloging Service for distributed data originally developed |
| 2 | * for atmospheric science data |
| 3 | * Copyright (C) 2015 Colorado State University |
| 4 | * |
| 5 | * NDN-Atmos is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * NDN-Atmos is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with NDN-Atmos. If not, see <http://www.gnu.org/licenses/>. |
| 17 | **/ |
| 18 | |
| 19 | #ifndef ATMOS_UTIL_CONNECTION_DETAILS_HPP |
| 20 | #define ATMOS_UTIL_CONNECTION_DETAILS_HPP |
| 21 | |
| 22 | #include "mysql/mysql.h" |
| 23 | |
| 24 | #include <memory> |
| 25 | #include <string> |
| 26 | |
| 27 | namespace atmos { |
| 28 | namespace util { |
Chengyu Fan | 4639821 | 2015-08-11 11:23:13 -0600 | [diff] [blame] | 29 | enum DatabaseOperation {CREATE, UPDATE, ADD, REMOVE, QUERY}; |
Alison Craig | 2a4d528 | 2015-04-10 12:00:02 -0600 | [diff] [blame] | 30 | struct ConnectionDetails { |
| 31 | public: |
| 32 | std::string server; |
| 33 | std::string user; |
| 34 | std::string password; |
| 35 | std::string database; |
| 36 | |
| 37 | ConnectionDetails(const std::string& serverInput, const std::string& userInput, |
| 38 | const std::string& passwordInput, const std::string& databaseInput); |
| 39 | }; |
| 40 | |
| 41 | std::shared_ptr<MYSQL> |
Chengyu Fan | b25835b | 2015-04-28 17:09:35 -0600 | [diff] [blame] | 42 | MySQLConnectionSetup(const ConnectionDetails& details); |
Alison Craig | 2a4d528 | 2015-04-10 12:00:02 -0600 | [diff] [blame] | 43 | |
| 44 | std::shared_ptr<MYSQL_RES> |
Chengyu Fan | 4639821 | 2015-08-11 11:23:13 -0600 | [diff] [blame] | 45 | MySQLPerformQuery(std::shared_ptr<MYSQL> connection, |
| 46 | const std::string& sql_query, |
| 47 | DatabaseOperation op, |
| 48 | bool& success, |
| 49 | std::string& errMsg); |
Alison Craig | 2a4d528 | 2015-04-10 12:00:02 -0600 | [diff] [blame] | 50 | |
| 51 | } // namespace util |
| 52 | } // namespace atmos |
| 53 | #endif //ATMOS_UTIL_CONNECTION_DETAILS_HPP |