src/PreparedStatement.h
author František Kučera <franta-hg@frantovo.cz>
Fri, 31 Jan 2020 23:22:56 +0100
branchv_0
changeset 30 629565ff82d3
parent 29 b0ef1e1dc9c8
child 33 86ceb97db7de
permissions -rw-r--r--
keep sqlite3.h dependency in Connection.cpp and PreparedStatement.cpp only II

/**
 * 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 <relpipe/reader/typedefs.h>
#include <relpipe/reader/TypeId.h>
#include <relpipe/writer/TypeId.h>
#include "SqlException.h"

namespace relpipe {
namespace tr {
namespace sql {

class PreparedStatement {
private:
	void* stmt;
public:
	PreparedStatement(void* 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);
	static bool isComplete(const char *sql); // TODO: use own implementation + move to a separate class
};

}
}
}