Re: [sqlite] How to create connection life-time object?
What I need is 'install and don't care' because I use many C++ classes as lifetime objects. I think that my solution does work now well, but if there would be a way to avoid use of SQL parser, it would be better. 2013/7/27 Max Vlasov> On Fri, Jul 26, 2013 at 9:56 PM, Dušan Paulovič > wrote: > > > Thanks for suggestion, but: > > 1.) one object is not linked to one connection > > > > If you have your own memory management, it's not a problem since the scheme > I described is basically just a storage of pointers. To free or not to free > (if the pointer points to a disposable entity) is your decision at your > chosen time. But if you want automatic reference counting (so when a > pointer not referenced anymore, it would be automatically deallocated), I > agree, the proposal is not good. Probably using your own global structure > not related to sqlite is less pain. > > > > 2.) object is not destroyed together with connection > > > > The same, you're free to use the table just as pointers storage > > Max > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to create connection life-time object?
On Fri, Jul 26, 2013 at 9:56 PM, Dušan Paulovičwrote: > Thanks for suggestion, but: > 1.) one object is not linked to one connection > If you have your own memory management, it's not a problem since the scheme I described is basically just a storage of pointers. To free or not to free (if the pointer points to a disposable entity) is your decision at your chosen time. But if you want automatic reference counting (so when a pointer not referenced anymore, it would be automatically deallocated), I agree, the proposal is not good. Probably using your own global structure not related to sqlite is less pain. > 2.) object is not destroyed together with connection > The same, you're free to use the table just as pointers storage Max ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to create connection life-time object?
Thanks for suggestion, but: 1.) one object is not linked to one connection 2.) object is not destroyed together with connection Dusan 2013/7/26 Max Vlasov> Hi, Dušan > > > On Thu, Jul 25, 2013 at 2:39 PM, Dušan Paulovič > wrote: > > > Hello, is there a way to somehow set a connection life-time object? > > ... > > > > > > It would be fine to have something like: > > int sqlite3_set_lifetime_object( > > sqlite3 *db, /*db connection*/ > > const char *zObjectName, /*utf8 name of object*/ > > void *pObject,/*if NULL, object is removed*/ > > void(*xDestroy)(void*)/*destructor*/ > > ); > > > > void * sqlite3_get_lifetime_object( > > sqlite3 *db, /*db connection*/ > > const char *zObjectName /*utf8 name of object*/ > > ); > > > > > > How about temporary memory table just for the task of storing your objects. > > You initialization code for particular connection > Attach ':memory:' as MyObjectStorage > Create table MyObjectStorage.[objects] (Name Text, Ptr Text) > > Your code for inserting an object > Insert into MyObjectStorage.[objects] (Name, Ptr) VALUES ('obj1', > '0x12345678') > > This code will query the pointer > select Ptr from MyObjectStorage.[objects] where Name='obj1' > > The only convention rule here will be the name of the attached db so no > other databases (or instances of the same storage) should use this name. > > Max > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] How to create connection life-time object?
Hi, Dušan On Thu, Jul 25, 2013 at 2:39 PM, Dušan Paulovičwrote: > Hello, is there a way to somehow set a connection life-time object? > ... > > > It would be fine to have something like: > int sqlite3_set_lifetime_object( > sqlite3 *db, /*db connection*/ > const char *zObjectName, /*utf8 name of object*/ > void *pObject,/*if NULL, object is removed*/ > void(*xDestroy)(void*)/*destructor*/ > ); > > void * sqlite3_get_lifetime_object( > sqlite3 *db, /*db connection*/ > const char *zObjectName /*utf8 name of object*/ > ); > How about temporary memory table just for the task of storing your objects. You initialization code for particular connection Attach ':memory:' as MyObjectStorage Create table MyObjectStorage.[objects] (Name Text, Ptr Text) Your code for inserting an object Insert into MyObjectStorage.[objects] (Name, Ptr) VALUES ('obj1', '0x12345678') This code will query the pointer select Ptr from MyObjectStorage.[objects] where Name='obj1' The only convention rule here will be the name of the attached db so no other databases (or instances of the same storage) should use this name. Max ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users