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  using Ptr = std::shared_ptr<DValue>;
51 
52  enum class Type
53  {
54  kEmpty
55  ,kString
56  ,kInteger
57  ,kFloat
58  ,kBoolean
59  };
60 
61  DValue();
62  DValue(Poco::Dynamic::Var& value);
63  DValue(std::string value_string);
64  DValue(char value_string);
65  DValue(const char* value_string);
66  DValue(int value_int);
67  DValue(float value_float);
68  DValue(bool value_bool);
69  ~DValue(){}
70 
71  Type& get_type()
72  {
73  auto& var = type_;
74  return var;
75  }
76 
77  bool operator==(DValue& dvalue);
78  bool operator!=(DValue& dvalue);
79  bool operator<(DValue& dvalue);
80  bool operator<=(DValue& dvalue);
81  bool operator>(DValue& dvalue);
82  bool operator>=(DValue& dvalue);
83  bool TypeIsIqual_(Type row_value_type);
84  std::string ToString_();
85  std::string& String_();
86  float& Float_();
87  bool& Bool_();
88  int& Int_();
89 
90  protected:
91  std::string& get_value_string()
92  {
93  auto& var = value_string_;
94  return var;
95  }
96  int& get_value_int()
97  {
98  auto& var = value_int_;
99  return var;
100  }
101  float& get_value_float()
102  {
103  auto& var = value_float_;
104  return var;
105  }
106  bool& get_value_bool()
107  {
108  auto& var = value_bool_;
109  return var;
110  }
111 
112  void Format_(Poco::Dynamic::Var& value);
113 
114  private:
115  Type type_;
116 
117  std::string value_string_;
118  int value_int_;
119  float value_float_;
120  bool value_bool_;
121 
122 };
123 
124 
125 #endif // NAF_TOOLS_DVALUE
Definition: dvalue.h:48