Migrated doxygen.conf to doxygen 1.3
[gedcom-parse.git] / include / gedcom.h.in
index 7625ef4075f68515e687f384b85c7bb25a8ff00b..4d73b97f7ce8ffc80034427f7cf0e229ec05c550 100644 (file)
@@ -47,7 +47,7 @@ int gedcom_check_version(int major, int minor, int patch);
 /***  First the records and elements to subscribe upon                  ***/
 /**************************************************************************/
                                                                           
-typedef enum _REC {
+typedef enum Gedcom_rec {
   REC_HEAD,
   REC_FAM,
   REC_INDI,
@@ -61,7 +61,7 @@ typedef enum _REC {
   NR_OF_RECS     /* Just a final value to be used in array boundaries */
 } Gedcom_rec;
 
-typedef enum _ELT {
+typedef enum Gedcom_elt {
   ELT_HEAD_SOUR = NR_OF_RECS,
   ELT_HEAD_SOUR_VERS,
   ELT_HEAD_SOUR_NAME,
@@ -239,26 +239,47 @@ typedef enum _ELT {
 /**************************************************************************/
 /***  Definition of some auxiliary types                                ***/
 /**************************************************************************/
-                                                                          
-typedef enum _MECH {
-  IMMED_FAIL,
-  DEFER_FAIL,
-  IGNORE_ERRORS
-} Gedcom_err_mech;
-
-typedef enum _MSG {
-  ERROR,
-  WARNING,
-  MESSAGE
-} Gedcom_msg_type;
-
-typedef enum _DATE_TYPE {
+
+  /** \addtogroup error */
+  /** @{ */
+  /** \brief Error handling mechanisms.
+      
+      These are the possible error handling mechanisms.
+      See \ref gedcom_set_error_handling.
+  */
+enum _Gedcom_err_mech {
+  IMMED_FAIL,    /**< immediately fail the parsing on an error (this is
+                      the default) */
+  DEFER_FAIL,    /**< continue parsing after an error, but return a failure
+                      code eventually */
+  IGNORE_ERRORS  /**< continue parsing after an error, return success always */
+};
+
+  /** \brief Error handling mechanisms. */
+typedef enum _Gedcom_err_mech Gedcom_err_mech;
+
+  /** \brief Message type in message handler callbacks
+      
+      This will be passed to the message callback to indicate the message type.
+      See \ref gedcom_set_message_handler.
+  */
+enum _Gedcom_msg_type {
+  ERROR,               /**< An error message */
+  WARNING,             /**< A warning message */
+  MESSAGE              /**< Just a message */
+};
+
+  /** \brief Message type in message handler callbacks */
+typedef enum _Gedcom_msg_type Gedcom_msg_type;
+  /** @} */
+
+typedef enum Date_type {
   DATE_UNRECOGNIZED,   /* Neither jday1 as jday2 are significant */
   DATE_EXACT,          /* Only jday1 is significant */
   DATE_BOUNDED         /* Both jday1 and jday2 are significant */
 } Date_type;
 
-typedef enum _CALENDAR_TYPE {
+typedef enum Calendar_type {
   CAL_GREGORIAN,
   CAL_JULIAN,
   CAL_HEBREW,
@@ -266,12 +287,12 @@ typedef enum _CALENDAR_TYPE {
   CAL_UNKNOWN
 } Calendar_type;
 
-typedef enum _YEAR_TYPE {
+typedef enum Year_type {
   YEAR_SINGLE,
   YEAR_DOUBLE     /* In this case, the 'year' indicates the last value */
 } Year_type;
 
-typedef enum _DATE_VAL_MOD {
+typedef enum Date_value_type {
   /* Simple date */
   DV_NO_MODIFIER,
   /* Range values */
@@ -324,7 +345,7 @@ struct date_value {
 /* Type for context handling, meant to be opaque */
 typedef void* Gedcom_ctxt;
 
-typedef enum _XREF_TYPE {
+typedef enum Xref_type {
   XREF_NONE,
   XREF_FAM,
   XREF_INDI,
@@ -344,7 +365,7 @@ struct xref_value {
   Gedcom_ctxt object;
 };
 
-typedef enum _AGE_TYPE {
+typedef enum Age_type {
   AGE_UNRECOGNIZED,
   AGE_CHILD,
   AGE_INFANT,
@@ -352,7 +373,7 @@ typedef enum _AGE_TYPE {
   AGE_NUMERIC
 } Age_type;
 
-typedef enum _AGE_MODIFIER {
+typedef enum Age_modifier {
   AGE_NO_MODIFIER,
   AGE_LESS_THAN,
   AGE_GREATER_THAN
@@ -367,36 +388,49 @@ struct age_value {
   char phrase[MAX_PHRASE_LEN + 1];
 };
 
-typedef enum _ENC {
+typedef enum Encoding {
   ONE_BYTE      = 0x00,
   TWO_BYTE_HILO = 0x01,
   TWO_BYTE_LOHI = 0x02
 } Encoding;
 
-typedef enum _ENC_BOM {
+typedef enum Enc_bom {
   WITHOUT_BOM = 0x00,
   WITH_BOM    = 0x10
 } Enc_bom;
 
-typedef enum _ENC_LINE_END {
+typedef enum Enc_line_end {
   END_CR    = 0,
   END_LF    = 1,
   END_CR_LF = 2,
   END_LF_CR = 3
 } Enc_line_end;
 
-typedef enum _DATE_INPUT {
+typedef enum Enc_from {
+  ENC_FROM_FILE = 0,
+  ENC_FROM_SYS  = 1,
+  ENC_MANUAL    = 2
+} Enc_from;
+
+struct encoding_state;
+
+typedef enum Date_input {
   DI_FROM_STRINGS,
   DI_FROM_NUMBERS,
   DI_FROM_SDN
 } Date_input;
 
+typedef enum Gedcom_compat {
+  COMPAT_ALLOW_OUT_OF_CONTEXT = 0x01
+} Gedcom_compat;
+
 /**************************************************************************/
 /***  Things meant to be internal, susceptible to changes               ***/
 /***  Use the GEDCOM_STRING/GEDCOM_DATE interface instead of relying    ***/
 /***  on this !!                                                        ***/
 /**************************************************************************/
-                                                                          
+
+/* Update strings in interface.c if this changes */
 typedef enum _GEDCOM_VAL_TYPE {
   GV_NULL       = 0x01,
   GV_CHAR_PTR   = 0x02,
@@ -426,12 +460,12 @@ extern struct age_value  def_age_val;
 extern struct xref_value def_xref_val;
 
 #define GV_CHECK_CAST(VAL, TYPE, MEMBER, DEFVAL)                              \
-   ((VAL->type == TYPE) ?                                                     \
-    VAL->value.MEMBER :                                                       \
-    (gedcom_cast_error(__FILE__,__LINE__, TYPE, VAL->type), DEFVAL))
+   (((VAL)->type == TYPE) ?                                                   \
+    (VAL)->value.MEMBER :                                                     \
+    (gedcom_cast_error(__FILE__,__LINE__, TYPE, (VAL)->type), DEFVAL))
 
 #define GV_IS_TYPE(VAL, TYPE)                                                 \
-   (VAL->type == TYPE)
+   ((VAL)->type == TYPE)
 
 /**************************************************************************/
 /***  Function interface                                                ***/
@@ -476,6 +510,10 @@ typedef struct Gedcom_write_struct* Gedcom_write_hndl;
 #define GEDCOM_IS_XREF_PTR(VAL) \
    GV_IS_TYPE(VAL, GV_XREF_PTR)
 
+  /** \brief Message handler callback
+      \ingroup error
+      See description of \ref gedcom_set_message_handler().
+  */
 typedef void
         (*Gedcom_msg_handler)
         (Gedcom_msg_type type, char *msg);
@@ -503,13 +541,27 @@ typedef void
         (Gedcom_elt elt, Gedcom_ctxt parent, int level, char *tag,
          char *raw_value, int tag_value);
 
+  /** \addtogroup main */
+  /** @{ */
+  /** \brief Initializes the Gedcom parser library */
 int     gedcom_init();
+  /** \brief Parses an existing Gedcom file */
 int     gedcom_parse_file(const char* file_name);
+  /** \brief Starts a new Gedcom model */
 int     gedcom_new_model();
-void    gedcom_set_debug_level(int level, FILE* trace_output);
+  /** @} */
+
+  /** \addtogroup error */
+  /** @{ */
+  /** \brief Sets the error handler callback */
+void    gedcom_set_message_handler(Gedcom_msg_handler func);
+  /** \brief Determine what happens on an error */
 void    gedcom_set_error_handling(Gedcom_err_mech mechanism);
+  /** @} */
+  
+void    gedcom_set_debug_level(int level, FILE* trace_output);
 void    gedcom_set_compat_handling(int enable_compat);
-void    gedcom_set_message_handler(Gedcom_msg_handler func);
+void    gedcom_set_compat_options(Gedcom_compat options);
 void    gedcom_set_default_callback(Gedcom_def_cb func);
 
 void    gedcom_subscribe_to_record(Gedcom_rec rec,
@@ -521,13 +573,13 @@ void    gedcom_subscribe_to_element(Gedcom_elt elt,
 
 /* Separate value parsing functions */
 struct date_value  gedcom_parse_date(const char* line_value);
-char*              gedcom_date_to_string(struct date_value* val);
-struct date_value* gedcom_new_date_value(struct date_value* copy_from);
+char*              gedcom_date_to_string(const struct date_value* val);
+struct date_value* gedcom_new_date_value(const struct date_value* copy_from);
 int   gedcom_normalize_date(Date_input compute_from, struct date_value *val);
 
 struct age_value  gedcom_parse_age(const char* line_value);
-struct age_value* gedcom_new_age_value(struct age_value* copy_from);
-char*             gedcom_age_to_string(struct age_value* val);
+struct age_value* gedcom_new_age_value(const struct age_value* copy_from);
+char*             gedcom_age_to_string(const struct age_value* val);
 
 /* Handling cross-references */
 struct xref_value *gedcom_get_by_xref(const char *key);
@@ -540,31 +592,33 @@ int                gedcom_delete_xref(const char* xrefstr);
 /* Writing support */
 Gedcom_write_hndl  gedcom_write_open(const char* filename);
 int  gedcom_write_close(Gedcom_write_hndl hndl, int *total_conv_fails);
-int  gedcom_write_set_encoding(const char* charset, Encoding width,
+int  gedcom_write_set_encoding(Enc_from from,
+                              const char* charset, Encoding width,
                                Enc_bom bom);
-int  gedcom_write_set_line_terminator(Enc_line_end end);
+int  gedcom_write_set_line_terminator(Enc_from from, Enc_line_end end);
 
 int  gedcom_write_record_str(Gedcom_write_hndl hndl,
-                            Gedcom_rec rec, char* xrefstr, char* val);
+                            Gedcom_rec rec, const char* xrefstr,
+                             const char* val);
   
 int gedcom_write_element_str(Gedcom_write_hndl hndl, Gedcom_elt elt,
                             int parsed_tag, int parent_rec_or_elt,
-                            char* val);
+                            const char* val);
 int gedcom_write_element_xref(Gedcom_write_hndl hndl, Gedcom_elt elt,
                               int parsed_tag, int parent_rec_or_elt,
-                             struct xref_value* val);
+                             const struct xref_value* val);
 
 int gedcom_write_element_date(Gedcom_write_hndl hndl,
                              Gedcom_elt elt, int tag, int parent_rec_or_elt,
-                             struct date_value* val);
+                             const struct date_value* val);
 int gedcom_write_element_age(Gedcom_write_hndl hndl,
                             Gedcom_elt elt, int tag, int parent_rec_or_elt,
-                            struct age_value* val);
+                            const struct age_value* val);
 
-int gedcom_write_user_str(Gedcom_write_hndl hndl, int level, char* tag,
-                         char* xrefstr, char* value);
-int gedcom_write_user_xref(Gedcom_write_hndl hndl, int level, char* tag,
-                          char* xrefstr, struct xref_value* val);
+int gedcom_write_user_str(Gedcom_write_hndl hndl, int level, const char* tag,
+                         const char* xrefstr, const char* value);
+int gedcom_write_user_xref(Gedcom_write_hndl hndl, int level, const char* tag,
+                          const char* xrefstr, const struct xref_value* val);
 
 /* For use in gom */
 int        gedcom_error(const char* s, ...);