ANNA Suite  2020b
Multipurpose development suite for Telco applications
Float.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_Float_hpp
10 #define anna_dbms_Float_hpp
11 
13 
14 #include <anna/dbms/Data.hpp>
15 
16 namespace anna {
17 
18 namespace dbms {
19 
23 class Float : public Data {
24 public:
31  explicit Float(const bool isNulleable = false, const char* format = "%f") :
32  Data(Type::Float, sizeof(float), isNulleable),
33  a_format(format),
34  a_value(0.0) {
35  Data::setBuffer(&a_value);
36  }
37 
42  Float(const Float& other) : Data(other), a_value(other.a_value), a_format(other.a_format) {
43  Data::setBuffer(&a_value);
44  }
45 
52  //float getFloatValue () const { return getValue (); }
53 
58  float getValue() const { return a_value; }
59 
64  const char* getFormat() const { return a_format; }
65 
71  Float& operator = (const Float& other) noexcept(false) {
72  if(this != &other) {
73  setNull(other.isNull());
74  a_value = other.a_value;
75  }
76 
77  return *this;
78  }
79 
85  Float& operator = (const float value) noexcept(false) {
86  a_value = value;
87  setNull(false);
88  return *this;
89  }
90 
96  operator float() const { return getValue(); }
97 
102  std::string asString() const ;
103 
104 private:
105  float a_value;
106  const char* a_format;
107 
108  void do_clear() { a_value = 0.0; }
109 };
110 
111 }
112 }
113 
114 #endif
115 
std::string asString() const
Definition: Float.hpp:23
void setBuffer(void *buffer)
Definition: Data.hpp:131
const char * getFormat() const
Definition: Float.hpp:64
Float & operator=(const Float &other) noexcept(false)
Definition: Float.hpp:71
float getValue() const
Definition: Float.hpp:58
Float(const Float &other)
Definition: Float.hpp:42
Definition: Data.hpp:29
Definition: Data.hpp:27
Definition: app.hpp:12
void setNull(const bool isNull)
Definition: Data.hpp:76
bool isNulleable() const
Definition: Data.hpp:68
Float(const bool isNulleable=false, const char *format="%f")
Definition: Float.hpp:31