1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
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 //
9 #include <anna/core/tracing/TraceMethod.hpp>
11 #include <anna/xml/Node.hpp>
12 #include <anna/xml/Attribute.hpp>
14 #include <anna/dbms/Statement.hpp>
15 #include <anna/dbms/InputBind.hpp>
16 #include <anna/dbms/OutputBind.hpp>
17 #include <anna/dbms/Database.hpp>
21 using namespace anna::dbms;
23 Statement::~Statement() {
27 for(input_iterator ii = input_begin(), maxii = input_end(); ii != maxii; ii ++) {
28 ibind = inputBind(ii);
30 a_database.deallocate(ibind);
33 for(output_iterator ii = output_begin(), maxii = output_end(); ii != maxii; ii ++) {
34 obind = outputBind(ii);
36 a_database.deallocate(obind);
40 string Statement::asString() const
42 string result("dbms::Statement { Nombre: ");
44 result += functions::asText(" | Var.Entrada: ", input_size());
45 result += functions::asText(" | Var.Salida: ", output_size());
47 result += a_measureTiming.asString();
48 result += " | Expresion: ";
49 result += a_expression;
50 return result += " }";
53 xml::Node* dbms::Statement::asXML(xml::Node* parent) const
55 xml::Node* result = parent->createChild("dbms.Statement");
56 result->createAttribute("Name", a_name);
57 xml::Node* node = result->createChild("Timing");
58 node->createAttribute("N", a_measureTiming.size());
59 node->createAttribute("Accumulator", a_measureTiming.getAccumulator());
60 node->createAttribute("Timing", a_measureTiming.asString());
61 result->createChild("Expression")->createText(a_expression);
65 void Statement::bindInput(const char* name, Data& data)
67 a_inputBinds.push_back(a_database.allocateInputBind(name, data));
70 const OutputBind* Statement::bindOutput(const char* name, Data& i)
72 OutputBind* result = a_database.allocateOutputBind(name, i);
73 a_outputBinds.push_back(result);
77 Data& Statement::input(input_iterator& ii)
79 return (*ii)->getData();
82 Data& Statement::output(output_iterator& ii)
84 return (*ii)->getData();