field.h
1 /*
2  * <one line to give the program's name and a brief idea of what it does.>
3  * Copyright (C) 2023 Jose F Rivas C <josefelixrc7@gmail.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef NAF_QUERY_FIELD
20 #define NAF_QUERY_FIELD
21 
22 
23 #include <string>
24 
25 #include "tools/dvalue.h"
26 
27 
28 namespace NAF
29 {
30  namespace Query
31  {
32  class Field;
33  }
34 }
35 
36 
38 {
39  public:
40  using Ptr = std::shared_ptr<Field>;
41 
42  struct Position
43  {
44  Position(std::size_t row, std::size_t column) : row(row), column(column) {}
45 
46  std::size_t row;
47  std::size_t column;
48  };
49 
50  Field();
51  Field(std::string column_name, Tools::DValue value);
52 
53  std::string get_column_name() const { return column_name_;}
54  Tools::DValue get_value() const {return value_;}
55  Tools::DValue& get_value()
56  {
57  auto& var = value_;
58  return var;
59  }
60 
61  void set_column_name(std::string column_name) { column_name_ = column_name;}
62  void set_value(Tools::DValue value) { value_ = value;}
63 
64  bool IsNull_();
65  std::string ToString_();
66  std::string& String_();
67  float& Float_();
68  bool& Bool_();
69  int& Int_();
70 
71  private:
72  bool is_null_;
73  std::string column_name_;
74  Tools::DValue value_;
75 };
76 
77 
78 #endif // NAF_QUERY_FIELD
Definition: field.h:38
Definition: dvalue.h:48
Definition: field.h:43