Loading...
Searching...
No Matches
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
36namespace NAF
37{
38 namespace Tools
39 {
40 class DValue;
41 }
42}
43
44using 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(const char* value_string);
65 DValue(int value_int);
66 DValue(float value_float);
67 DValue(bool value_bool);
68 ~DValue(){}
69
70 Type& get_type()
71 {
72 auto& var = type_;
73 return var;
74 }
75
76 bool operator==(DValue& dvalue);
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 TypeIsIqual_(Type row_value_type);
83 std::string ToString_();
84 std::string& String_();
85 float& Float_();
86 bool& Bool_();
87 int& Int_();
88
89 protected:
90 std::string& get_value_string()
91 {
92 auto& var = value_string_;
93 return var;
94 }
95 int& get_value_int()
96 {
97 auto& var = value_int_;
98 return var;
99 }
100 float& get_value_float()
101 {
102 auto& var = value_float_;
103 return var;
104 }
105 bool& get_value_bool()
106 {
107 auto& var = value_bool_;
108 return var;
109 }
110
111 void Format_(Poco::Dynamic::Var& value);
112
113 private:
114 Type type_;
115
116 std::string value_string_;
117 int value_int_;
118 float value_float_;
119 bool value_bool_;
120
121};
122
123
124#endif // NAF_TOOLS_DVALUE
Definition dvalue.h:48