src/PreparedStatement.h
branchv_0
changeset 26 49919a60c747
parent 25 ec793cb3e686
child 27 9441a517fa1f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/PreparedStatement.h	Wed Dec 25 00:57:26 2019 +0100
@@ -0,0 +1,85 @@
+/**
+ * Relational pipes
+ * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <memory>
+#include <string>
+#include <sstream>
+#include <regex>
+#include <vector>
+#include <locale>
+#include <codecvt>
+#include <unistd.h>
+#include <cassert>
+#include <sys/stat.h>
+
+#include <sqlite3.h>
+
+#include <relpipe/reader/typedefs.h>
+#include <relpipe/reader/TypeId.h>
+#include <relpipe/reader/handlers/RelationalReaderValueHandler.h>
+#include <relpipe/reader/handlers/AttributeMetadata.h>
+
+#include <relpipe/writer/Factory.h>
+
+#include "Configuration.h"
+#include "SqlException.h"
+
+namespace relpipe {
+namespace tr {
+namespace sql {
+
+using namespace std;
+using namespace relpipe;
+using namespace relpipe::reader;
+using namespace relpipe::reader::handlers;
+
+class PreparedStatement {
+private:
+	sqlite3_stmt* stmt;
+
+public:
+
+	PreparedStatement(sqlite3_stmt* stmt);
+
+	virtual ~PreparedStatement();
+
+	void setBoolean(int parameterIndex, relpipe::reader::boolean_t value);
+
+	void setInteger(int parameterIndex, relpipe::reader::integer_t value);
+
+	void setString(int parameterIndex, std::string value);
+
+	void setNull(int parameterIndex);
+
+	bool next();
+
+	void reset();
+
+	int getColumnCount();
+
+	std::string getColumName(int columnIndex);
+
+	relpipe::writer::TypeId getColumType(int columnIndex, relpipe::writer::TypeId defaultType = relpipe::writer::TypeId::STRING);
+
+	std::string getString(int columnIndex);
+
+};
+
+}
+}
+}