X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Fgom_internal.h;h=46c42a100815edb60b732c60de7fa25decb014e5;hb=f110a9eb416fe4d8824be87b46cf4c50ba927088;hp=829b13d584e9ff1019e6e4d526e63787b6f9f4fa;hpb=505301d49e81bcd0e1827026cd4672b8722ac349;p=gedcom-parse.git diff --git a/gom/gom_internal.h b/gom/gom_internal.h index 829b13d..46c42a1 100644 --- a/gom/gom_internal.h +++ b/gom/gom_internal.h @@ -75,6 +75,10 @@ void gom_cast_error(const char* file, int line, void gom_no_context(const char* file, int line); void gom_unexpected_context(const char* file, int line, OBJ_TYPE found); +int gom_write_xref_list(Gedcom_write_hndl hndl, + Gedcom_elt elt, int tag, int parent_rec_or_elt, + struct xref_list* val); + #define MAKE_GOM_CTXT(CTXT_TYPE, STRUCTTYPE, CTXT_PTR) \ make_gom_ctxt(CTXT_TYPE, T_ ## STRUCTTYPE, CTXT_PTR) @@ -105,15 +109,6 @@ void def_elt_end(Gedcom_elt elt, Gedcom_ctxt parent, Gedcom_ctxt self, Gedcom_val parsed_value); void set_xref_type(struct xref_value *xr, const char* str); -typedef enum { - WITHOUT_NL, - WITH_NL -} NL_TYPE; - -char* concat_strings(NL_TYPE type, char *str1, const char *str2); -struct date_value* dup_date(struct date_value dv); -struct age_value* dup_age(struct age_value age); - /* Doubly-linked list, but last rec->next is NULL (doesn't go to first rec) */ #define LINK_CHAIN_ELT(STRUCTTYPE, FIRSTVAL, VAL) \ { \ @@ -163,11 +158,18 @@ void NULL_DESTROY(void* anything); char *raw_value UNUSED, int parsed_tag UNUSED, \ Gedcom_val parsed_value UNUSED +#define _REC_END_PARAMS_ Gedcom_rec rec UNUSED, Gedcom_ctxt self UNUSED, \ + Gedcom_val parsed_value UNUSED + #define _ELT_PARAMS_ Gedcom_elt elt UNUSED, Gedcom_ctxt parent UNUSED, \ int level UNUSED, char *tag UNUSED, \ char *raw_value UNUSED, int parsed_tag UNUSED, \ Gedcom_val parsed_value UNUSED +#define _ELT_END_PARAMS_ Gedcom_elt elt UNUSED, Gedcom_ctxt parent UNUSED, \ + Gedcom_ctxt self UNUSED, \ + Gedcom_val parsed_value UNUSED + #define REC_CB(STRUCTTYPE,CB_NAME,FUNC) \ Gedcom_ctxt CB_NAME(_REC_PARAMS_) \ { \ @@ -211,6 +213,46 @@ void NULL_DESTROY(void* anything); return (Gedcom_ctxt)result; \ } +#define STRING_END_CB(STRUCTTYPE,CB_NAME,FIELD) \ + void CB_NAME(_ELT_END_PARAMS_) \ + { \ + Gom_ctxt ctxt = (Gom_ctxt)self; \ + if (! ctxt) \ + NO_CONTEXT; \ + else { \ + struct STRUCTTYPE *obj = SAFE_CTXT_CAST(STRUCTTYPE, ctxt); \ + if (obj) { \ + char *str = GEDCOM_STRING(parsed_value); \ + char *newvalue = strdup(str); \ + if (! newvalue) \ + MEMORY_ERROR; \ + else \ + obj->FIELD = newvalue; \ + } \ + destroy_gom_ctxt(ctxt); \ + } \ + } + +#define STRING_END_REC_CB(STRUCTTYPE,CB_NAME,FIELD) \ + void CB_NAME(_REC_END_PARAMS_) \ + { \ + Gom_ctxt ctxt = (Gom_ctxt)self; \ + if (! ctxt) \ + NO_CONTEXT; \ + else { \ + struct STRUCTTYPE *obj = SAFE_CTXT_CAST(STRUCTTYPE, ctxt); \ + if (obj) { \ + char *str = GEDCOM_STRING(parsed_value); \ + char *newvalue = strdup(str); \ + if (! newvalue) \ + MEMORY_ERROR; \ + else \ + obj->FIELD = newvalue; \ + } \ + destroy_gom_ctxt(ctxt); \ + } \ + } + #define DATE_CB(STRUCTTYPE,CB_NAME,FIELD) \ Gedcom_ctxt CB_NAME(_ELT_PARAMS_) \ { \ @@ -222,7 +264,7 @@ void NULL_DESTROY(void* anything); = SAFE_CTXT_CAST(STRUCTTYPE, (Gom_ctxt)parent); \ if (obj) { \ struct date_value dv = GEDCOM_DATE(parsed_value); \ - obj->FIELD = dup_date(dv); \ + obj->FIELD = gedcom_new_date_value(&dv); \ if (! obj->FIELD) \ MEMORY_ERROR; \ else \ @@ -243,7 +285,7 @@ void NULL_DESTROY(void* anything); = SAFE_CTXT_CAST(STRUCTTYPE, (Gom_ctxt)parent); \ if (obj) { \ struct age_value age = GEDCOM_AGE(parsed_value); \ - obj->FIELD = dup_age(age); \ + obj->FIELD = gedcom_new_age_value(&age); \ if (! obj->FIELD) \ MEMORY_ERROR; \ else \