r15105 - gnucash/branches/gda-dev - 1) Use getter/setter functions to transfer from objects <-> db
Phil Longstaff
plongstaff at rogers.com
Fri Nov 24 19:38:37 EST 2006
On Fri, 2006-24-11 at 15:53 -0500, Derek Atkins wrote:
> Phil,
>
> Phil Longstaff <plongstaff at cvs.gnucash.org> writes:
>
> > +static col_cvt_t col_table[] =
> > +{
> > + { "guid", CT_GUID, 0, COL_NNUL|COL_PKEY,
> > + (GNC_GDA_FN_GETTER)qof_entity_get_guid,
> > + (GNC_GDA_FN_SETTER)xaccAccountSetGUID },
> > + { "name", CT_STRING, 50, COL_NNUL,
> > + NULL, NULL, ACCOUNT_NAME_ },
> > + { "account_type", CT_INT, 0, COL_NNUL,
> > + (GNC_GDA_FN_GETTER)xaccAccountGetType,
> > + (GNC_GDA_FN_SETTER)xaccAccountSetType },
> > + { "commodity_guid", CT_GUID, 0, COL_NNUL,
> > + get_commodity, set_commodity },
> > + { "parent_guid", CT_GUID, 0, 0, get_parent, set_parent },
> > + { "code", CT_STRING, 100, 0,
> > + NULL, NULL, ACCOUNT_CODE_ },
> > + { "description", CT_STRING, 500, 0,
> > + NULL, NULL, ACCOUNT_DESCRIPTION_ },
> > + { NULL }
> > +};
>
> This looks like a close duplication to the table in src/engine/Account.c.
> How hard would it be to just use that instead of rebuilding it here?
> I'll note that if we need to make small QOF changes so we don't need
> to duplicate the Parameter Tables then that would be a GOOD THING. :)
I do try to use the parameter table getters and setters where possible.
For example, "code" will use the ACCOUNT_CODE_ getter and setter.
Hoever, there are a number of problems in the way of directly using the
parameter tables.
1) I need information which isn't available currently in the parameter
tables (e.g. can column be null, is column the primary key), max size
for strings.
2) Some parameters have only a getter and not a setter.
3) Some parameter tables (e.g. commodity) don't exist.
4) Some parameter setters are inappropriate. For example, there is a
qofTransSetNum() to set the number for a transaction, but it can't be
used if the transaction is already being edited (and I have a
xaccTransBeginEdit() before loading the transaction fields).
5) There are some parameters which don't have entries in the parameter
tables, and some entries in the parameter tables which don't get
saved/restored.
6) Some entries in the parameter table don't use the right type. For
example, an account's commodity is stored as a guid, but the getter and
setter use a gnc_commodity*. This could be handled by adding a
COMMODITY_GUID type (and ACCOUNT_GUID and ...) to the backend.
Obviously, (1) could be solved by extending the information in the
parameter tables.
Phil
More information about the gnucash-devel
mailing list