5a706cc74765ff9126b42d889c2b4bbd0a9ac913
[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
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /* Sub-structures */
34
35 struct user_data {
36   int level;
37   char *tag;
38   char *str_value;
39   struct xref_value *xref_value;
40   struct user_data *next;
41   struct user_data *previous;
42 };
43
44 struct address {                      /* ADDRESS_STRUCTURE */
45   char *full_label;                   /* ADDRESS_LINE */
46   char *line1;                        /* ADDRESS_LINE1 */
47   char *line2;                        /* ADDRESS_LINE2 */
48   char *city;                         /* ADDRESS_CITY */
49   char *state;                        /* ADDRESS_STATE */
50   char *postal;                       /* ADDRESS_POSTAL_CODE */
51   char *country;                      /* ADDRESS_COUNTRY */
52   struct user_data *extra;
53 };
54
55 struct text {
56   char *text;                         /* TEXT_FROM_SOURCE */
57   struct user_data *extra;
58   struct text *next;
59   struct text *previous;
60 };
61
62 struct source_citation {              /* SOURCE_CITATION */
63   char *description;                  /* SOURCE_DESCRIPTION */
64   struct xref_value *reference;
65   char *page;                         /* WHERE_WITHIN_SOURCE */
66   char *event;                        /* EVENT_TYPE_CITED_FROM */
67   char *role;                         /* ROLE_IN_EVENT */
68   struct date_value *date;            /* ENTRY_RECORDING_DATE */
69   struct text *text;
70   char *quality;                      /* CERTAINTY_ASSESSMENT */
71   struct multimedia_link *mm_link;
72   struct note_sub *note;
73   struct user_data *extra;
74   struct source_citation *next;
75   struct source_citation *previous;
76 };
77
78 struct note_sub {                     /* NOTE_STRUCTURE */
79   char *text;                         /* SUBMITTER_TEXT */
80   struct xref_value *reference;
81   struct source_citation *citation;
82   struct user_data *extra;
83   struct note_sub *next;
84   struct note_sub *previous;
85 };
86
87 struct place {                        /* PLACE_STRUCTURE */
88   char *value;                        /* PLACE_VALUE */
89   char *place_hierarchy;              /* PLACE_HIERARCHY */
90   struct source_citation *citation;
91   struct note_sub *note;
92   struct user_data *extra;
93 };
94
95 struct multimedia_link {              /* MULTIMEDIA_LINK */
96   struct xref_value *reference;
97   char *form;                         /* MULTIMEDIA_FORMAT */
98   char *title;                        /* DESCRIPTIVE_TITLE */
99   char *file;                         /* MULTIMEDIA_FILE_REFERENCE */
100   struct note_sub *note;
101   struct user_data *extra;
102   struct multimedia_link *next;
103   struct multimedia_link *previous;
104 };
105
106 struct lds_event {                    /* LDS_INDIVIDUAL_ORDINANCE */
107   int event;
108   char *event_name;
109   char *date_status;                  /* LDS_BAPTISM_DATE_STATUS */
110   struct date_value *date;            /* DATE_LDS_ORD */
111   char *temple_code;                  /* TEMPLE_CODE */
112   char *place_living_ordinance;       /* PLACE_LIVING_ORDINANCE */
113   struct xref_value *family;
114   struct source_citation *citation;
115   struct note_sub *note;
116   struct user_data *extra;
117   struct lds_event *next;
118   struct lds_event *previous;
119 };
120
121 struct user_ref_number {
122   char *value;                        /* USER_REFERENCE_NUMBER */
123   char *type;                         /* USER_REFERENCE_TYPE */
124   struct user_data *extra;
125   struct user_ref_number *next;
126   struct user_ref_number *previous;
127 };
128
129 struct change_date {                  /* CHANGE_DATE_STRUCTURE */
130   struct date_value *date;            /* CHANGE_DATE */
131   char *time;                         /* TIME_VALUE */
132   struct note_sub *note;
133   struct user_data *extra;
134 };
135
136 struct event {                        /* FAMILY_EVENT_STRUCTURE */
137   int event;
138   char *event_name;
139   char *val;
140   char *type;                         /* EVENT_DESCRIPTOR */
141   struct date_value *date;            /* DATE_VALUE */
142   struct place *place;
143   struct address *address;
144   char *phone[3];                     /* PHONE_NUMBER */
145   struct age_value *age;              /* AGE_AT_EVENT */
146   char *agency;                       /* RESPONSIBLE_AGENCY */
147   char *cause;                        /* CAUSE_OF_EVENT */
148   struct source_citation *citation;
149   struct multimedia_link *mm_link;
150   struct note_sub *note;
151   struct age_value *husband_age;
152   struct age_value *wife_age;
153   struct xref_value *family;
154   char *adoption_parent;              /* ADOPTED_BY_WHICH_PARENT */
155   struct user_data *extra;
156   struct event *next;
157   struct event *previous;
158 };
159
160 struct xref_list {
161   struct xref_value *xref;
162   struct user_data *extra;
163   struct xref_list *next;
164   struct xref_list *previous;
165 };
166
167 struct personal_name {                /* PERSONAL_NAME_STRUCTURE */
168   char *name;                         /* NAME_PERSONAL */
169   char *prefix;                       /* NAME_PIECE_PREFIX */
170   char *given;                        /* NAME_PIECE_GIVEN */
171   char *nickname;                     /* NAME_PIECE_NICKNAME */
172   char *surname_prefix;               /* NAME_PIECE_SURNAME_PREFIX */
173   char *surname;                      /* NAME_PIECE_SURNAME */
174   char *suffix;                       /* NAME_PIECE_SUFFIX */
175   struct source_citation *citation;
176   struct note_sub *note;
177   struct user_data *extra;
178   struct personal_name *next;
179   struct personal_name *previous;
180 };
181
182 struct pedigree {
183   char *pedigree;                     /* PEDIGREE_LINKAGE_TYPE */
184   struct user_data *extra;
185   struct pedigree *next;
186   struct pedigree *previous;
187 };
188
189 struct family_link {                  /* CHILD_TO_FAMILY_LINK */
190   struct xref_value *family;
191   struct pedigree *pedigree;
192   struct note_sub *note;
193   struct user_data *extra;
194   struct family_link *next;
195   struct family_link *previous;
196 };
197
198 struct association {                  /* ASSOCIATION_STRUCTURE */
199   struct xref_value *to;
200   char *type;                         /* RECORD_TYPE */
201   char *relation;                     /* RELATION_IS_DESCRIPTOR */
202   struct source_citation *citation;
203   struct note_sub *note;
204   struct user_data *extra;
205   struct association *next;
206   struct association *previous;
207 };
208
209 struct source_event {
210   char *recorded_events;              /* EVENTS_RECORDED */
211   struct date_value *date_period;     /* DATE_PERIOD */
212   char *jurisdiction;                 /* SOURCE_JURISDICTION_PLACE */
213   struct user_data *extra;
214   struct source_event *next;
215   struct source_event *previous;
216 };
217
218 struct source_description {
219   char *call_number;                  /* SOURCE_CALL_NUMBER */
220   char *media;                        /* SOURCE_MEDIA_TYPE */
221   struct user_data *extra;
222   struct source_description *next;
223   struct source_description *previous;
224 };
225
226 /* Main structures */
227
228 struct header {                       /* HEADER */
229   struct header_source {
230     char *id;                         /* APPROVED_SYSTEM_ID */
231     char *name;                       /* NAME_OF_PRODUCT */
232     char *version;                    /* VERSION_NUMBER */
233     struct header_corporation {
234       char *name;                     /* NAME_OF_BUSINESS */
235       struct address *address;
236       char *phone[3];                 /* PHONE_NUMBER */
237     } corporation;
238     struct header_data {
239       char *name;                     /* NAME_OF_SOURCE_DATA */
240       struct date_value *date;        /* PUBLICATION_DATE */
241       char *copyright;                /* COPYRIGHT_SOURCE_DATA */
242     } data;
243   } source;
244   char *destination;                  /* RECEIVING_SYSTEM_NAME */
245   struct date_value *date;            /* TRANSMISSION_DATE */
246   char *time;                         /* TIME_VALUE */
247   struct xref_value *submitter;
248   struct xref_value *submission;
249   char *filename;                     /* FILE_NAME */
250   char *copyright;                    /* COPYRIGHT_GEDCOM_FILE */
251   struct header_gedcom {
252     char *version;                    /* VERSION_NUMBER */
253     char *form;                       /* GEDCOM_FORM */
254   } gedcom;
255   struct header_charset {
256     char *name;                       /* CHARACTER_SET */
257     char *version;                    /* VERSION_NUMBER */
258   } charset;
259   char *language;                     /* LANGUAGE_OF_TEXT */
260   char *place_hierarchy;              /* PLACE_HIERARCHY */
261   char *note;                         /* GEDCOM_CONTENT_DESCRIPTION */
262   struct user_data *extra;
263 };
264
265 struct submission {                   /* SUBMISSION_RECORD */
266   char *xrefstr;
267   struct xref_value *submitter;
268   char *family_file;                  /* NAME_OF_FAMILY_FILE */
269   char *temple_code;                  /* TEMPLE_CODE */
270   char *nr_of_ancestor_gens;          /* GENERATIONS_OF_ANCESTORS */
271   char *nr_of_descendant_gens;        /* GENERATIONS_OF_DESCENDANTS */
272   char *ordinance_process_flag;       /* ORDINANCE_PROCESS_FLAG */
273   char *record_id;                    /* AUTOMATED_RECORD_ID */
274   struct user_data *extra;
275 };
276
277 struct family {                       /* FAM_RECORD */
278   char *xrefstr;
279   struct event *event;
280   struct xref_value *husband;
281   struct xref_value *wife;
282   struct xref_list *children;
283   char *nr_of_children;               /* COUNT_OF_CHILDREN */
284   struct xref_list *submitters;
285   struct lds_event *lds_spouse_sealing;
286   struct source_citation *citation;
287   struct multimedia_link *mm_link;
288   struct note_sub *note;
289   struct user_ref_number *ref;
290   char *record_id;                    /* AUTOMATED_RECORD_ID */
291   struct change_date *change_date;
292   struct user_data *extra;
293   struct family *next;
294   struct family *previous;
295 };
296
297 struct individual {                   /* INDIVIDUAL_RECORD */
298   char *xrefstr;
299   char *restriction_notice;           /* RESTRICTION_NOTICE */
300   struct personal_name *name;
301   char *sex;                          /* SEX_VALUE */
302   struct event *event;
303   struct event *attribute;
304   struct lds_event *lds_individual_ordinance;
305   struct family_link *child_to_family;
306   struct family_link *spouse_to_family;
307   struct xref_list *submitters;
308   struct association *association;
309   struct xref_list *alias;
310   struct xref_list *ancestor_interest;
311   struct xref_list *descendant_interest;
312   struct source_citation *citation;
313   struct multimedia_link *mm_link;
314   struct note_sub *note;
315   char *record_file_nr;               /* PERMANENT_RECORD_FILE_NUMBER */
316   char *ancestral_file_nr;            /* ANCESTRAL_FILE_NUMBER */
317   struct user_ref_number *ref;
318   char *record_id;                    /* AUTOMATED_RECORD_ID */
319   struct change_date *change_date;
320   struct user_data *extra;
321   struct individual *next;
322   struct individual *previous;
323 };
324
325 struct multimedia {                   /* MULTIMEDIA_RECORD */
326   char *xrefstr;
327   char *form;                         /* MULTIMEDIA_FORMAT */
328   char *title;                        /* DESCRIPTIVE_TITLE */
329   struct note_sub *note;
330   char *data;                         /* ENCODED_MULTIMEDIA_LINE */
331   struct xref_value *continued;
332   struct user_ref_number *ref;
333   char *record_id;                    /* AUTOMATED_RECORD_ID */
334   struct change_date *change_date;
335   struct user_data *extra;
336   struct multimedia *next;
337   struct multimedia *previous;
338 };
339
340 struct note {                         /* NOTE_RECORD */
341   char *xrefstr;
342   char *text;                         /* SUBMITTER_TEXT */
343   struct source_citation *citation;
344   struct user_ref_number *ref;
345   char *record_id;                    /* AUTOMATED_RECORD_ID */
346   struct change_date *change_date;
347   struct user_data *extra;
348   struct note *next;
349   struct note *previous;
350 };
351
352 struct repository {                   /* REPOSITORY_RECORD */
353   char *xrefstr;
354   char *name;                         /* NAME_OF_REPOSITORY */
355   struct address *address;
356   char *phone[3];                     /* PHONE_NUMBER */
357   struct note_sub *note;
358   struct user_ref_number *ref;
359   char *record_id;                    /* AUTOMATED_RECORD_ID */
360   struct change_date *change_date;
361   struct user_data *extra;
362   struct repository *next;
363   struct repository *previous;
364 };
365
366 struct source {                       /* SOURCE_RECORD */
367   char *xrefstr;
368   struct source_data {
369     struct source_event *event;
370     char *agency;                     /* RESPONSIBLE_AGENCY */
371     struct note_sub *note;
372   } data;
373   char *author;                       /* SOURCE_ORIGINATOR */
374   char *title;                        /* SOURCE_DESCRIPTIVE_TITLE */
375   char *abbreviation;                 /* SOURCE_FILED_BY_ENTRY */
376   char *publication;                  /* SOURCE_PUBLICATION_FACTS */
377   char *text;                         /* TEXT_FROM_SOURCE */
378   struct repo_link {
379     struct xref_value *link;
380     struct note_sub *note;
381     struct source_description *description;
382   } repository;
383   struct multimedia_link *mm_link;
384   struct note_sub *note;
385   struct user_ref_number *ref;
386   char *record_id;                    /* AUTOMATED_RECORD_ID */
387   struct change_date *change_date;
388   struct user_data *extra;
389   struct source *next;
390   struct source *previous;
391 };
392
393 struct submitter {                    /* SUBMITTER_RECORD */
394   char *xrefstr;
395   char *name;                         /* SUBMITTER_NAME */
396   struct address *address;
397   char *phone[3];                     /* PHONE_NUMBER */
398   struct multimedia_link *mm_link;
399   char *language[3];                  /* LANGUAGE_PREFERENCE */
400   char *record_file_nr;               /* SUBMITTER_REGISTERED_RFN */
401   char *record_id;                    /* AUTOMATED_RECORD_ID */
402   struct change_date *change_date;
403   struct user_data *extra;
404   struct submitter *next;
405   struct submitter *previous;
406 };
407
408 struct user_rec {
409   char *xrefstr;
410   char *tag;
411   char *str_value;
412   struct xref_value *xref_value;
413   struct user_data *extra;
414   struct user_rec *next;
415   struct user_rec *previous;
416 };
417
418 /* Functions */
419
420 int  gom_parse_file(const char *file_name);
421 int  gom_new_model();
422 int  gom_write_file(const char* file_name, int *total_conv_fails);
423
424 struct header*     gom_get_header();
425 struct submission* gom_get_submission();
426
427 struct family*     gom_get_first_family();
428 struct family*     gom_get_family_by_xref(const char *xref);
429
430 struct individual* gom_get_first_individual();
431 struct individual* gom_get_individual_by_xref(const char *xref);
432
433 struct multimedia* gom_get_first_multimedia();
434 struct multimedia* gom_get_multimedia_by_xref(const char *xref);
435
436 struct note*       gom_get_first_note();
437 struct note*       gom_get_note_by_xref(const char *xref);
438
439 struct repository* gom_get_first_repository();
440 struct repository* gom_get_repository_by_xref(const char *xref);
441
442 struct source*     gom_get_first_source();
443 struct source*     gom_get_source_by_xref(const char *xref);
444
445 struct submitter*  gom_get_first_submitter();
446 struct submitter*  gom_get_submitter_by_xref(const char *xref);
447
448 struct user_rec*   gom_get_first_user_rec();
449 struct user_rec*   gom_get_user_rec_by_xref(const char *xref);
450
451 char* gom_get_string(char* data);
452 char* gom_set_string(char** data, const char* utf8_str);
453
454 char* gom_get_string_for_locale(char* data, int* conversion_failures);
455 char* gom_set_string_for_locale(char** data, const char* locale_str);
456 void  gom_set_unknown(const char* unknown);
457
458 #ifdef __cplusplus
459 }
460 #endif
461
462 #endif /* __GEDCOM_GOM_H */