Rename 'add' functions to 'new'.
[gedcom-parse.git] / include / gom.h
1 /* External header for the Gedcom parser library.
2    Copyright (C) 2002 The Genes Development Team
3    This file is part of the Gedcom parser library.
4    Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2002.
5
6    The Gedcom parser library is free software; you can redistribute it
7    and/or modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    The Gedcom parser library is distributed in the hope that it will be
12    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the Gedcom parser library; if not, write to the
18    Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 /* $Id$ */
22 /* $Name$ */
23
24 #ifndef __GEDCOM_GOM_H
25 #define __GEDCOM_GOM_H
26
27 #include "gedcom.h"
28 #include <time.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /* Sub-structures */
35
36 struct user_data {
37   int level;
38   char *tag;
39   char *str_value;
40   struct xref_value *xref_value;
41   struct user_data *next;
42   struct user_data *previous;
43 };
44
45 struct address {                      /* ADDRESS_STRUCTURE */
46   char *full_label;                   /* ADDRESS_LINE */
47   char *line1;                        /* ADDRESS_LINE1 */
48   char *line2;                        /* ADDRESS_LINE2 */
49   char *city;                         /* ADDRESS_CITY */
50   char *state;                        /* ADDRESS_STATE */
51   char *postal;                       /* ADDRESS_POSTAL_CODE */
52   char *country;                      /* ADDRESS_COUNTRY */
53   struct user_data *extra;
54 };
55
56 struct text {
57   char *text;                         /* TEXT_FROM_SOURCE */
58   struct user_data *extra;
59   struct text *next;
60   struct text *previous;
61 };
62
63 struct source_citation {              /* SOURCE_CITATION */
64   char *description;                  /* SOURCE_DESCRIPTION */
65   struct xref_value *reference;
66   char *page;                         /* WHERE_WITHIN_SOURCE */
67   char *event;                        /* EVENT_TYPE_CITED_FROM */
68   char *role;                         /* ROLE_IN_EVENT */
69   struct date_value *date;            /* ENTRY_RECORDING_DATE */
70   struct text *text;
71   char *quality;                      /* CERTAINTY_ASSESSMENT */
72   struct multimedia_link *mm_link;
73   struct note_sub *note;
74   struct user_data *extra;
75   struct source_citation *next;
76   struct source_citation *previous;
77 };
78
79 struct note_sub {                     /* NOTE_STRUCTURE */
80   char *text;                         /* SUBMITTER_TEXT */
81   struct xref_value *reference;
82   struct source_citation *citation;
83   struct user_data *extra;
84   struct note_sub *next;
85   struct note_sub *previous;
86 };
87
88 struct place {                        /* PLACE_STRUCTURE */
89   char *value;                        /* PLACE_VALUE */
90   char *place_hierarchy;              /* PLACE_HIERARCHY */
91   struct source_citation *citation;
92   struct note_sub *note;
93   struct user_data *extra;
94 };
95
96 struct multimedia_link {              /* MULTIMEDIA_LINK */
97   struct xref_value *reference;
98   char *form;                         /* MULTIMEDIA_FORMAT */
99   char *title;                        /* DESCRIPTIVE_TITLE */
100   char *file;                         /* MULTIMEDIA_FILE_REFERENCE */
101   struct note_sub *note;
102   struct user_data *extra;
103   struct multimedia_link *next;
104   struct multimedia_link *previous;
105 };
106
107 struct lds_event {                    /* LDS_INDIVIDUAL_ORDINANCE */
108   int event;
109   char *event_name;
110   char *date_status;                  /* LDS_BAPTISM_DATE_STATUS */
111   struct date_value *date;            /* DATE_LDS_ORD */
112   char *temple_code;                  /* TEMPLE_CODE */
113   char *place_living_ordinance;       /* PLACE_LIVING_ORDINANCE */
114   struct xref_value *family;
115   struct source_citation *citation;
116   struct note_sub *note;
117   struct user_data *extra;
118   struct lds_event *next;
119   struct lds_event *previous;
120 };
121
122 struct user_ref_number {
123   char *value;                        /* USER_REFERENCE_NUMBER */
124   char *type;                         /* USER_REFERENCE_TYPE */
125   struct user_data *extra;
126   struct user_ref_number *next;
127   struct user_ref_number *previous;
128 };
129
130 struct change_date {                  /* CHANGE_DATE_STRUCTURE */
131   struct date_value *date;            /* CHANGE_DATE */
132   char *time;                         /* TIME_VALUE */
133   struct note_sub *note;
134   struct user_data *extra;
135 };
136
137 struct event {                        /* FAMILY_EVENT_STRUCTURE */
138   int event;
139   char *event_name;
140   char *val;
141   char *type;                         /* EVENT_DESCRIPTOR */
142   struct date_value *date;            /* DATE_VALUE */
143   struct place *place;
144   struct address *address;
145   char *phone[3];                     /* PHONE_NUMBER */
146   struct age_value *age;              /* AGE_AT_EVENT */
147   char *agency;                       /* RESPONSIBLE_AGENCY */
148   char *cause;                        /* CAUSE_OF_EVENT */
149   struct source_citation *citation;
150   struct multimedia_link *mm_link;
151   struct note_sub *note;
152   struct age_value *husband_age;
153   struct age_value *wife_age;
154   struct xref_value *family;
155   char *adoption_parent;              /* ADOPTED_BY_WHICH_PARENT */
156   struct user_data *extra;
157   struct event *next;
158   struct event *previous;
159 };
160
161 struct xref_list {
162   struct xref_value *xref;
163   struct user_data *extra;
164   struct xref_list *next;
165   struct xref_list *previous;
166 };
167
168 struct personal_name {                /* PERSONAL_NAME_STRUCTURE */
169   char *name;                         /* NAME_PERSONAL */
170   char *prefix;                       /* NAME_PIECE_PREFIX */
171   char *given;                        /* NAME_PIECE_GIVEN */
172   char *nickname;                     /* NAME_PIECE_NICKNAME */
173   char *surname_prefix;               /* NAME_PIECE_SURNAME_PREFIX */
174   char *surname;                      /* NAME_PIECE_SURNAME */
175   char *suffix;                       /* NAME_PIECE_SUFFIX */
176   struct source_citation *citation;
177   struct note_sub *note;
178   struct user_data *extra;
179   struct personal_name *next;
180   struct personal_name *previous;
181 };
182
183 struct pedigree {
184   char *pedigree;                     /* PEDIGREE_LINKAGE_TYPE */
185   struct user_data *extra;
186   struct pedigree *next;
187   struct pedigree *previous;
188 };
189
190 struct family_link {                  /* CHILD_TO_FAMILY_LINK */
191   struct xref_value *family;
192   struct pedigree *pedigree;
193   struct note_sub *note;
194   struct user_data *extra;
195   struct family_link *next;
196   struct family_link *previous;
197 };
198
199 struct association {                  /* ASSOCIATION_STRUCTURE */
200   struct xref_value *to;
201   char *type;                         /* RECORD_TYPE */
202   char *relation;                     /* RELATION_IS_DESCRIPTOR */
203   struct source_citation *citation;
204   struct note_sub *note;
205   struct user_data *extra;
206   struct association *next;
207   struct association *previous;
208 };
209
210 struct source_event {
211   char *recorded_events;              /* EVENTS_RECORDED */
212   struct date_value *date_period;     /* DATE_PERIOD */
213   char *jurisdiction;                 /* SOURCE_JURISDICTION_PLACE */
214   struct user_data *extra;
215   struct source_event *next;
216   struct source_event *previous;
217 };
218
219 struct source_description {
220   char *call_number;                  /* SOURCE_CALL_NUMBER */
221   char *media;                        /* SOURCE_MEDIA_TYPE */
222   struct user_data *extra;
223   struct source_description *next;
224   struct source_description *previous;
225 };
226
227 /* Main structures */
228
229 struct header {                       /* HEADER */
230   struct header_source {
231     char *id;                         /* APPROVED_SYSTEM_ID */
232     char *name;                       /* NAME_OF_PRODUCT */
233     char *version;                    /* VERSION_NUMBER */
234     struct header_corporation {
235       char *name;                     /* NAME_OF_BUSINESS */
236       struct address *address;
237       char *phone[3];                 /* PHONE_NUMBER */
238     } corporation;
239     struct header_data {
240       char *name;                     /* NAME_OF_SOURCE_DATA */
241       struct date_value *date;        /* PUBLICATION_DATE */
242       char *copyright;                /* COPYRIGHT_SOURCE_DATA */
243     } data;
244   } source;
245   char *destination;                  /* RECEIVING_SYSTEM_NAME */
246   struct date_value *date;            /* TRANSMISSION_DATE */
247   char *time;                         /* TIME_VALUE */
248   struct xref_value *submitter;
249   struct xref_value *submission;
250   char *filename;                     /* FILE_NAME */
251   char *copyright;                    /* COPYRIGHT_GEDCOM_FILE */
252   struct header_gedcom {
253     char *version;                    /* VERSION_NUMBER */
254     char *form;                       /* GEDCOM_FORM */
255   } gedcom;
256   struct header_charset {
257     char *name;                       /* CHARACTER_SET */
258     char *version;                    /* VERSION_NUMBER */
259   } charset;
260   char *language;                     /* LANGUAGE_OF_TEXT */
261   char *place_hierarchy;              /* PLACE_HIERARCHY */
262   char *note;                         /* GEDCOM_CONTENT_DESCRIPTION */
263   struct user_data *extra;
264 };
265
266 struct submission {                   /* SUBMISSION_RECORD */
267   char *xrefstr;
268   struct xref_value *submitter;
269   char *family_file;                  /* NAME_OF_FAMILY_FILE */
270   char *temple_code;                  /* TEMPLE_CODE */
271   char *nr_of_ancestor_gens;          /* GENERATIONS_OF_ANCESTORS */
272   char *nr_of_descendant_gens;        /* GENERATIONS_OF_DESCENDANTS */
273   char *ordinance_process_flag;       /* ORDINANCE_PROCESS_FLAG */
274   char *record_id;                    /* AUTOMATED_RECORD_ID */
275   struct user_data *extra;
276 };
277
278 struct family {                       /* FAM_RECORD */
279   char *xrefstr;
280   struct event *event;
281   struct xref_value *husband;
282   struct xref_value *wife;
283   struct xref_list *children;
284   char *nr_of_children;               /* COUNT_OF_CHILDREN */
285   struct xref_list *submitters;
286   struct lds_event *lds_spouse_sealing;
287   struct source_citation *citation;
288   struct multimedia_link *mm_link;
289   struct note_sub *note;
290   struct user_ref_number *ref;
291   char *record_id;                    /* AUTOMATED_RECORD_ID */
292   struct change_date *change_date;
293   struct user_data *extra;
294   struct family *next;
295   struct family *previous;
296 };
297
298 struct individual {                   /* INDIVIDUAL_RECORD */
299   char *xrefstr;
300   char *restriction_notice;           /* RESTRICTION_NOTICE */
301   struct personal_name *name;
302   char *sex;                          /* SEX_VALUE */
303   struct event *event;
304   struct event *attribute;
305   struct lds_event *lds_individual_ordinance;
306   struct family_link *child_to_family;
307   struct family_link *spouse_to_family;
308   struct xref_list *submitters;
309   struct association *association;
310   struct xref_list *alias;
311   struct xref_list *ancestor_interest;
312   struct xref_list *descendant_interest;
313   struct source_citation *citation;
314   struct multimedia_link *mm_link;
315   struct note_sub *note;
316   char *record_file_nr;               /* PERMANENT_RECORD_FILE_NUMBER */
317   char *ancestral_file_nr;            /* ANCESTRAL_FILE_NUMBER */
318   struct user_ref_number *ref;
319   char *record_id;                    /* AUTOMATED_RECORD_ID */
320   struct change_date *change_date;
321   struct user_data *extra;
322   struct individual *next;
323   struct individual *previous;
324 };
325
326 struct multimedia {                   /* MULTIMEDIA_RECORD */
327   char *xrefstr;
328   char *form;                         /* MULTIMEDIA_FORMAT */
329   char *title;                        /* DESCRIPTIVE_TITLE */
330   struct note_sub *note;
331   char *data;                         /* ENCODED_MULTIMEDIA_LINE */
332   struct xref_value *continued;
333   struct user_ref_number *ref;
334   char *record_id;                    /* AUTOMATED_RECORD_ID */
335   struct change_date *change_date;
336   struct user_data *extra;
337   struct multimedia *next;
338   struct multimedia *previous;
339 };
340
341 struct note {                         /* NOTE_RECORD */
342   char *xrefstr;
343   char *text;                         /* SUBMITTER_TEXT */
344   struct source_citation *citation;
345   struct user_ref_number *ref;
346   char *record_id;                    /* AUTOMATED_RECORD_ID */
347   struct change_date *change_date;
348   struct user_data *extra;
349   struct note *next;
350   struct note *previous;
351 };
352
353 struct repository {                   /* REPOSITORY_RECORD */
354   char *xrefstr;
355   char *name;                         /* NAME_OF_REPOSITORY */
356   struct address *address;
357   char *phone[3];                     /* PHONE_NUMBER */
358   struct note_sub *note;
359   struct user_ref_number *ref;
360   char *record_id;                    /* AUTOMATED_RECORD_ID */
361   struct change_date *change_date;
362   struct user_data *extra;
363   struct repository *next;
364   struct repository *previous;
365 };
366
367 struct source {                       /* SOURCE_RECORD */
368   char *xrefstr;
369   struct source_data {
370     struct source_event *event;
371     char *agency;                     /* RESPONSIBLE_AGENCY */
372     struct note_sub *note;
373   } data;
374   char *author;                       /* SOURCE_ORIGINATOR */
375   char *title;                        /* SOURCE_DESCRIPTIVE_TITLE */
376   char *abbreviation;                 /* SOURCE_FILED_BY_ENTRY */
377   char *publication;                  /* SOURCE_PUBLICATION_FACTS */
378   char *text;                         /* TEXT_FROM_SOURCE */
379   struct repo_link {
380     struct xref_value *link;
381     struct note_sub *note;
382     struct source_description *description;
383   } repository;
384   struct multimedia_link *mm_link;
385   struct note_sub *note;
386   struct user_ref_number *ref;
387   char *record_id;                    /* AUTOMATED_RECORD_ID */
388   struct change_date *change_date;
389   struct user_data *extra;
390   struct source *next;
391   struct source *previous;
392 };
393
394 struct submitter {                    /* SUBMITTER_RECORD */
395   char *xrefstr;
396   char *name;                         /* SUBMITTER_NAME */
397   struct address *address;
398   char *phone[3];                     /* PHONE_NUMBER */
399   struct multimedia_link *mm_link;
400   char *language[3];                  /* LANGUAGE_PREFERENCE */
401   char *record_file_nr;               /* SUBMITTER_REGISTERED_RFN */
402   char *record_id;                    /* AUTOMATED_RECORD_ID */
403   struct change_date *change_date;
404   struct user_data *extra;
405   struct submitter *next;
406   struct submitter *previous;
407 };
408
409 struct user_rec {
410   char *xrefstr;
411   char *tag;
412   char *str_value;
413   struct xref_value *xref_value;
414   struct user_data *extra;
415   struct user_rec *next;
416   struct user_rec *previous;
417 };
418
419 /* Functions */
420
421 int  gom_parse_file(const char *file_name);
422 int  gom_new_model();
423 int  gom_write_file(const char* file_name, int *total_conv_fails);
424
425 struct header*     gom_get_header();
426 int                gom_header_update_timestamp(time_t t);
427   
428 struct submission* gom_get_submission();
429 struct submission* gom_new_submission(const char* xrefstr);
430 int                gom_delete_submission();
431
432 struct family*     gom_get_first_family();
433 struct family*     gom_get_family_by_xref(const char *xref);
434 struct family*     gom_new_family(const char* xrefstr);
435 int                gom_delete_family(struct family* obj);
436
437 struct individual* gom_get_first_individual();
438 struct individual* gom_get_individual_by_xref(const char *xref);
439 struct individual* gom_new_individual(const char* xrefstr);
440 int                gom_delete_individual(struct individual* obj);
441
442 struct multimedia* gom_get_first_multimedia();
443 struct multimedia* gom_get_multimedia_by_xref(const char *xref);
444 struct multimedia* gom_new_multimedia(const char* xrefstr);
445 int                gom_delete_multimedia(struct multimedia* obj);
446
447 struct note*       gom_get_first_note();
448 struct note*       gom_get_note_by_xref(const char *xref);
449 struct note*       gom_new_note(const char* xrefstr);
450 int                gom_delete_note(struct note* obj);
451
452 struct repository* gom_get_first_repository();
453 struct repository* gom_get_repository_by_xref(const char *xref);
454 struct repository* gom_new_repository(const char* xrefstr);
455 int                gom_delete_repository(struct repository* obj);
456
457 struct source*     gom_get_first_source();
458 struct source*     gom_get_source_by_xref(const char *xref);
459 struct source*     gom_new_source(const char* xrefstr);
460 int                gom_delete_source(struct source* obj);
461
462 struct submitter*  gom_get_first_submitter();
463 struct submitter*  gom_get_submitter_by_xref(const char *xref);
464 struct submitter*  gom_new_submitter(const char* xrefstr);
465 int                gom_delete_submitter(struct submitter* obj);
466
467 struct user_rec*   gom_get_first_user_rec();
468 struct user_rec*   gom_get_user_rec_by_xref(const char *xref);
469 struct user_rec*   gom_new_user_rec(const char* xrefstr, const char* tag);
470 int                gom_delete_user_rec(struct user_rec* obj);
471
472 char* gom_get_string(char* data);
473 char* gom_set_string(char** data, const char* utf8_str);
474
475 char* gom_get_string_for_locale(char* data, int* conversion_failures);
476 char* gom_set_string_for_locale(char** data, const char* locale_str);
477 void  gom_set_unknown(const char* unknown);
478
479 struct xref_value* gom_set_xref(struct xref_value** data, const char* xref);
480 struct xref_list*  gom_add_xref(struct xref_list** data, const char* xref);
481 int                gom_remove_xref(struct xref_list** data, const char* xref);
482
483 struct address*    gom_set_new_address(struct address** obj);
484 int                gom_delete_address(struct address** obj);
485
486 struct place*      gom_set_new_place(struct place** obj);
487 int                gom_delete_place(struct place** obj);
488
489 struct change_date* gom_set_new_change_date(struct change_date** obj);
490 int                 gom_delete_change_date(struct change_date** obj);
491 int                 gom_update_timestamp(struct change_date** obj, time_t t);
492   
493 #ifdef __cplusplus
494 }
495 #endif
496
497 #endif /* __GEDCOM_GOM_H */