Sorry, I forgot to say that this method is just defined as static: static int xCompare (void* v, int iLen1, const void* str1, int iLen2, const void* str2); In my opinion the important question is: does the return value have a specific meaning according with its numeric value or returning positive/negative/zero value it's enough?
Citando "Jay A. Kreibich" <j...@kreibi.ch>: > > On Thu, Nov 12, 2009 at 05:06:20PM +0100, galea...@korg.it scratched > on the wall: > >> int MyClass::xCompare (void* v, int iLen1, const void* str1, int >> iLen2, const void* str2) >> { > > >> and I registered it: >> sqlite3_create_collation(mpDB,"MYCOLLATE", SQLITE_UTF8, NULL, >> MyClass::xCompare); > > You can't do that. > > C++ puts a silent "this" pointer in as the first argument, so you > cannot use a non-static class method as a callback. > > You must create a static method, like this: > > static int MyClass:xCompareCallback( void *v, > int iLen1, const void *str1, int iLen2, const void* str2) > { > MyClass *ptr = v; > return v->xCompare(NULL, iLen1, str1, iLen2, str2); > } > > And register like this: > > sqlite3_create_collation(mpDB, "MYCOLLATE", SQLITE_UTF8, > PtrToClassInstance, MyClass::xCompareCallback); > > > The "PtrToClassInstance" must be a pointer to the class instance you > want called. If you're registering this inside your C++ class, you > can use "this". > > -j > > -- > Jay A. Kreibich < J A Y @ K R E I B I.C H > > > "Our opponent is an alien starship packed with atomic bombs. We have > a protractor." "I'll go home and see if I can scrounge up a ruler > and a piece of string." --from Anathem by Neal Stephenson > _______________________________________________ > 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