X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Fdbms%2FInteger.hpp;fp=include%2Fanna%2Fdbms%2FInteger.hpp;h=ce98691aaaa99fc383c454ff479a269fbb05d0ca;hb=78be86969d2f26a9084b0c4af6ce43d5fa4ed3fd;hp=0000000000000000000000000000000000000000;hpb=a3b95648bd76140ef55e0b5941d423eee6c3856f;p=anna.git diff --git a/include/anna/dbms/Integer.hpp b/include/anna/dbms/Integer.hpp new file mode 100644 index 0000000..ce98691 --- /dev/null +++ b/include/anna/dbms/Integer.hpp @@ -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 + +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 +