Add no-deprecated to warnings due to dynamic exceptions.
[anna.git] / include / anna / dbms / Integer.hpp
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 #ifndef anna_dbms_Integer_hpp
10 #define anna_dbms_Integer_hpp
11
12 #include <anna/dbms/Data.hpp>
13
14 namespace anna {
15
16 namespace dbms {
17
18 /**
19    Cadena usada como entrada y/o salida de las sentencias SQL.
20 */
21 class Integer : public Data {
22 public:
23   /**
24      Constructor.
25      \param isNulleable Indica si el dato puede tomar valores nulos
26   */
27   explicit Integer(const bool isNulleable = false) :
28     Data(Type::Integer, sizeof(int), isNulleable),
29     a_value(0) {
30     Data::setBuffer(&a_value);
31   }
32
33   /**
34      Constructor copia.
35      \param other Instancia de la que copiar.
36   */
37   Integer(const Integer& other) :
38     Data(other),
39     a_value(other.a_value) {
40     Data::setBuffer(&a_value);
41   }
42
43   /**
44      Devuelve el valor entero asociado a esta instancia.
45      \return El valor entero asociado a esta instancia.
46   */
47   int getValue() const throw() { return a_value; }
48
49   /**
50      Operador de asignacin entero.
51      \param i Valor entero a asignar.
52      \return La referencia a esta instancia.
53   */
54   Integer& operator = (const int i)
55   throw() {
56     a_value = i;
57     Data::setNull(false);
58     return *this;
59   }
60
61   /**
62      Operador copia.
63      \param other Instancia de la que copiar.
64      \return La referencia a esta instancia.
65   */
66   Integer& operator = (const Integer& other)
67   throw() {
68     if(this != &other) {
69       setNull(other.isNull());
70       a_value = other.a_value;
71     }
72
73     return *this;
74   }
75
76   /**
77      Operador de conversion.
78      \return El valor entero asociado a esta instancia.
79   */
80   operator int () const throw() { return a_value; }
81
82   /**
83      Devuelve una cadena con la informacion referente a esta instancia.
84      @return Una cadena con la informacion referente a esta instancia.
85   */
86   std::string asString() const throw();
87
88 private:
89   int a_value;
90
91   void do_clear() throw() { a_value = 0; }
92 };
93
94 }
95 }
96
97 #endif
98