The Battle for Wesnoth  1.15.3+dev
bind.hpp
Go to the documentation of this file.
1 //
2 // M A R I A D B + +
3 //
4 // Copyright Sylvain Rochette Langlois 2013,
5 // The ViaDuck Project 2016 - 2018.
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 #ifndef _MARIADB_BIND_HPP_
11 #define _MARIADB_BIND_HPP_
12 
13 #include <mysql.h>
14 #include <mariadb++/types.hpp>
15 #include <mariadb++/data.hpp>
16 
17 namespace mariadb {
18 class statement;
19 class result_set;
20 class bind {
21  friend class statement;
22  friend class result_set;
23 
24  public:
25  /**
26  * Construct a parameter bind
27  */
28  explicit bind(MYSQL_BIND *mysql_bind);
29 
30  /**
31  * Construct a result bind for given field type
32  */
33  bind(MYSQL_BIND *mysql_bind, MYSQL_FIELD *mysql_field);
34 
35  /*
36  * Disallow copying and moving of a bind:
37  * As the bind can set its union as the bind "buffer", copying the bind would change the address of the union
38  */
39  bind(const bind &) = delete;
40  bind(bind &&) = delete;
41  bind &operator=(const bind &) = delete;
42  bind &operator=(bind &&) = delete;
43 
44  char* buffer() const;
45 
46  long unsigned int length() const;
47 
48  bool is_null() const;
49 
50  void set(enum_field_types type, const char* buffer = nullptr, unsigned long length = 0, bool us = false);
51 
52  private:
53  MYSQL_BIND* m_bind;
54  MYSQL_TIME m_time;
55 
56  my_bool m_is_null;
57  my_bool m_error;
58 
60 
61  union {
68  };
69 };
70 
71  using bind_ref = std::unique_ptr<bind>;
72 }
73 
74 #endif
signed int s32
Definition: types.hpp:25
char * buffer() const
Definition: bind.cpp:34
double f64
Definition: types.hpp:27
data_ref m_data
Definition: bind.hpp:59
my_bool m_is_null
Definition: bind.hpp:56
s64 m_signed64
Definition: bind.hpp:63
bind & operator=(const bind &)=delete
float f32
Definition: types.hpp:26
bool is_null() const
Definition: bind.cpp:42
bind(MYSQL_BIND *mysql_bind)
Construct a parameter bind.
Definition: bind.cpp:17
f64 m_double64
Definition: bind.hpp:65
MYSQL_TIME m_time
Definition: bind.hpp:54
f32 m_float32[2]
Definition: bind.hpp:66
std::unique_ptr< bind > bind_ref
Definition: bind.hpp:71
u64 m_unsigned64
Definition: bind.hpp:62
my_bool m_error
Definition: bind.hpp:57
std::shared_ptr< ::mariadb::data< char > > data_ref
Definition: data.hpp:170
unsigned char u8
Definition: types.hpp:20
Class representing a prepared statement with binding functionality.
Definition: statement.hpp:39
MYSQL_BIND * m_bind
Definition: bind.hpp:53
signed long long s64
Definition: types.hpp:35
u8 m_uchar8[4]
Definition: bind.hpp:67
long unsigned int length() const
Definition: bind.cpp:40
static void statement(LexState *ls)
Definition: lparser.cpp:1537
unsigned long long u64
Definition: types.hpp:34
Class used to store query and statement results.
Definition: result_set.hpp:69
s32 m_signed32[2]
Definition: bind.hpp:64