summary refs log tree commit diff stats
path: root/lib/binding.h
blob: 5da1e714797cda3d71297aafc27ae96328994f32 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef BINDING_H_CAE0B18E
#define BINDING_H_CAE0B18E

#include <string>

namespace verbly {

  class binding {
    public:
      enum class type {
        invalid,
        integer,
        string,
        field
      };

      // Default constructor

      binding()
      {
      }

      // Copy and move constructors

      binding(const binding& other);
      binding(binding&& other);

      // Assignment

      binding& operator=(binding other);

      // Swap

      friend void swap(binding& first, binding& second);

      // Destructor

      ~binding();

      // Generic accessors

      type getType() const
      {
        return type_;
      }

      // Integer

      binding(int arg);

      int getInteger() const;

      // String

      binding(std::string arg);

      std::string getString() const;

      // Field

      binding(std::string table, std::string column);

      std::string getTable() const;
      std::string getColumn() const;

    private:

      union {
        int integer_;
        std::string string_;
        struct {
          std::string table_;
          std::string column_;
        } field_;
      };

      type type_ = type::invalid;
  };

};

#endif /* end of include guard: BINDING_H_CAE0B18E */