Додаток Г.2 Лістинг бібліотеки потоку зчитування даних реєстру

//---------------------------------------------------------------------------

#ifndef dbthreadH

#define dbthreadH

//---------------------------------------------------------------------------

#include <System.Classes.hpp>

//---------------------------------------------------------------------------

class dbCreate: public TThread

{

private:

protected:

void __fastcall Execute();

public:

__fastcall dbCreate(bool CreateSuspended);

};

//---------------------------------------------------------------------------

#endif


Додаток Ґ Лістинг бібліотеки класу бази даних

/* клас бази даних */

#include "sqlite3.h"

#include <iostream.h>

#include <fstream.h>

#include <vcl.h>

class DB {

private:

sqlite3 *database;

//функція Call-back для обробки команди SELECT

static int callback(void *notused, int coln, char **rows, char **colnm)

{

return 0;

}

public:

// класс помилок

class Err {

public:

char *errstr;

Err(const char * str) {strcpy(errstr, str);}

};

// конструктор відкриває базу даних

DB(char *db_name)

{

int rc;

char *errmsg;

rc = sqlite3_open(db_name, &database);

// у разі помилки

if (rc) {

errmsg = (char*) sqlite3_errmsg(database);

sqlite3_close(database);

throw Err(errmsg);

}

}

//деструктор закриває БД

~DB() {sqlite3_close(database);}

// виконання SQL-запиту

void SQLRun(const char *sql)

{

sqlite3_stmt *stmt;

char *errmsg;

sqlite3_exec(database, sql, callback, NULL, &errmsg);

if (sql[0] == 'S')

{

int row = 0;

sqlite3_prepare_v2 (database, sql, strlen (sql) + 1, & stmt, NULL);

ofstream out("out");

while (true)

{

int s = sqlite3_step (stmt);

if (s == SQLITE_ROW)

{

int bytes;

char * text;

bytes = sqlite3_column_bytes(stmt, 0);

for (int n=0; n<sqlite3_column_count(stmt); n++)

{

text = sqlite3_column_text (stmt, n);

UnicodeString lol = (UnicodeString)text;

out << text << endl;

}

row++;

}

else if (s == SQLITE_DONE) break;

}

out.close();

}

}

};


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: