dvalue.h
1 /*
2  * Nebula Atom
3 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #ifndef NAF_TOOLS_DVALUE
20 #define NAF_TOOLS_DVALUE
21 
22 
23 #include <string>
24 #include <stdexcept>
25 
26 #include <Poco/Dynamic/Var.h>
27 #include "Poco/DateTimeParser.h"
28 #include "Poco/DateTime.h"
29 #include "Poco/DateTimeFormat.h"
30 #include "Poco/DateTimeFormatter.h"
31 #include "Poco/Timestamp.h"
32 
33 #include "tools/output_logger.h"
34 
35 
36 namespace NAF
37 {
38  namespace Tools
39  {
40  class DValue;
41  }
42 }
43 
44 using namespace Poco;
45 
46 
48 {
49  public:
50  enum class Type
51  {
52  kEmpty
53  ,kString
54  ,kInteger
55  ,kFloat
56  ,kBoolean
57  };
58 
59  DValue();
60  DValue(Poco::Dynamic::Var& value);
61  DValue(std::string value_string);
62  DValue(char value_string);
63  DValue(const char* value_string);
64  DValue(int value_int);
65  DValue(float value_float);
66  DValue(bool value_bool);
67  ~DValue(){}
68 
69  Type& get_type()
70  {
71  auto& var = type_;
72  return var;
73  }
74  std::string& get_value_string()
75  {
76  auto& var = value_string_;
77  return var;
78  }
79  int& get_value_int()
80  {
81  auto& var = value_int_;
82  return var;
83  }
84  float& get_value_float()
85  {
86  auto& var = value_float_;
87  return var;
88  }
89  bool& get_value_bool()
90  {
91  auto& var = value_bool_;
92  return var;
93  }
94 
95  bool operator==(DValue& dvalue);
96  bool operator!=(DValue& dvalue);
97  bool operator<(DValue& dvalue);
98  bool operator<=(DValue& dvalue);
99  bool operator>(DValue& dvalue);
100  bool operator>=(DValue& dvalue);
101  bool TypeIsIqual_(Type row_value_type);
102  std::string ToString_();
103 
104  protected:
105  void Format_(Poco::Dynamic::Var& value);
106 
107  private:
108  Type type_;
109 
110  std::string value_string_;
111  int value_int_;
112  float value_float_;
113  bool value_bool_;
114 
115 };
116 
117 
118 #endif // NAF_TOOLS_DVALUE
Definition: dvalue.h:48