Add no-deprecated to warnings due to dynamic exceptions.
[anna.git] / source / dbms.mysql / Database.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #include <string.h>
10
11 #include <anna/core/tracing/Logger.hpp>
12 #include <anna/core/tracing/TraceMethod.hpp>
13
14 #include <anna/dbms.mysql/mysql.hpp>
15 #include <anna/dbms.mysql/internal/sccs.hpp>
16
17 using namespace std;
18 using namespace anna;
19 using namespace anna::dbms;
20
21 mysql::Database::Database(const char* dbmsName, const char* host) :
22   dbms::Database(getClassName(), dbmsName) {
23   a_host = (host == NULL) ? NULL : strdup(host);
24   mysql::sccs::activate();
25 }
26
27 mysql::Database::Database(const char* componentName, const char* dbmsName, const char* host) :
28   dbms::Database(componentName, dbmsName) {
29   a_host = (host == NULL) ? NULL : strdup(host);
30   mysql::sccs::activate();
31 }
32
33 void mysql::Database::do_initialize()
34 throw(RuntimeException) {
35   LOGMETHOD(TraceMethod tm("anna::dbms::mysql::Database", "do_initialize", ANNA_FILE_LOCATION));
36   dbms::Database::do_initialize();
37 }
38
39 //----------------------------------------------------------------------------------
40 // Libera todos los manejadores asociados a este entorno.
41 //----------------------------------------------------------------------------------
42 mysql::Database::~Database() {
43   LOGMETHOD(TraceMethod tm("anna::dbms::mysql::Database", "~Database", ANNA_FILE_LOCATION));
44
45   if(a_host != NULL)
46     free(a_host);
47 }
48
49 dbms::Connection* mysql::Database::allocateConnection(const std::string& name, const char* user, const char* password)
50 throw(RuntimeException) {
51   return new Connection(*this, name, user, password);
52 }
53
54 dbms::Statement* mysql::Database::allocateStatement(const char* name, const std::string& expression, const bool isCritical)
55 throw(RuntimeException) {
56   return new Statement(*this, name, expression, isCritical);
57 }
58
59 dbms::InputBind* mysql::Database::allocateInputBind(const char* name, Data& data)
60 throw(RuntimeException) {
61   return new InputBind(name, data);
62 }
63
64 void mysql::Database::deallocate(dbms::InputBind* inputBind)
65 throw() {
66   delete(InputBind*) inputBind;
67 }
68
69 dbms::OutputBind* mysql::Database::allocateOutputBind(const char* name, Data& data)
70 throw(RuntimeException) {
71   return new OutputBind(name, data);
72 }
73
74 void mysql::Database::deallocate(dbms::OutputBind* outputBind)
75 throw() {
76   delete(OutputBind*) outputBind;
77 }