ANNA Suite  2020b
Multipurpose development suite for Telco applications
Data.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_Data_hpp
10 #define anna_dbms_Data_hpp
11 
12 #include <string>
13 
14 #include <anna/config/defines.hpp>
15 #include <anna/core/functions.hpp>
17 
18 namespace anna {
19 
20 namespace dbms {
21 
22 class Bind;
23 
27 class Data {
28 public:
29  struct Type {
30  enum _v {
36  Date,
38  };
39  };
40 
45  int getMaxSize() const { return a_maxSize; }
46 
51  Type::_v getType() const { return a_type; }
52 
56  void* getBuffer() { return a_buffer; }
57 
62  bool isNull() const { return a_isNull; }
63 
68  bool isNulleable() const { return a_isNulleable; }
69 
76  void setNull(const bool isNull) { if(a_isNulleable == true) a_isNull = isNull; }
77 
86  void clear() {
87  setNull(true);
88  do_clear();
89  }
90 
95  virtual std::string asString() const ;
96 
97 protected:
107  explicit Data(const Type::_v type, const int maxSize, const bool isNulleable) :
108  a_type(type),
109  a_maxSize(maxSize),
110  a_isNulleable(isNulleable),
111  a_isNull(isNulleable),
112  a_buffer(NULL)
113  {;}
114 
119  Data(const Data& other) :
120  a_type(other.a_type),
121  a_maxSize(other.a_maxSize),
122  a_isNulleable(other.a_isNulleable),
123  a_isNull(other.a_isNull),
124  a_buffer(other.a_buffer)
125  {;}
126 
131  void setBuffer(void* buffer) { a_buffer = buffer; }
132 
133 private:
134  const Type::_v a_type;
135  const int a_maxSize;
136  const bool a_isNulleable;
137  void* a_buffer;
138  bool a_isNull;
139 
140  virtual void do_clear() = 0;
141 };
142 
143 }
144 }
145 
146 #endif
147 
void clear()
Definition: Data.hpp:86
_v
Definition: Data.hpp:30
Data(const Type::_v type, const int maxSize, const bool isNulleable)
Definition: Data.hpp:107
bool isNull() const
Definition: Data.hpp:62
void setBuffer(void *buffer)
Definition: Data.hpp:131
Type::_v getType() const
Definition: Data.hpp:51
Definition: Data.hpp:35
Data(const Data &other)
Definition: Data.hpp:119
Definition: Data.hpp:29
Definition: Data.hpp:27
Definition: TimeStamp.hpp:25
int getMaxSize() const
Definition: Data.hpp:45
Definition: Data.hpp:31
Definition: Data.hpp:32
Definition: Data.hpp:34
Definition: app.hpp:12
Definition: Data.hpp:36
void setNull(const bool isNull)
Definition: Data.hpp:76
bool isNulleable() const
Definition: Data.hpp:68
Definition: Data.hpp:33
virtual std::string asString() const
void * getBuffer()
Definition: Data.hpp:56