1 /* Place sub-structure in the gedcom object model.
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.
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.
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.
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
29 #include "source_citation.h"
34 #include "gom_internal.h"
36 Gedcom_ctxt sub_place_start(_ELT_PARAMS_)
38 Gom_ctxt ctxt = (Gom_ctxt)parent;
39 Gom_ctxt result = NULL;
44 struct place *place = SUB_MAKEFUNC(place)();
46 place->value = strdup(GEDCOM_STRING(parsed_value));
53 switch (ctxt->ctxt_type) {
55 case ELT_SUB_FAM_EVT_EVEN:
56 case ELT_SUB_INDIV_ATTR:
57 case ELT_SUB_INDIV_RESI:
58 case ELT_SUB_INDIV_BIRT:
59 case ELT_SUB_INDIV_GEN:
60 case ELT_SUB_INDIV_ADOP:
61 case ELT_SUB_INDIV_EVEN:
62 ADDFUNC2_NOLIST(event,place)(ctxt, place); break;
64 UNEXPECTED_CONTEXT(ctxt->ctxt_type);
66 result = MAKE_GOM_CTXT(elt, place, place);
71 return (Gedcom_ctxt)result;
74 DEFINE_SUB_MAKEFUNC(place)
75 DEFINE_SUB_SETFUNC(place)
76 DEFINE_SUB_DELETEFUNC(place)
78 DEFINE_STRING_CB(place, sub_place_form_start, place_hierarchy)
80 DEFINE_ADDFUNC2(place, source_citation, citation)
81 DEFINE_ADDFUNC2(place, note_sub, note)
82 DEFINE_ADDFUNC2(place, user_data, extra)
84 void place_subscribe()
86 gedcom_subscribe_to_element(ELT_SUB_PLAC, sub_place_start, def_elt_end);
87 gedcom_subscribe_to_element(ELT_SUB_PLAC_FORM,
88 sub_place_form_start, def_elt_end);
91 void UNREFALLFUNC(place)(struct place* obj)
94 UNREFALLFUNC(source_citation)(obj->citation);
95 UNREFALLFUNC(note_sub)(obj->note);
96 UNREFALLFUNC(user_data)(obj->extra);
100 void CLEANFUNC(place)(struct place* place)
103 SAFE_FREE(place->value);
104 SAFE_FREE(place->place_hierarchy);
105 DESTROY_CHAIN_ELTS(source_citation, place->citation);
106 DESTROY_CHAIN_ELTS(note_sub, place->note);
107 DESTROY_CHAIN_ELTS(user_data, place->extra);
112 int write_place(Gedcom_write_hndl hndl, int parent, struct place* place)
116 if (!place) return 1;
118 result |= gedcom_write_element_str(hndl, ELT_SUB_PLAC, 0,
119 parent, place->value);
120 if (place->place_hierarchy)
121 result |= gedcom_write_element_str(hndl, ELT_SUB_PLAC_FORM, 0,
122 ELT_SUB_PLAC, place->place_hierarchy);
124 result |= write_citations(hndl, ELT_SUB_PLAC, place->citation);
126 result |= write_note_subs(hndl, ELT_SUB_PLAC, place->note);
128 result |= write_user_data(hndl, place->extra);