#ifndef _DbSqlite_H_
#define _DbSqlite_H_

#include "sqlite3.h"
#include <string>
#include <functional>

using CallbackSqliteRowData = std::function<void(sqlite3_stmt*)>;

class DbSqlite
{
public:
	DbSqlite(const char* dbname);
	~DbSqlite();

	void open(const char* dbname);

	bool exec(const char* sql);

	bool prepare_step(const char* sql, CallbackSqliteRowData& cb);

	void close();

	int get_int(sqlite3_stmt* stmt, int index);
	double get_double(sqlite3_stmt* stmt, int index);
	std::string get_text(sqlite3_stmt* stmt, int index);

private:
	sqlite3* sqlite_ = nullptr;
};

#endif // !!! _DbSqlite_H_