QOF iteration (was QOF won't link)
Neil Williams
linux at codehelp.co.uk
Wed Jun 16 19:46:05 EDT 2004
On Wednesday 16 June 2004 9:09, Derek Atkins wrote:
> Neil Williams <linux at codehelp.co.uk> writes:
> > What do I need in a Makefile.am to deal with these error reports:
> >
> > /opt/neil/gnucash/src/import-export/gnc-book-merge/gnc_book_merge.c:114:
> > undefined reference to `qof_sql_query_run'
> > gnc_book_merge.o(.text+0x100): In function
> > `gnc_book_merge_do_some_queries':
> > /opt/neil/gnucash/src/import-export/gnc-book-merge/gnc_book_merge.c:134:
> > undefined reference to `qof_sql_query_new'
> > gnc_book_merge.o(.text+0x10e):/opt/neil/gnucash/src/import-export/gnc-boo
> >k-merge/gnc_book_merge.c:137: undefined reference to
> > `qof_sql_query_set_book'
> > gnc_book_merge.o(.text+0x130):/opt/neil/gnucash/src/import-export/gnc-boo
> >k-merge/gnc_book_merge.c:157: undefined reference to
> > `qof_sql_query_destroy'
> > collect2: ld returned 1 exit status
> > make: *** [gnc_book_merge] Error 1
> >
> > I can't find any suitable libraries in the CVS HEAD src/ tree.
> Nor do I get this error when I build CVS
> HEAD, so it's something you did yourself
I was following the QOF example and trying to use the qofsql.c code as I keep
getting segmentation faults if I use iterators and callback functions.
However, it's looking like that is the only way to get it to work. I find the
whole (QofCollection *coll, QofEntityForeachCB cb, gpointer ud) VERY
confusing.
Once I've got qof_collection_get_data(coll) how do I read data contained
within the object?
e.g. my current callback doesn't do any data query, it just prints a debug
line so that I know it is being executed and then obtains the data type
directly from QofCollection. (Not very useful, I know.)
void gnc_book_merge_foreach (QofCollection *coll, QofEntityForeachCB cb,
gpointer ud) {
printf("foreach running \n");
printf("Foreach Coll data type: %s\n",qof_collection_get_type(coll));
}
foreach running
Foreach Coll data type: gncInvoice
foreach running
Foreach Coll data type: gncInvoice
Whatever I do at that stage to be able to use a get_whatever() call for the
gncInvoice-type data results in a seg. fault, so I've obviously got it wrong.
(I'm calling the foreach using
qof_collection_foreach(coll, (QofEntityForeachCB)gnc_book_merge_foreach, ud);
from main())
This maybe isn't ideal (as I understand it) for my needs anyway, it appears to
rely too much on knowing the type of data in advance. If this is to be
generic, it needs to handle any registered type without major surgery.
When I use the alternative:
qof_object_foreach(GNC_ID_INVOICE, testbook, (QofEntityForeachCB)
gnc_book_merge_foreach, ud);
I get:
** CRITICAL **: Error: qof_object_foreach(): No object of type gncInvoice
and no debug "foreach running" lines.
> (or it's pulling in the wrong
> QOF headers and getting confused).
Not now. libqof is a distant memory.
> These symbols are declared in src/engine/qofsql.h but that file is not
> compiled in the gnucash build -- which leads me to believe you're
> having the version-skew problem that I alluded to.
Or that I'm using code that is in the doxygen files and in CVS but which isn't
actually usable within Gnucash? There's no target for qofsql.c and it depends
on libsql/sql_parser.h which I can only find in libqof-dev or possibly one of
the sqllite packages. (libsqlite0 - SQLite shared library
libsqlite0-dev - SQLite development files ) Have I blundered into the
replacement for the XML file format? Is it not being built because it would
add another dependency to the 1.9 build?
> Are you looking at QOF or Gnucash? This is not the right place to ask
> QOF questionbs.
Using QOF within Gnucash. I want to be able to scroll through the contents of
a GNCBook by using QOF to query all registered objects with full tracking of
exactly what type of data is being scrolled.
I'm sorry this is taking so long, you did say it wasn't easy but it is taking
more effort than I expected to get under the skin of QOF. You might be
relieved to hear that the doxygen formatting and the comparison and collision
code is not hitting the same problems, but then until I can throw some real
data at the code, I can't test it properly either!
:-(
--
Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/
http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20040617/d2ec389a/attachment.bin
More information about the gnucash-devel
mailing list