summaryrefslogtreecommitdiff
path: root/libodbcpp/odbc-command.h
blob: ff8b2fe367d22fe283d9599395225f23178d948d (plain)
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
#ifndef ODBC_COMMAND_H
#define ODBC_COMMAND_H

#include "odbc-param_fwd.h" // IWYU pragma: keep
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <command.h>
#include <glibmm/ustring.h>
#include <memory>
#include <sql.h>
#include <string>
#include <string_view>
#include <vector>

namespace boost::posix_time {
	class time_duration;
}

namespace ODBC {
	class Connection;
	using ParamPtr = std::unique_ptr<Param>;
	class Command : public virtual DB::Command {
		using Params = std::vector<ParamPtr>;

	public:
		Command(const Connection &, const std::string & sql);

		void bindParamI(unsigned int i, int val) override;
		void bindParamI(unsigned int i, long val) override;
		void bindParamI(unsigned int i, long long val) override;
		void bindParamI(unsigned int i, unsigned int val) override;
		void bindParamI(unsigned int i, unsigned long int val) override;
		void bindParamI(unsigned int i, unsigned long long int val) override;

		void bindParamB(unsigned int i, bool val) override;

		void bindParamF(unsigned int i, double val) override;
		void bindParamF(unsigned int i, float val) override;

		void bindParamS(unsigned int i, const Glib::ustring &) override;
		void bindParamS(unsigned int i, const std::string_view &) override;

		void bindParamT(unsigned int i, const boost::posix_time::time_duration &) override;
		void bindParamT(unsigned int i, const boost::posix_time::ptime &) override;

		void bindNull(unsigned int i) override;

	protected:
		friend class Param;
		friend class Column;
		SQLHSTMT hStmt;
		const Connection & connection;

	private:
		Params params;

		template<class ParamType> ParamType * makeParam(unsigned int idx);
	};

}

#endif