Small correction in help string.
[gedcom-parse.git] / doc / usage.html
index 6880dc8f65ab3f3025d679ab4d488f676d8d17cf..dc2e70ad7d9f03ebde68f0f2b722ca9caf204076 100644 (file)
@@ -1,9 +1,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Using the GEDCOM parser library</title>
   
                                                               
-  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"></head>
-
-<body text="#000000" bgcolor="#ffffff" link="#000099" vlink="#990099" alink="#000099">
+  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"></head><body text="#000000" bgcolor="#ffffff" link="#000099" vlink="#990099" alink="#000099">
                  
 <h1 align="center">Using the GEDCOM parser library</h1>
          <br>
@@ -19,8 +17,7 @@
             <li><a href="#Start_and_end_callbacks">Start and end callbacks</a></li>
             <li><a href="#Default_callbacks">Default callbacks</a></li>
                                
-  </ul>
-         <li><a href="#Other_API_functions">Other API functions</a></li>
+  </ul><li><a href="#Other_API_functions">Other API functions</a></li>
                            
   <ul>
            <li><a href="#Debugging">Debugging</a></li>
   </ul>
     <li><a href="#Converting_character_sets">Converting character sets</a></li>
     <li><a href="#Support_for_configure.in">Support for configure.in</a><br>
+<br>
      </li>
-           <li><a href="interface.html">Interface details</a><br>
+           <li><a href="interface.html">Interface details of the callback parser</a></li><li><a href="gom.html">C object model</a><br>
             </li>
+
                
 </ul>
                
 <hr width="100%" size="2">         
 <h2><a name="Overview"></a>Overview<br>
-         </h2>
-         The GEDCOM parser library is built as a callback-based parser (comparable 
-    to the SAX interface of XML). &nbsp;It comes with:<br>
+         </h2>          The GEDCOM
+parser library provides two interfaces. &nbsp;At the one hand, it can be
+used as a callback-based parser (comparable      to the SAX interface of
+XML); at the other hand, the parser can be used to convert the GEDCOM file
+into an object model (comparable to the DOM interface of XML). &nbsp;It comes
+with:<br>
                  
 <ul>
            <li>a library (<code>libgedcom.so</code>), to be linked in the 
-application     program</li>
+application     program, which implements the callback parser</li>
            <li>a header file (<code>gedcom.h</code>), to be used in the sources 
    of  the application program</li>
        <li>a header file (<code>gedcom-tags.h</code>) that is also installed, 
-  but that is automatically included via <code>gedcom.h</code><br>
-       </li>
+  but that is automatically included via <code>gedcom.h</code></li></ul>Additionally, if you want to use the GEDCOM C object model, the following should be used (note that <code>libgedcom.so</code> is also needed in this case, because the object model uses the callback parser internally):<br>
+<ul>
+  <li>a library (<code>libgedcom_gom.so</code>), to be linked in the application program, which implements the C object model</li>
+  <li>a header file (<code>gom.h</code>), to be used in the sources of the application program<br>
+  </li>
+
                  
 </ul>
+
          Next to these, there is also a data directory in <code>$PREFIX/share/gedcom-parse</code>
           that contains some additional stuff, but which is not immediately 
  important    at first. &nbsp;I'll leave the description of the data directory 
  for later.<br>
          <br>
-         The very simplest call of the gedcom parser is simply the following
-  piece   of code (include of the gedcom header is assumed, as everywhere
+         The very simplest call of the gedcom callback parser is simply the following
+  piece   of code (include of the <code>gedcom.h</code> header is assumed, as everywhere
 in  this manual):<br>
                  
 <blockquote><code>int result;<br>
@@ -71,32 +78,42 @@ in  this manual):<br>
  is  parse  the entire file and return the result. &nbsp;The function returns
   0 on success  and 1 on failure. &nbsp;No other information is available
 using   this function  only.<br>
-  <br>
-  The call to <code>gedcom_init</code>() should be one of the first calls 
+<br>
+Alternatively, programs using the C object model should use the following (in this case, the inclusion of both <code>gedcom.h</code> and <code>gom.h</code> is required):<br>
+  
+<blockquote><code>int result;<br>
+  ...<br>
+    <b>gedcom_init</b>();<br>
+         ...<br>
+         result = <b>gom_parse_file</b>("myfamily.ged");<br>
+           </code>   </blockquote>
+The call to <code>gom_parse_file</code> will build the C object model, which is then a complete representation of the GEDCOM file.<br>
+<br>
+No matter which of the interfaces you use, the call to <code>gedcom_init</code>() should be one of the first calls 
 in your program. &nbsp;The requirement is that it should come before the first
 call to <code>iconv_open</code> (part of the generic character set conversion
 feature) in the program, either by your program itself, or indirectly by
 the library calls it makes. &nbsp;Practically, it should e.g. come before
  any calls to any GTK functions, because GTK uses <code>iconv_open</code>
- in its initialization. &nbsp;For the same reason it is also advised to put
-the <code>-lgedcom</code> option on the linking of the program as the last
-option, so that its initialization code is run first.<br>
+ in its initialization.<br>
+&nbsp; <br>
+For the same reason it is also advised to put
+the <code>-lgedcom</code> option
+on the linking of the program as the last option, so that its initialization
+code is run first. &nbsp;In the case of using the C object model, the linking
+options should be: <code>-lgedcom_gom -lgedcom</code><br>
           <br>
         The next sections will refine this piece of code to be able to have
  meaningful errors   and the actual data that is in the file.<br>
                            
 <hr width="100%" size="2">                       
-<h2><a name="Error_handling"></a>Error handling</h2>
-        Since this is a relatively simple topic, it is discussed before the 
- actual   callback mechanism, although it also uses a callback...<br>
-          <br>
-        The library can be used in several different circumstances, both
+<h2><a name="Error_handling"></a>Error handling</h2>The library can be used in several different circumstances, both
 terminal-based     as GUI-based. &nbsp;Therefore, it leaves the actual display
 of the error    message up to the application. &nbsp;For this, the application
 needs to  register  a callback before parsing the GEDCOM file, which will
 be called  by the library   on errors, warnings and messages.<br>
           <br>
-        A typical piece of code would be:<br>
+        A typical piece of code would be (<code>gom_parse_file</code> would be called in case the C object model is used):<br>
                            
 <blockquote><code>void <b>my_message_handler</b> (Gedcom_msg_type type,  
  char *msg)<br>
@@ -129,8 +146,7 @@ way it wants.   &nbsp;Warnings are similar, but use "Warning" instead of "Error"
 <hr width="100%" size="2">                                            
 <h2><a name="Data_callback_mechanism"></a>Data callback mechanism</h2>
         The most important use of the parser is of course to get the data 
-out   of  the GEDCOM file. &nbsp;As already mentioned, the parser uses a callback
-  mechanism  for that. &nbsp;In fact, the mechanism involves two levels.<br>
+out   of  the GEDCOM file. &nbsp;This section focuses on the callback mechanism (see <a href="gom.html">here</a> for the C object model). &nbsp;In fact, the mechanism involves two levels.<br>
               <br>
         The primary level is that each of the sections in a GEDCOM file is
  notified    to the application code via a "start element" callback and an
@@ -399,7 +415,8 @@ raw_value,   int parsed_tag)<br>
                               
 <h2><a name="Other_API_functions"></a>Other API functions<br>
                      </h2>
-       Although the above describes the basic interface of libgedcom, there 
+
+       Although the above describes the basic interface of the gedcom parser, there 
  are   some other functions that allow to customize the behaviour of the library.
    &nbsp;These will be explained in the current section.<br>
                                                                         
@@ -664,37 +681,30 @@ handle needs to be closed (when the program exits):<br>
                          
 <hr width="100%" size="2">                                              
  
-<h2><a name="Support_for_configure.in"></a>Support for configure.in</h2>
-   Programs using the GEDCOM parser library and using autoconf to configure 
- their sources can use the following statements in configure.in (the example 
- is checking for gedcom-parse, version 1.34):<br>
-                                                   
-<blockquote><code>AC_CHECK_LIB(gedcom, gedcom_parse_file,,<br>
-   &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AC_MSG_ERROR(Cannot
- find libgedcom: Please install gedcom-parse))<br>
-   AC_MSG_CHECKING(for libgedcom version)<br>
-   AC_TRY_RUN([<br>
-   #include &lt;stdio.h&gt;<br>
-   #include &lt;stdlib.h&gt;<br>
-   #include &lt;gedcom.h&gt;<br>
-   int<br>
-   main()<br>
-   {<br>
-   if (GEDCOM_PARSE_VERSION &gt;= 1034) exit(0);<br>
-   exit(1);<br>
-   }],<br>
-   ac_gedcom_version_ok='yes',<br>
-   ac_gedcom_version_ok='no',<br>
-   ac_gedcom_version_ok='no')<br>
-   if test "$ac_gedcom_version_ok" = 'yes' ; then<br>
-   &nbsp; AC_MSG_RESULT(ok)<br>
-   else<br>
-   &nbsp; AC_MSG_RESULT(not ok)<br>
-   &nbsp; AC_MSG_ERROR(You need at least version 1.34 of gedcom-parse)<br>
-   fi</code><br>
-                                                   </blockquote>
-    There are three preprocessor symbols defined for version checks in the
- header:<br>
+<h2><a name="Support_for_configure.in"></a>Support for configure.in</h2>There
+is a macro available for use in configure.in for applications that are using
+autoconf to configure their sources. &nbsp;The following macro checks whether
+the Gedcom parser library is available and whether its version is high enough:<br>
+<blockquote><code>AM_LIB_GEDCOM_PARSER([<i>major</i>,[<i>minor</i>,[<i>patch</i>]]])</code><br>
+</blockquote>
+All the arguments are optional and default to 0. &nbsp;E.g. to check for
+version 1.34, you would put in configure.in the following statement:<br>
+<blockquote><code>AM_LIB_GEDCOM_PARSER(1,34)</code><br>
+</blockquote>
+To be able to use this macro in the sources of your application, you have three options:<br>
+<ul>
+  <li>Put the file <code>m4/gedcom.m4</code> in your autoconf data directory (i.e. the path given by '<code>aclocal --print-ac-dir</code>', usually <code>/usr/share/aclocal</code>). &nbsp;You can do this automatically by going into the m4 subdirectory and typing '<code>make install-m4</code>'.<br>
+    <br>
+  </li>
+  <li>If you're using autoconf, but not automake, copy the contents of <code>m4/gedcom.m4</code> in the <code>aclocal.m4</code> file in your sources.<br>
+    <br>
+  </li>
+  <li>If you're using automake, copy the contents of <code>m4/gedcom.m4</code> in the <code>acinclude.m4</code> file in your sources.<br>
+  </li>
+</ul>
+<br>
+There are three preprocessor symbols defined for version checks in the
+ header (but their direct use is deprecated: please use the macro above):<br>
                                                      
 <ul>
                                                      <li><code>GEDCOM_PARSE_VERSION_MAJOR</code></li>
@@ -704,6 +714,7 @@ handle needs to be closed (when the program exits):<br>
                                                      
 </ul>
    The last one is equal to <code>(GEDCOM_PARSE_VERSION_MAJOR * 1000) + GEDCOM_PARSE_VERSION_MINOR.</code><br>
+
      
 <hr width="100%" size="2">                                              
                                        
@@ -713,5 +724,8 @@ handle needs to be closed (when the program exits):<br>
 <pre>                    </pre>
                                                                         
                                                         
+<br>
+<br>
+<br>
 <br>
 </body></html>
\ No newline at end of file