Revert "Remove mysql and oracle resources for anna-ericsson project"
[anna.git] / include / anna / dbms.mysql / OutputBind.hpp
diff --git a/include/anna/dbms.mysql/OutputBind.hpp b/include/anna/dbms.mysql/OutputBind.hpp
new file mode 100644 (file)
index 0000000..72e9929
--- /dev/null
@@ -0,0 +1,68 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef anna_dbms_mysql_OutputBind_hpp
+#define anna_dbms_mysql_OutputBind_hpp
+
+#include <anna/core/DataBlock.hpp>
+
+#include <anna/dbms/OutputBind.hpp>
+#include <anna/dbms/DatabaseException.hpp>
+
+#include <anna/dbms.mysql/BaseBind.hpp>
+
+namespace anna {
+
+class DataBlock;
+
+namespace dbms {
+
+class Statement;
+
+namespace mysql {
+
+class OutputBind : public dbms::OutputBind, public BaseBind {
+public:
+  OutputBind(const char* name, dbms::Data& data);
+  ~OutputBind();
+
+private:
+  struct Blob {
+    DataBlock buffer;
+    st_mysql_stmt* stmt;
+    st_mysql_bind* binds;
+    int pos;
+
+    Blob();
+  };
+
+  Blob* a_blob;
+
+  void decodeLongBlob(dbms::Data&) const throw(RuntimeException, dbms::DatabaseException);
+  void decodeDate(dbms::Data&) throw();
+
+  static unsigned char asByte(const char hex)
+  throw() {
+    return (hex >= '0' && hex <= '9') ? (hex - '0') : ((hex - 'A') + 0x0a);
+  }
+
+  /* Funciones virtuales puras */
+  void decode() const throw(RuntimeException);
+  void prepare(anna::dbms::Statement*, anna::dbms::Connection*, const int pos) throw(RuntimeException);
+  void release(anna::dbms::Statement*) throw() {;}
+  void do_write(const dbms::LongBlock&) const throw(RuntimeException, dbms::DatabaseException);
+
+  friend class Statement;
+};
+
+}
+}
+}
+
+#endif
+