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 int type = ctxt_type(ctxt);
56 case ELT_SUB_FAM_EVT_EVEN:
57 case ELT_SUB_INDIV_ATTR:
58 case ELT_SUB_INDIV_RESI:
59 case ELT_SUB_INDIV_BIRT:
60 case ELT_SUB_INDIV_GEN:
61 case ELT_SUB_INDIV_ADOP:
62 case ELT_SUB_INDIV_EVEN:
63 ADDFUNC2_NOLIST(event,place)(ctxt, place); break;
65 UNEXPECTED_CONTEXT(type);
67 result = MAKE_GOM_CTXT(elt, place, place);
72 return (Gedcom_ctxt)result;
75 DEFINE_SUB_MAKEFUNC(place)
76 DEFINE_SUB_SETFUNC(place)
77 DEFINE_SUB_DELETEFUNC(place)
79 DEFINE_STRING_CB(place, sub_place_form_start, place_hierarchy)
81 DEFINE_ADDFUNC2(place, source_citation, citation)
82 DEFINE_ADDFUNC2(place, note_sub, note)
83 DEFINE_ADDFUNC2(place, user_data, extra)
85 void place_subscribe()
87 gedcom_subscribe_to_element(ELT_SUB_PLAC, sub_place_start, def_elt_end);
88 gedcom_subscribe_to_element(ELT_SUB_PLAC_FORM,
89 sub_place_form_start, def_elt_end);
92 void UNREFALLFUNC(place)(struct place* obj)
95 UNREFALLFUNC(source_citation)(obj->citation);
96 UNREFALLFUNC(note_sub)(obj->note);
97 UNREFALLFUNC(user_data)(obj->extra);
101 void CLEANFUNC(place)(struct place* place)
104 SAFE_FREE(place->value);
105 SAFE_FREE(place->place_hierarchy);
106 DESTROY_CHAIN_ELTS(source_citation, place->citation);
107 DESTROY_CHAIN_ELTS(note_sub, place->note);
108 DESTROY_CHAIN_ELTS(user_data, place->extra);
113 int write_place(Gedcom_write_hndl hndl, int parent, struct place* place)
117 if (!place) return 1;
119 result |= gedcom_write_element_str(hndl, ELT_SUB_PLAC, 0,
120 parent, place->value);
121 if (place->place_hierarchy)
122 result |= gedcom_write_element_str(hndl, ELT_SUB_PLAC_FORM, 0,
123 ELT_SUB_PLAC, place->place_hierarchy);
125 result |= write_citations(hndl, ELT_SUB_PLAC, place->citation);
127 result |= write_note_subs(hndl, ELT_SUB_PLAC, place->note);
129 result |= write_user_data(hndl, place->extra);