From 70dd8d0091ad90636d0957346830ca564db969f6 Mon Sep 17 00:00:00 2001 From: Peter Verthez Date: Sun, 25 Aug 2002 11:30:48 +0000 Subject: [PATCH] Describe extra argument in callback. --- doc/usage.html | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/doc/usage.html b/doc/usage.html index c50bd47..6880dc8 100644 --- a/doc/usage.html +++ b/doc/usage.html @@ -1,13 +1,9 @@ - - - - Using the GEDCOM parser library +Using the GEDCOM parser library + - - - + + +

Using the GEDCOM parser library


@@ -169,7 +165,8 @@ the information that comes via the default callback in plain textual format.
-
Gedcom_ctxt my_header_start_cb (int level,
+
Gedcom_ctxt my_header_start_cb (Gedcom_rec rec,
+                                int level,
                                Gedcom_val xref,
                    @@ -185,7 +182,7 @@ of a GEDCOM file.  First, have a look at the following piece of code:
}

- void my_header_end_cb (Gedcom_ctxt self)
+ void my_header_end_cb (Gedcom_rec rec, Gedcom_ctxt self)
{
  printf("The header ends, context is %d\n", (int)self);   /* context will print as "1" */
@@ -203,7 +200,7 @@ callback. The end callback is optional: you can pass NULL if you are not interested in the end callback.  The identifiers to use as first argument to the function (here REC_HEAD) are described in the interface -details .
+details .  These are also passed as first argument in the callbacks (the Gedcom_rec argument).

From the name of the function it becomes clear that this function is specific to complete records.  For the separate elements in records @@ -242,7 +239,9 @@ and included via gedcom.h (so no need to include gedcom-t We will now retrieve the SOUR field (the name of the program that wrote the file) from the header:
-
Gedcom_ctxt my_header_source_start_cb(Gedcom_ctxt +
Gedcom_ctxt my_header_source_start_cb(Gedcom_elt  elt,
+                      +                Gedcom_ctxt parent,
                                      int   @@ -265,7 +264,8 @@ wrote the file) from the header:
  return parent;
}

- void my_header_source_end_cb(Gedcom_ctxt parent,
+ void my_header_source_end_cb(Gedcom_elt  elt,
+                             Gedcom_ctxt parent,
                             Gedcom_ctxt self,
                    @@ -291,8 +291,7 @@ wrote the file) from the header:
can be its own context object of course.  The end callback is called with both the context of the parent and the context of itself, which in this example will be the same.  Again, the list of identifiers to use as -a first argument for the subscription function are detailed in the interface details .
+a first argument for the subscription function are detailed in the interface details .  Again, these are passed as first argument in the callback (the Gedcom_elt argument).

If we look at the other arguments of the start callback, we see the level number (the initial number of the line in the GEDCOM file), the tag @@ -305,8 +304,7 @@ in the section for record callbacks above.
The Gedcom_val type is meant to be an opaque type.  The only thing that needs to be known about it is that it can contain specific data types, which have to be retrieved from it using pre-defined macros. -  These data types are described in the interface details. +  These data types are described in the interface details.

Some extra notes:
@@ -334,7 +332,7 @@ in the section for record callbacks above.
applications.  To preserve this extra data anyway, a default callback can be registered by the application, as in the following example:
-
void my_default_cb (Gedcom_ctxt parent, int level, +
void my_default_cb (Gedcom_elt elt, Gedcom_ctxt parent, int level, char* tag, char* raw_value, int parsed_tag)
{
  ...
@@ -365,7 +363,7 @@ data is saved again in a GEDCOM file.  To make it more specific, consider   char* extra_text;
};

- Gedcom_ctxt my_header_start_cb(int level, Gedcom_val xref, char* tag, + Gedcom_ctxt my_header_start_cb(Gedcom_rec rec, int level, Gedcom_val xref, char* tag, char *raw_value,
                               int parsed_tag, Gedcom_val parsed_value)
@@ -374,7 +372,7 @@ data is saved again in a GEDCOM file.  To make it more specific, consider   return (Gedcom_ctxt)head;
}

- void my_default_cb(Gedcom_ctxt parent, int level, char* tag, char* + void my_default_cb(Gedcom_elt elt, Gedcom_ctxt parent, int level, char* tag, char* raw_value, int parsed_tag)
{
  struct header head = (struct header)parent;
@@ -538,8 +536,7 @@ because any locale can be converted to UTF-8.
implementation, the following steps need to be taken by the application (more detailed info can be found in the info file of the GNU libc library in the "Generic Charset Conversion" section under "Character Set Handling" -or online +or online here):
    @@ -626,8 +623,7 @@ and show an error.  This is not very user friendly, of course.
  • Skip over the character that can't be converted and append a "?" to the output buffer, then call iconv again.  Skipping over a UTF-8 character is fairly simple, - as follows from the encoding rules + as follows from the encoding rules :
@@ -717,5 +713,5 @@ handle needs to be closed (when the program exits):
                    
- - +
+ \ No newline at end of file -- 2.30.2