Revert "Remove mysql and oracle resources for anna-ericsson project"
[anna.git] / include / anna / dbms / Integer.hpp
diff --git a/include/anna/dbms/Integer.hpp b/include/anna/dbms/Integer.hpp
new file mode 100644 (file)
index 0000000..ce98691
--- /dev/null
@@ -0,0 +1,98 @@
+// 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_Integer_hpp
+#define anna_dbms_Integer_hpp
+
+#include <anna/dbms/Data.hpp>
+
+namespace anna {
+
+namespace dbms {
+
+/**
+   Cadena usada como entrada y/o salida de las sentencias SQL.
+*/
+class Integer : public Data {
+public:
+  /**
+     Constructor.
+     \param isNulleable Indica si el dato puede tomar valores nulos
+  */
+  explicit Integer(const bool isNulleable = false) :
+    Data(Type::Integer, sizeof(int), isNulleable),
+    a_value(0) {
+    Data::setBuffer(&a_value);
+  }
+
+  /**
+     Constructor copia.
+     \param other Instancia de la que copiar.
+  */
+  Integer(const Integer& other) :
+    Data(other),
+    a_value(other.a_value) {
+    Data::setBuffer(&a_value);
+  }
+
+  /**
+     Devuelve el valor entero asociado a esta instancia.
+     \return El valor entero asociado a esta instancia.
+  */
+  int getValue() const throw() { return a_value; }
+
+  /**
+     Operador de asignacin entero.
+     \param i Valor entero a asignar.
+     \return La referencia a esta instancia.
+  */
+  Integer& operator = (const int i)
+  throw() {
+    a_value = i;
+    Data::setNull(false);
+    return *this;
+  }
+
+  /**
+     Operador copia.
+     \param other Instancia de la que copiar.
+     \return La referencia a esta instancia.
+  */
+  Integer& operator = (const Integer& other)
+  throw() {
+    if(this != &other) {
+      setNull(other.isNull());
+      a_value = other.a_value;
+    }
+
+    return *this;
+  }
+
+  /**
+     Operador de conversion.
+     \return El valor entero asociado a esta instancia.
+  */
+  operator int () const throw() { return a_value; }
+
+  /**
+     Devuelve una cadena con la informacion referente a esta instancia.
+     @return Una cadena con la informacion referente a esta instancia.
+  */
+  std::string asString() const throw();
+
+private:
+  int a_value;
+
+  void do_clear() throw() { a_value = 0; }
+};
+
+}
+}
+
+#endif
+