ANNA Suite  2020b
Multipurpose development suite for Telco applications
Integer.hpp
Go to the documentation of this file.
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 
21 class Integer : public Data {
22 public:
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 
37  Integer(const Integer& other) :
38  Data(other),
39  a_value(other.a_value) {
40  Data::setBuffer(&a_value);
41  }
42 
47  int getValue() const { return a_value; }
48 
54  Integer& operator = (const int i)
55  {
56  a_value = i;
57  Data::setNull(false);
58  return *this;
59  }
60 
66  Integer& operator = (const Integer& other)
67  {
68  if(this != &other) {
69  setNull(other.isNull());
70  a_value = other.a_value;
71  }
72 
73  return *this;
74  }
75 
80  operator int () const { return a_value; }
81 
86  std::string asString() const ;
87 
88 private:
89  int a_value;
90 
91  void do_clear() { a_value = 0; }
92 };
93 
94 }
95 }
96 
97 #endif
98 
bool isNull() const
Definition: Data.hpp:62
void setBuffer(void *buffer)
Definition: Data.hpp:131
Integer & operator=(const int i)
Definition: Integer.hpp:54
std::string asString() const
Definition: Data.hpp:29
Definition: Data.hpp:27
Integer(const bool isNulleable=false)
Definition: Integer.hpp:27
Integer(const Integer &other)
Definition: Integer.hpp:37
Definition: Integer.hpp:21
Definition: app.hpp:12
void setNull(const bool isNull)
Definition: Data.hpp:76
bool isNulleable() const
Definition: Data.hpp:68
int getValue() const
Definition: Integer.hpp:47