Re: [fpc-pascal] TDatabase, PostgreSQL and Mac OS X?
I don't know too much about OS X, but can't you simply rename libpq.dylib to libpq.so? --- Jeremy Cowgar <[EMAIL PROTECTED]> wrote: > I have the following simple program that does not seem to be working. > Connectivity using postgres unit works fine. Here's the error and > then the program will follow. Thank you! Oh, a note. I do not have > libpq.so. I do have libpq.dylib. Also, my postgresql is installed in > a non-standard place, /usr/local/pgsql however other programs have > not had a problem with that thus far. I created symlinks to /usr/ > local/pgsql/libpq* into /usr/lib but that did not solve the problem. > > Jeremy > > > $ ./dbtest Connecting to database... > An unhandled exception occurred at $0007864C : > EInOutError : Can not load PosgreSQL client. Is it installed? (libpq.so) >$0007864C >$00054F87 > > > > program dbtest; > > uses sqldb, pqconnection; > > var > Fconnection : tSQLConnection; > > begin > writeln('Connecting to database...'); > > Fconnection := tpqConnection.Create(nil); > with Fconnection do > begin > DatabaseName := 'test'; > open; > end; > > writeln('Connected...'); > > Fconnection.Free; > end. > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > Leonardo M. Ramé http://leonardorame.blogspot.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TDatabase, PostgreSQL and Mac OS X?
Jeremy Cowgar schreef: Leonardo, Wow. That worked. I did a symlink from libpq.dylib to libpq.so and it works now. Is there a proper way to do this on mac os x anyone? Thanks Lenardo! Maybe apply this patch and recompile: Index: base/postgres/dllistdyn.pp === --- base/postgres/dllistdyn.pp (revision 4739) +++ base/postgres/dllistdyn.pp (working copy) @@ -15,9 +15,14 @@ {$PACKRECORDS C} {$IFDEF Unix} +{$IFDEF Darwin} const +pqlib = 'libpq.dylib'; +{$ELSE} + const pqlib = 'libpq.so'; {$ENDIF} +{$ENDIF} {$IFDEF Windows} const pqlib = 'libpq.dll'; Index: base/postgres/postgres3dyn.pp === --- base/postgres/postgres3dyn.pp (revision 4739) +++ base/postgres/postgres3dyn.pp (working copy) @@ -15,9 +15,14 @@ dynlibs, SysUtils, dllistdyn; {$IFDEF Unix} +{$IFDEF Darwin} const +pqlib = 'libpq.dylib'; +{$ELSE} + const pqlib = 'libpq.so'; {$ENDIF} +{$ENDIF} {$IFDEF Win32} const pqlib = 'libpq.dll'; Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TDatabase, PostgreSQL and Mac OS X?
Leonardo, Wow. That worked. I did a symlink from libpq.dylib to libpq.so and it works now. Is there a proper way to do this on mac os x anyone? Thanks Lenardo! Jeremy On Sep 27, 2006, at 7:55 AM, Leonardo M. Ramé wrote: I don't know too much about OS X, but can't you simply rename libpq.dylib to libpq.so? --- Jeremy Cowgar <[EMAIL PROTECTED]> wrote: I have the following simple program that does not seem to be working. Connectivity using postgres unit works fine. Here's the error and then the program will follow. Thank you! Oh, a note. I do not have libpq.so. I do have libpq.dylib. Also, my postgresql is installed in a non-standard place, /usr/local/pgsql however other programs have not had a problem with that thus far. I created symlinks to /usr/ local/pgsql/libpq* into /usr/lib but that did not solve the problem. Jeremy $ ./dbtest Connecting to database... An unhandled exception occurred at $0007864C : EInOutError : Can not load PosgreSQL client. Is it installed? (libpq.so) $0007864C $00054F87 program dbtest; uses sqldb, pqconnection; var Fconnection : tSQLConnection; begin writeln('Connecting to database...'); Fconnection := tpqConnection.Create(nil); with Fconnection do begin DatabaseName := 'test'; open; end; writeln('Connected...'); Fconnection.Free; end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal Leonardo M. Ramé http://leonardorame.blogspot.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] THashedStringList vs TFPHashTable
Hi, Is TFPHashTable the same as Delphi's THashedStringList? I am looking for a List class that can hold large amounts of objects with a ID string associated for quick lookups. Regards, - Graeme - ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] THashedStringList vs TFPHashTable
Graeme, I dont know if is the same, but I know that the operations in THashedStringList is sloow, too much unecessary operations, I use TStringHash class for that. for interfaces: Look the unit JazzClass.pas in http://jazz.liws.com.br/download/jazz_a7.zip for objects: http://blogs.liws.com.br/cesar/download/ObjectRegister.html I wrote a article in my blog fast add and search objects http://blogs.liws.com.br/cesar/?p=23, sorry still portuguese, but you can look at source code: []s Cesar Romero Graeme Geldenhuys escreveu: Hi, Is TFPHashTable the same as Delphi's THashedStringList? I am looking for a List class that can hold large amounts of objects with a ID string associated for quick lookups. Regards, - Graeme - ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TDatabase, PostgreSQL and Mac OS X?
Well, congratulations. I've experienced that same problem trying to use the ZeosLib PostGresql protocol on Linux. It try to use libpq.so and i had libpq-x.x.so, so i created a smart link to it. --- Jeremy Cowgar <[EMAIL PROTECTED]> wrote: > Leonardo, Wow. That worked. I did a symlink from libpq.dylib to > libpq.so and it works now. > > Is there a proper way to do this on mac os x anyone? > > Thanks Lenardo! > > Jeremy > > On Sep 27, 2006, at 7:55 AM, Leonardo M. Ramé wrote: > > > I don't know too much about OS X, but can't you simply rename > > libpq.dylib to libpq.so? > > > > --- Jeremy Cowgar <[EMAIL PROTECTED]> wrote: > > > >> I have the following simple program that does not seem to be working. > >> Connectivity using postgres unit works fine. Here's the error and > >> then the program will follow. Thank you! Oh, a note. I do not have > >> libpq.so. I do have libpq.dylib. Also, my postgresql is installed in > >> a non-standard place, /usr/local/pgsql however other programs have > >> not had a problem with that thus far. I created symlinks to /usr/ > >> local/pgsql/libpq* into /usr/lib but that did not solve the problem. > >> > >> Jeremy > >> > >> > >> $ ./dbtest Connecting to database... > >> An unhandled exception occurred at $0007864C : > >> EInOutError : Can not load PosgreSQL client. Is it installed? > >> (libpq.so) > >>$0007864C > >>$00054F87 > >> > >> > >> > >> program dbtest; > >> > >> uses sqldb, pqconnection; > >> > >> var > >>Fconnection : tSQLConnection; > >> > >> begin > >>writeln('Connecting to database...'); > >> > >>Fconnection := tpqConnection.Create(nil); > >>with Fconnection do > >>begin > >>DatabaseName := 'test'; > >>open; > >>end; > >> > >>writeln('Connected...'); > >> > >>Fconnection.Free; > >> end. > >> > >> ___ > >> fpc-pascal maillist - fpc-pascal@lists.freepascal.org > >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal > >> > > > > > > Leonardo M. Ramé > > http://leonardorame.blogspot.com > > > > __ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam protection around > > http://mail.yahoo.com > > ___ > > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > Leonardo M. Ramé http://leonardorame.blogspot.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] TDatabase Docs?
Does anyone know where I can read about the TDatabase classes? I know I can look in the source, but I was hoping for an API ref or something. Thanks, Jeremy ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] THashedStringList vs TFPHashTable
At 16:00 27-9-2006, you wrote: Hi, Is TFPHashTable the same as Delphi's THashedStringList? I am looking for a List class that can hold large amounts of objects with a ID string associated for quick lookups. For the compiler i created a TFPHashList and TFPHashObjectList as similair to TFPList and TFPObjectList. The code is available in compiler/cutils.pas Peter ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE: [fpc-pascal] THashedStringList vs TFPHashTable
Not in cutils.pas - found them in compiler/cclasses.pas. J > > > At 16:00 27-9-2006, you wrote: > >Hi, > > > >Is TFPHashTable the same as Delphi's THashedStringList? > > > >I am looking for a List class that can hold large amounts of objects > >with a ID string associated for quick lookups. > > For the compiler i created a TFPHashList and TFPHashObjectList as > similair to TFPList and TFPObjectList. The code is available in > compiler/cutils.pas > > > Peter > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] THashedStringList vs TFPHashTable
Graeme Geldenhuys ha scritto: > Hi, > > Is TFPHashTable the same as Delphi's THashedStringList? > > I am looking for a List class that can hold large amounts of objects > with a ID string associated for quick lookups. > > Regards, > - Graeme - Yes, similar to a THashedStringList, but with a special implementation The TFPHashTable was highly optimized with a lot of profiling, while trying to achieve the ease of use through object orientation and ease of maintainance. It's a hash table with a customizable hash function (to achieve constant performance in searches), chaining is used as a collision resolution scheme. Some statistics are also provided to be able to choose the appropriate hash function and the appropriate hash table size. The difference in performance with respect to a simple ordered TStringList is evident when more then 100.000 elements are added to the container, the number of elements the container can hold is huge (longword, and obviously ram size, is the limit :). I have another idea to further improve the performance of searches and I'm planning to further profile it in the next weeks to see if there are other speed gains. Be aware that the version in 2.0.4 and before contains a bug that was solved by Marco in 2.1.1. and merged in 2.0.5 (an AV if the insertion is made after a clear) due to the use of longwords in the for cycles. I'm attaching the fpcunit tests for you to see how to use it, and I'll give you all the assistance that you need. I'll be glad to receive some feedback as usual. Regards, Dean unit testfphashtable; {$mode objfpc}{$H+} interface uses Classes, SysUtils, fpcunit, testutils, testregistry, contnrs; type { TTestHtNode } TTestHtNode = class(TTestCase) published procedure TestNodeCreation; procedure TestKeyComparison; end; //inherited to be able to get access to protected methods TMyHashTable = class(TFPHashTable) end; { TTestFPHashTable } TTestFPHashTable= class(TTestCase) private ht: TMyHashTable; FSum: integer; protected procedure SetUp; override; procedure TearDown; override; procedure SumTest(Item: Pointer; const Key: string; var Continue: Boolean); procedure SumTestUntilFound100(Item: Pointer; const Key: string; var Continue: Boolean); published procedure TestCreate; procedure TestCreateWith; procedure TestIsEmpty; procedure TestAdd; procedure TestAddSimpleSyntax; procedure TestGetData; procedure TestChainLength; procedure TestDelete; procedure TestClear; procedure TestForEachCall; procedure TestForEachCallBreak; procedure TestHashTableGrow; procedure TestVoidSlots; //test for bug 0007292 fixed by marco guard all for loops with unsigned //loopcounter against overflow (rev.4507) procedure TestAddAfterClear; end; implementation procedure TTestFPHashTable.SetUp; begin ht := TMyHashTable.CreateWith(9973, @RSHash); AssertEquals(12289, ht.HashTableSize); end; procedure TTestFPHashTable.TearDown; begin ht.Free; end; procedure TTestFPHashTable.TestAdd; begin ht.Add('1', pointer(1)); ht.Add('2', pointer(2)); ht.Add('nil', nil); AssertEquals('wrong number of items', 3, ht.Count); end; procedure TTestFPHashTable.TestAddSimpleSyntax; begin ht['1'] := pointer(1); ht['2'] := pointer(2); ht['nil'] := nil; AssertEquals('wrong number of items', 3, ht.Count); end; procedure TTestFPHashTable.TestGetData; var i: integer; begin for i := 0 to do ht.Add(intToStr(i), pointer(i)); AssertEquals(1, ht.Count); for i := 0 to do AssertEquals(i, integer(ht[PChar(IntToStr(i))])); for i := downto 0 do AssertEquals(i, integer(ht[PChar(IntToStr(i))])); end; procedure TTestFPHashTable.TestChainLength; var i: integer; sum: int64; begin sum := 0; for i := 0 to do ht.Add(intToStr(i), pointer(i)); AssertEquals(1, ht.Count); for i := 0 to ht.HashTableSize-1 do if Assigned(ht.HashTable[i]) then Sum := Sum + ht.ChainLength(i); AssertEquals(1, sum); end; procedure TTestFPHashTable.TestDelete; var i: DWord; begin for i := 0 to do ht.Add(intToStr(i), pointer(i)); ht.Delete('994'); AssertEquals('Wrong number of items after delete', , ht.Count); AssertNull('Item not deleted', ht.Find('994')); end; procedure TTestFPHashTable.TestClear; var i: integer; begin for i := 0 to do ht.Add(intToStr(i), pointer(i)); ht.Clear; AssertTrue('container not empty', ht.IsEmpty); end; procedure TTestFPHashTable.TestHashTableGrow; var i: integer; begin for i := 0 to do ht.Add(intToStr(i), pointer(i)); ht.HashTableSize := ht.HashTableSize + 1; AssertEquals(24593, ht.HashTableSize); AssertEquals(1, ht.Count); for i := 0 to do AssertEquals(i, integer(ht[PChar(IntToStr(i))])); end; procedure TTestFPHashTable.TestVoidSlots; begin AssertEquals(12289, ht.VoidSlots); ht.Add('a', nil); AssertE
Re: [fpc-pascal] THashedStringList vs TFPHashTable
Thanks to all that replied. The string that is going to be stored in the List (with associated object) is a GUID string, so is very random by nature. Would this have any negative affects in the hash table? I will try it out anyway, I can always swap the internal list out if needed. What I am creating is a Flyweight (design pattern) to store all common objecs I use. I will be fetching the objects based on the OID (GUID) string. Regards, - Graeme - On 27/09/06, Dean Zobec <[EMAIL PROTECTED]> wrote: Graeme Geldenhuys ha scritto: > Hi, > > Is TFPHashTable the same as Delphi's THashedStringList? > > I am looking for a List class that can hold large amounts of objects > with a ID string associated for quick lookups. > > Regards, > - Graeme - Yes, similar to a THashedStringList, but with a special implementation The TFPHashTable was highly optimized with a lot of profiling, while trying to achieve the ease of use through object orientation and ease of maintainance. It's a hash table with a customizable hash function (to achieve constant performance in searches), chaining is used as a collision resolution scheme. Some statistics are also provided to be able to choose the appropriate hash function and the appropriate hash table size. The difference in performance with respect to a simple ordered TStringList is evident when more then 100.000 elements are added to the container, the number of elements the container can hold is huge (longword, and obviously ram size, is the limit :). I have another idea to further improve the performance of searches and I'm planning to further profile it in the next weeks to see if there are other speed gains. Be aware that the version in 2.0.4 and before contains a bug that was solved by Marco in 2.1.1. and merged in 2.0.5 (an AV if the insertion is made after a clear) due to the use of longwords in the for cycles. I'm attaching the fpcunit tests for you to see how to use it, and I'll give you all the assistance that you need. I'll be glad to receive some feedback as usual. Regards, Dean unit testfphashtable; {$mode objfpc}{$H+} interface uses Classes, SysUtils, fpcunit, testutils, testregistry, contnrs; type { TTestHtNode } TTestHtNode = class(TTestCase) published procedure TestNodeCreation; procedure TestKeyComparison; end; //inherited to be able to get access to protected methods TMyHashTable = class(TFPHashTable) end; { TTestFPHashTable } TTestFPHashTable= class(TTestCase) private ht: TMyHashTable; FSum: integer; protected procedure SetUp; override; procedure TearDown; override; procedure SumTest(Item: Pointer; const Key: string; var Continue: Boolean); procedure SumTestUntilFound100(Item: Pointer; const Key: string; var Continue: Boolean); published procedure TestCreate; procedure TestCreateWith; procedure TestIsEmpty; procedure TestAdd; procedure TestAddSimpleSyntax; procedure TestGetData; procedure TestChainLength; procedure TestDelete; procedure TestClear; procedure TestForEachCall; procedure TestForEachCallBreak; procedure TestHashTableGrow; procedure TestVoidSlots; //test for bug 0007292 fixed by marco guard all for loops with unsigned //loopcounter against overflow (rev.4507) procedure TestAddAfterClear; end; implementation procedure TTestFPHashTable.SetUp; begin ht := TMyHashTable.CreateWith(9973, @RSHash); AssertEquals(12289, ht.HashTableSize); end; procedure TTestFPHashTable.TearDown; begin ht.Free; end; procedure TTestFPHashTable.TestAdd; begin ht.Add('1', pointer(1)); ht.Add('2', pointer(2)); ht.Add('nil', nil); AssertEquals('wrong number of items', 3, ht.Count); end; procedure TTestFPHashTable.TestAddSimpleSyntax; begin ht['1'] := pointer(1); ht['2'] := pointer(2); ht['nil'] := nil; AssertEquals('wrong number of items', 3, ht.Count); end; procedure TTestFPHashTable.TestGetData; var i: integer; begin for i := 0 to do ht.Add(intToStr(i), pointer(i)); AssertEquals(1, ht.Count); for i := 0 to do AssertEquals(i, integer(ht[PChar(IntToStr(i))])); for i := downto 0 do AssertEquals(i, integer(ht[PChar(IntToStr(i))])); end; procedure TTestFPHashTable.TestChainLength; var i: integer; sum: int64; begin sum := 0; for i := 0 to do ht.Add(intToStr(i), pointer(i)); AssertEquals(1, ht.Count); for i := 0 to ht.HashTableSize-1 do if Assigned(ht.HashTable[i]) then Sum := Sum + ht.ChainLength(i); AssertEquals(1, sum); end; procedure TTestFPHashTable.TestDelete; var i: DWord; begin for i := 0 to do ht.Add(intToStr(i), pointer(i)); ht.Delete('994'); AssertEquals('Wrong number of items after delete', , ht.Count); AssertNull('Item not deleted', ht.Find('994')); end; procedure TTestFPHashTable.TestClear; var i: integer; begin for i := 0 to do ht.Add(intToStr(i), pointer(i)); ht.Cle
[fpc-pascal] fpdoc xml files with special characters
Hi, How is fpdoc's xml files supposed to handle special characters? For example, I tried to type the '&' character, and fpdoc complained. I then escaped the ampersand with & which was fine. This is all great for HTML output, but what will happen with LaTeX output. Will it display the ampersand, or the escaped ampersand (&)? I guess this all depends on the XMLReader unit and if it reverts the & back to the & sign correct? Regards, - Graeme - -- There's no place like 127.0.0.1 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpdoc xml files with special characters
On Wed, 27 Sep 2006, Graeme Geldenhuys wrote: > Hi, > > How is fpdoc's xml files supposed to handle special characters? For > example, I tried to type the '&' character, and fpdoc complained. I > then escaped the ampersand with & which was fine. > > This is all great for HTML output, but what will happen with LaTeX > output. Will it display the ampersand, or the escaped ampersand > (&)? I guess this all depends on the XMLReader unit and if it > reverts the & back to the & sign correct? It will deal this correctly. The backends will escape the characters again if needed. Different backends must escape in different ways... Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpdoc xml files with special characters
On 27/09/06, Michael Van Canneyt <[EMAIL PROTECTED]> wrote: > This is all great for HTML output, but what will happen with LaTeX > output. Will it display the ampersand, or the escaped ampersand > (&)? I guess this all depends on the XMLReader unit and if it > reverts the & back to the & sign correct? It will deal this correctly. The backends will escape the characters again if needed. Different backends must escape in different ways... Michael. Thanks for confirming that Michael! You guys thought of everything. :-) G. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] THashedStringList vs TFPHashTable
Graeme Geldenhuys ha scritto: > Thanks to all that replied. The string that is going to be stored in > the List (with associated object) is a GUID string, so is very random > by nature. Would this have any negative affects in the hash table? > > I will try it out anyway, I can always swap the internal list out if > needed. What I am creating is a Flyweight (design pattern) to store > all common objecs I use. I will be fetching the objects based on the > OID (GUID) string. It's a typical use. Choose an appropriate HashTableSize when creating the container (approx.the number of the elements you are going to store or more), you can test it with different hash functions and see through the statistics which one is better (the longer the chains i.e. more void slots, the longer the fetch times). Dean ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal