src/PreparedStatement.h
author František Kučera <franta-hg@frantovo.cz>
Wed, 25 Dec 2019 01:07:41 +0100
branchv_0
changeset 27 9441a517fa1f
parent 26 49919a60c747
child 28 498d5d3406c3
permissions -rw-r--r--
move Connection class to separate .h and .cpp files

/**
 * 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);
};

}
}
}