X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=doc%2Fgom.html;h=857e7452eaa63b7b539fffdebdc94ef05e9f33ab;hb=60282b9f2f1326231ea5019e239d00bdccd6608b;hp=7358ad11273e62e05b16239046888715e8172035;hpb=c80fb171c952d002191509a343bb4c3747dffc35;p=gedcom-parse.git diff --git a/doc/gom.html b/doc/gom.html index 7358ad1..857e745 100644 --- a/doc/gom.html +++ b/doc/gom.html @@ -24,7 +24,12 @@
  • Modifying the object model
  • Writing the object model to file

  • @@ -73,7 +78,7 @@ struct submission*  gom_get_submission();
    to get the first of such records, and one to get a record via its cross-reference tag in the GEDCOM file:
    struct XXX*   gom_get_first_XXX();
    -struct XXX*   gom_get_XXX_by_xref(char* xref);

    +struct XXX*   gom_get_XXX_by_xref(const char* xref);
    @@ -126,7 +131,8 @@ tags is.  Each element of the linked list has:
    This way, none of the information in the GEDCOM file is lost, even the non-standard information.


    -

    Modifying the object model

    +

    Modifying the object model

    Note that the date manipulations are described here.
    +

    Manipulating strings

    There are some functions available to retrieve and change strings in the @@ -170,14 +176,81 @@ failures for the result string.  Pass a pointer to an integer if you want to know this.  You can pass NULL if you're not interested.  The function returns NULL if an error occurred (e.g. if the given string is not a valid string for the current locale); in that case the target data variable is not modified.
    +
    +

    Adding and removing records

    +For each of the record types, there are two functions to add and remove records: +
    struct XXX*   gom_new_XXX(const char* xref);
    +int           gom_delete_XXX(struct XXX* obj);

    +
    + + +The XXX stands for one of the following: family, individual, multimedia, note, repository, source, submitter, user_rec.
    +
    +For submission records, the gom_delete_submission() has no parameters (since there can be only one such object anyway).
    +
    +When creating new records, the application is responsible for making sure +that mandatory fields (according to the GEDCOM spec) are filled in afterwards. + In a later release, there will be checks in gom_write_file when something is missing.
    +
    +

    Adding, removing and moving cross-references
    +

    +For struct members that are of type struct xref_value, the following function is available:
    +
    struct xref_value*  gom_set_xref(struct xref_value** data, const char* xref);
    +
    +This function modifies the data variable to point to the given xref, taking care of unreferencing the old value, and referencing the new value.  If an error occurs, NULL is returned (and the data variable is not changed).  If xref is NULL, the data is set to NULL.
    +
    +For struct members that are of type struct xref_list, the following functions are available:
    +
    struct xref_list*   gom_add_xref(struct xref_list** data, const char* xref);
    +int                 gom_remove_xref(struct xref_list** data, const char* xref);
    +int                 gom_move_xref(Gom_direction dir,
    struct xref_list** data, const char* xref);
    +
    +The first function adds the given xref to the end of the data list.  The second function removes the given xref from the data list (if present; if not present an error is generated and 1 is returned).
    +
    +The third function moves the given xref up or down the data list, depending on the dir parameter, which can be:
    + +Again, an error is generated and 1 is returned if the given xref is not part +of the list.  If the xref cannot be moved up (because the first in the +list) or down (because the last in the list), a warning is generated, but +the function still returns success (0).
    +

    Adding, removing and moving substructures
    +

    +For struct members that are just a single value, the following functions are available:
    +
    struct XXX*   gom_set_new_XXX(struct XXX** data);
    +int           gom_delete_XXX(struct XXX** data);

    +
    +This is the case for XXX equal to address, change_date or place.  The first function creates a new substructure and assigns it to data (NULL is returned if there was already a value).  The second function deletes the value from data.
    +
    +Note: for change_date structs there is also the following short-cut function, which updates the date and time directly:
    +
    int gom_update_timestamp (struct change_date** obj, time_t tval);
    +For struct members that are a list (as described here), the following functions are available:
    +
    struct XXX*   gom_add_new_XXX(struct XXX** data);
    +int           gom_remove_XXX(struct XXX** data, struct XXX* obj);

    + int           gom_move_XXX(Gom_direction dir, struct XXX** data, struct XXX* obj);
    +
    + +This is the case for all XXX structs that have a next and previous member.  The first function creates a new substructure and adds it to the end of the data list.  The second function deletes the object from the data list (if present; if not present, an error is generated and 1 is returned).
    +
    +The third function moves the given obj up or down the data list, depending on the dir parameter, similar to the xref functions above.
    +
    +

    Writing the object model to file

    Writing the current object model to a file is simply done using the following function:
    int gom_write_file (const char* filename, int* total_conv_fails);
    -This writes the model to the file filename.  The second parameter can return the total number of conversion failures (pass NULL if you're not interested).
    +This writes the model to the file filename.  The second parameter can return the total number of conversion failures (pass NULL if you're not interested).  The functions in this section can be used before gom_write_file to control some settings.

    -The functions in this section can be used before gom_write_file to control some settings.
    +Before you write the file, you can update the timestamp in the header using the following function:
    +
    int gom_header_update_timestamp (time_t tval);
    +This sets the date and time fields of the header to the time indicated by tval. + The function returns 0 on success, non-zero if an error occurred.  Typically, +the function would be used as follows, to set the current time in the timestamp:
    +
    int result;
    +result = gom_header_update_timestamp(time(NULL));

    +


    $Id$
    $Name$

    @@ -195,4 +268,6 @@ The functions in this section


    +
    +
    \ No newline at end of file