From 46bb010ca7c5eb04551c030105f9999ca80e472f Mon Sep 17 00:00:00 2001 From: tobigun Date: Sun, 8 Jun 2008 15:33:48 +0000 Subject: - set svn:eol-style to native - removed some svn:executable properties from non-executable files git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1144 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/lib/SQLite/example/TestSqlite.dpr | 30 +- Game/Code/lib/SQLite/example/TestSqlite.exe | Bin 504832 -> 0 bytes Game/Code/lib/SQLite/example/uTestSqlite.pas | 466 +++++++++++++-------------- Game/Code/lib/SQLite/readme.txt | 164 +++++----- 4 files changed, 330 insertions(+), 330 deletions(-) delete mode 100644 Game/Code/lib/SQLite/example/TestSqlite.exe (limited to 'Game/Code/lib/SQLite') diff --git a/Game/Code/lib/SQLite/example/TestSqlite.dpr b/Game/Code/lib/SQLite/example/TestSqlite.dpr index 82f2a468..596a3a04 100644 --- a/Game/Code/lib/SQLite/example/TestSqlite.dpr +++ b/Game/Code/lib/SQLite/example/TestSqlite.dpr @@ -1,15 +1,15 @@ -program TestSqlite; - -uses - Forms, - uTestSqlite in 'uTestSqlite.pas' {Form1}, - SQLiteTable3 in 'SQLiteTable3.pas', - SQLite3 in 'SQLite3.pas'; - -{$R *.res} - -begin - Application.Initialize; - Application.CreateForm(TForm1, Form1); - Application.Run; -end. +program TestSqlite; + +uses + Forms, + uTestSqlite in 'uTestSqlite.pas' {Form1}, + SQLiteTable3 in 'SQLiteTable3.pas', + SQLite3 in 'SQLite3.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. diff --git a/Game/Code/lib/SQLite/example/TestSqlite.exe b/Game/Code/lib/SQLite/example/TestSqlite.exe deleted file mode 100644 index 12f77a3d..00000000 Binary files a/Game/Code/lib/SQLite/example/TestSqlite.exe and /dev/null differ diff --git a/Game/Code/lib/SQLite/example/uTestSqlite.pas b/Game/Code/lib/SQLite/example/uTestSqlite.pas index 6691fece..484be71c 100644 --- a/Game/Code/lib/SQLite/example/uTestSqlite.pas +++ b/Game/Code/lib/SQLite/example/uTestSqlite.pas @@ -1,233 +1,233 @@ -unit uTestSqlite; - -interface - -uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls,SQLiteTable3, ExtCtrls, jpeg; - -type - TForm1 = class(TForm) - btnTest: TButton; - memNotes: TMemo; - Label1: TLabel; - Label2: TLabel; - ebName: TEdit; - Label3: TLabel; - ebNumber: TEdit; - Label4: TLabel; - ebID: TEdit; - Image1: TImage; - btnLoadImage: TButton; - btnDisplayImage: TButton; - procedure btnTestClick(Sender: TObject); - procedure btnLoadImageClick(Sender: TObject); - procedure btnDisplayImageClick(Sender: TObject); - private - { Private declarations } - public - { Public declarations } - end; - -var - Form1: TForm1; - -implementation - -{$R *.dfm} - -procedure TForm1.btnTestClick(Sender: TObject); -var -slDBpath: string; -sldb: TSQLiteDatabase; -sltb: TSQLIteTable; -sSQL: String; -Notes: String; - -begin - -slDBPath := ExtractFilepath(application.exename) -+ 'test.db'; - -sldb := TSQLiteDatabase.Create(slDBPath); -try - -if sldb.TableExists('testTable') then begin -sSQL := 'DROP TABLE testtable'; -sldb.execsql(sSQL); -end; - -sSQL := 'CREATE TABLE testtable ([ID] INTEGER PRIMARY KEY,[OtherID] INTEGER NULL,'; -sSQL := sSQL + '[Name] VARCHAR (255),[Number] FLOAT, [notes] BLOB, [picture] BLOB COLLATE NOCASE);'; - -sldb.execsql(sSQL); - -sldb.execsql('CREATE INDEX TestTableName ON [testtable]([Name]);'); - -//begin a transaction -sldb.BeginTransaction; - -sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Some Name",4,587.6594,"Here are some notes");'; -//do the insert -sldb.ExecSQL(sSQL); - -sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Another Name",12,4758.3265,"More notes");'; -//do the insert -sldb.ExecSQL(sSQL); - -//end the transaction -sldb.Commit; - -//query the data -sltb := slDb.GetTable('SELECT * FROM testtable'); -try - -if sltb.Count > 0 then -begin -//display first row - -ebName.Text := sltb.FieldAsString(sltb.FieldIndex['Name']); -ebID.Text := inttostr(sltb.FieldAsInteger(sltb.FieldIndex['ID'])); -ebNumber.Text := floattostr( sltb.FieldAsDouble(sltb.FieldIndex['Number'])); -Notes := sltb.FieldAsBlobText(sltb.FieldIndex['Notes']); -memNotes.Text := notes; - -end; - -finally -sltb.Free; -end; - -finally -sldb.Free; - -end; - -end; - -procedure TForm1.btnLoadImageClick(Sender: TObject); -var -slDBpath: string; -sldb: TSQLiteDatabase; -sltb: TSQLIteTable; -iID: integer; -fs: TFileStream; - -begin - -slDBPath := ExtractFilepath(application.exename) -+ 'test.db'; - -if not FileExists(slDBPath) then begin -MessageDLg('Test.db does not exist. Click Test Sqlite 3 to create it.',mtInformation,[mbOK],0); -exit; -end; - -sldb := TSQLiteDatabase.Create(slDBPath); -try - -//get an ID -//query the data -sltb := slDb.GetTable('SELECT ID FROM testtable'); -try - -if sltb.Count = 0 then begin -MessageDLg('There are no rows in the database. Click Test Sqlite 3 to insert a row.',mtInformation,[mbOK],0); -exit; -end; - -iID := sltb.FieldAsInteger(sltb.FieldIndex['ID']); - -finally -sltb.Free; -end; - -//load an image -fs := TFileStream.Create(ExtractFileDir(application.ExeName) + '\sunset.jpg',fmOpenRead); -try - -//insert the image into the db -sldb.UpdateBlob('UPDATE testtable set picture = ? WHERE ID = ' + inttostr(iID),fs); - -finally -fs.Free; -end; - -finally -sldb.Free; - -end; - -end; - -procedure TForm1.btnDisplayImageClick(Sender: TObject); -var -slDBpath: string; -sldb: TSQLiteDatabase; -sltb: TSQLIteTable; -iID: integer; -ms: TMemoryStream; -pic: TJPegImage; - -begin - -slDBPath := ExtractFilepath(application.exename) -+ 'test.db'; - -if not FileExists(slDBPath) then begin -MessageDLg('Test.db does not exist. Click Test Sqlite 3 to create it, then Load image to load an image.',mtInformation,[mbOK],0); -exit; -end; - -sldb := TSQLiteDatabase.Create(slDBPath); -try - -//get an ID -//query the data -sltb := slDb.GetTable('SELECT ID FROM testtable'); -try - -if not sltb.Count = 0 then begin -MessageDLg('No rows in the test database. Click Test Sqlite 3 to insert a row, then Load image to load an image.',mtInformation,[mbOK],0); -exit; -end; - -iID := sltb.FieldAsInteger(sltb.FieldIndex['ID']); - -finally -sltb.Free; -end; - -sltb := sldb.GetTable('SELECT picture FROM testtable where ID = ' + inttostr(iID)); -try - -ms := sltb.FieldAsBlob(sltb.FieldIndex['picture']); -//note that the memory stream is freed when the TSqliteTable is destroyed. - -if (ms = nil) then begin -MessageDLg('No image in the test database. Click Load image to load an image.',mtInformation,[mbOK],0); -exit; -end; - -ms.Position := 0; - -pic := TJPEGImage.Create; -pic.LoadFromStream(ms); - -self.Image1.Picture.Graphic := pic; - -pic.Free; - -finally -sltb.Free; -end; - -finally -sldb.Free; - -end; - - -end; - -end. +unit uTestSqlite; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls,SQLiteTable3, ExtCtrls, jpeg; + +type + TForm1 = class(TForm) + btnTest: TButton; + memNotes: TMemo; + Label1: TLabel; + Label2: TLabel; + ebName: TEdit; + Label3: TLabel; + ebNumber: TEdit; + Label4: TLabel; + ebID: TEdit; + Image1: TImage; + btnLoadImage: TButton; + btnDisplayImage: TButton; + procedure btnTestClick(Sender: TObject); + procedure btnLoadImageClick(Sender: TObject); + procedure btnDisplayImageClick(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + +var + Form1: TForm1; + +implementation + +{$R *.dfm} + +procedure TForm1.btnTestClick(Sender: TObject); +var +slDBpath: string; +sldb: TSQLiteDatabase; +sltb: TSQLIteTable; +sSQL: String; +Notes: String; + +begin + +slDBPath := ExtractFilepath(application.exename) ++ 'test.db'; + +sldb := TSQLiteDatabase.Create(slDBPath); +try + +if sldb.TableExists('testTable') then begin +sSQL := 'DROP TABLE testtable'; +sldb.execsql(sSQL); +end; + +sSQL := 'CREATE TABLE testtable ([ID] INTEGER PRIMARY KEY,[OtherID] INTEGER NULL,'; +sSQL := sSQL + '[Name] VARCHAR (255),[Number] FLOAT, [notes] BLOB, [picture] BLOB COLLATE NOCASE);'; + +sldb.execsql(sSQL); + +sldb.execsql('CREATE INDEX TestTableName ON [testtable]([Name]);'); + +//begin a transaction +sldb.BeginTransaction; + +sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Some Name",4,587.6594,"Here are some notes");'; +//do the insert +sldb.ExecSQL(sSQL); + +sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("Another Name",12,4758.3265,"More notes");'; +//do the insert +sldb.ExecSQL(sSQL); + +//end the transaction +sldb.Commit; + +//query the data +sltb := slDb.GetTable('SELECT * FROM testtable'); +try + +if sltb.Count > 0 then +begin +//display first row + +ebName.Text := sltb.FieldAsString(sltb.FieldIndex['Name']); +ebID.Text := inttostr(sltb.FieldAsInteger(sltb.FieldIndex['ID'])); +ebNumber.Text := floattostr( sltb.FieldAsDouble(sltb.FieldIndex['Number'])); +Notes := sltb.FieldAsBlobText(sltb.FieldIndex['Notes']); +memNotes.Text := notes; + +end; + +finally +sltb.Free; +end; + +finally +sldb.Free; + +end; + +end; + +procedure TForm1.btnLoadImageClick(Sender: TObject); +var +slDBpath: string; +sldb: TSQLiteDatabase; +sltb: TSQLIteTable; +iID: integer; +fs: TFileStream; + +begin + +slDBPath := ExtractFilepath(application.exename) ++ 'test.db'; + +if not FileExists(slDBPath) then begin +MessageDLg('Test.db does not exist. Click Test Sqlite 3 to create it.',mtInformation,[mbOK],0); +exit; +end; + +sldb := TSQLiteDatabase.Create(slDBPath); +try + +//get an ID +//query the data +sltb := slDb.GetTable('SELECT ID FROM testtable'); +try + +if sltb.Count = 0 then begin +MessageDLg('There are no rows in the database. Click Test Sqlite 3 to insert a row.',mtInformation,[mbOK],0); +exit; +end; + +iID := sltb.FieldAsInteger(sltb.FieldIndex['ID']); + +finally +sltb.Free; +end; + +//load an image +fs := TFileStream.Create(ExtractFileDir(application.ExeName) + '\sunset.jpg',fmOpenRead); +try + +//insert the image into the db +sldb.UpdateBlob('UPDATE testtable set picture = ? WHERE ID = ' + inttostr(iID),fs); + +finally +fs.Free; +end; + +finally +sldb.Free; + +end; + +end; + +procedure TForm1.btnDisplayImageClick(Sender: TObject); +var +slDBpath: string; +sldb: TSQLiteDatabase; +sltb: TSQLIteTable; +iID: integer; +ms: TMemoryStream; +pic: TJPegImage; + +begin + +slDBPath := ExtractFilepath(application.exename) ++ 'test.db'; + +if not FileExists(slDBPath) then begin +MessageDLg('Test.db does not exist. Click Test Sqlite 3 to create it, then Load image to load an image.',mtInformation,[mbOK],0); +exit; +end; + +sldb := TSQLiteDatabase.Create(slDBPath); +try + +//get an ID +//query the data +sltb := slDb.GetTable('SELECT ID FROM testtable'); +try + +if not sltb.Count = 0 then begin +MessageDLg('No rows in the test database. Click Test Sqlite 3 to insert a row, then Load image to load an image.',mtInformation,[mbOK],0); +exit; +end; + +iID := sltb.FieldAsInteger(sltb.FieldIndex['ID']); + +finally +sltb.Free; +end; + +sltb := sldb.GetTable('SELECT picture FROM testtable where ID = ' + inttostr(iID)); +try + +ms := sltb.FieldAsBlob(sltb.FieldIndex['picture']); +//note that the memory stream is freed when the TSqliteTable is destroyed. + +if (ms = nil) then begin +MessageDLg('No image in the test database. Click Load image to load an image.',mtInformation,[mbOK],0); +exit; +end; + +ms.Position := 0; + +pic := TJPEGImage.Create; +pic.LoadFromStream(ms); + +self.Image1.Picture.Graphic := pic; + +pic.Free; + +finally +sltb.Free; +end; + +finally +sldb.Free; + +end; + + +end; + +end. diff --git a/Game/Code/lib/SQLite/readme.txt b/Game/Code/lib/SQLite/readme.txt index 3b064e68..0bfdd93e 100644 --- a/Game/Code/lib/SQLite/readme.txt +++ b/Game/Code/lib/SQLite/readme.txt @@ -1,82 +1,82 @@ -14 Aug 2005 - -The following changes were made by Lukas Gebauer (geby@volny.cz). In addition, some changes from a previous D5-compatible version were merged, and the supplied sqlite3.dll is updated to version 3.2.2 - -Notes from Lukas: - -- added support for delphi 4+ - -- datatype constants matches SQlite datatypes contants. (otherwise in some situations you got bad column datatype!) - -- removed dependency on strutils - -- code is reformated to better look (official borland formationg -rules) - -- added some pragma's after database is open (temp is in memory) - -- TSQLiteDatabase.GetTableValue(const SQL: string): int64 for easy call of SQL commands what returning one number only. (like select -count(*)...) - -- TSQLiteDatabase.GetTableString(const SQL: string): String for easy call of SQL commands what returning one string only. (like PRAGMA -integrity_check) - -- TSQLiteDatabase.SetTimeout(Value: integer); you can set timeout for accessing to some table. Good for database sharing! - -- TSQLiteDatabase.version: string; returns SQLITE version string - -- removed bool fieldtype (it is not natural SQLite3 type) - -- fild type detection by Sqite3_columnType knows REAL too. - -- integer filedtype is based on Int64 - -- GetFields can get data from any supported fieldtype - -- changed some integers to cardinal for avoid signed and unsigned mismatch - -- TSqliteTable.FieldAsInteger(I: cardinal): int64; returns int64 - - -3 May 2005 Fixed bug where strupper called on column type before checking for nil - -2 May 2005 Add extra check for nil in TSqliteTable.Destroy, thanks to Tim Maddrell - -22 Apr 2005 Revise TSqliteTable.Destroy to fix memory leak with dtStr type (thanks to -Jose Brito) - -21 Apr 2005 Quick revision to fix case sensitivity in detecting column type, -and remove PRAGMA full_column_names = 1 which is deprecated. Warning: may break code. Fix your SQL code so that all column names in a result set are unique. - -21 Feb 2005 Sqlite DLL now 3.1.3 - -19 Feb 2005 Revised for Sqlite 3.1.2 - -21 Dec 2004 First public release - -The following notice appears in the Sqlite source code: - -* -** 2001 September 15 -** -** -** The author disclaims copyright to this source code. In place of - -** a legal notice, here is a blessing: - -** - May you do good and not evil. - -** May you find forgiveness for yourself and forgive others. - -** May you share freely, never taking more than you give. - - -For more information about SQLite, see http://www.sqlite.org - -For more information about this simple wrapper, see http://www.itwriting.com/sqlitesimple.php - - - - - +14 Aug 2005 + +The following changes were made by Lukas Gebauer (geby@volny.cz). In addition, some changes from a previous D5-compatible version were merged, and the supplied sqlite3.dll is updated to version 3.2.2 + +Notes from Lukas: + +- added support for delphi 4+ + +- datatype constants matches SQlite datatypes contants. (otherwise in some situations you got bad column datatype!) + +- removed dependency on strutils + +- code is reformated to better look (official borland formationg +rules) + +- added some pragma's after database is open (temp is in memory) + +- TSQLiteDatabase.GetTableValue(const SQL: string): int64 for easy call of SQL commands what returning one number only. (like select +count(*)...) + +- TSQLiteDatabase.GetTableString(const SQL: string): String for easy call of SQL commands what returning one string only. (like PRAGMA +integrity_check) + +- TSQLiteDatabase.SetTimeout(Value: integer); you can set timeout for accessing to some table. Good for database sharing! + +- TSQLiteDatabase.version: string; returns SQLITE version string + +- removed bool fieldtype (it is not natural SQLite3 type) + +- fild type detection by Sqite3_columnType knows REAL too. + +- integer filedtype is based on Int64 + +- GetFields can get data from any supported fieldtype + +- changed some integers to cardinal for avoid signed and unsigned mismatch + +- TSqliteTable.FieldAsInteger(I: cardinal): int64; returns int64 + + +3 May 2005 Fixed bug where strupper called on column type before checking for nil + +2 May 2005 Add extra check for nil in TSqliteTable.Destroy, thanks to Tim Maddrell + +22 Apr 2005 Revise TSqliteTable.Destroy to fix memory leak with dtStr type (thanks to +Jose Brito) + +21 Apr 2005 Quick revision to fix case sensitivity in detecting column type, +and remove PRAGMA full_column_names = 1 which is deprecated. Warning: may break code. Fix your SQL code so that all column names in a result set are unique. + +21 Feb 2005 Sqlite DLL now 3.1.3 + +19 Feb 2005 Revised for Sqlite 3.1.2 + +21 Dec 2004 First public release + +The following notice appears in the Sqlite source code: + +* +** 2001 September 15 +** +** +** The author disclaims copyright to this source code. In place of + +** a legal notice, here is a blessing: + +** + May you do good and not evil. + +** May you find forgiveness for yourself and forgive others. + +** May you share freely, never taking more than you give. + + +For more information about SQLite, see http://www.sqlite.org + +For more information about this simple wrapper, see http://www.itwriting.com/sqlitesimple.php + + + + + -- cgit v1.2.3