Exemplo n.º 1
0
        private static void writeLink(StreamWriter file, IndiLink indiLink)
        {
            // TODO extra text
            var str = indiLink.Type == IndiLink.FAMS_TYPE ? "FAMS" : "FAMC";

            WriteCommon.writeXrefIfNotEmpty(file, str, indiLink.Xref, 1);
            WriteCommon.writeIfNotEmpty(file, "PEDI", indiLink.Pedi, 2);
            WriteCommon.writeIfNotEmpty(file, "STAT", indiLink.Stat, 2);
            WriteCommon.writeSubNotes(file, indiLink, 2);
        }
Exemplo n.º 2
0
        public static IndiLink LinkParse(ParseContext2 ctx)
        {
            UnkRec err = null;

            IndiLink link = new IndiLink();

            // Can't get here for values other than FAMC/FAMS [unless caller changes!]
            link.Type = ctx.Tag == "FAMC" ? IndiLink.FAMC_TYPE : IndiLink.FAMS_TYPE;

            string xref;
            string extra;

            parseXrefExtra(ctx.Remain, out xref, out extra);

            if (string.IsNullOrEmpty(xref))
            {
                err       = new UnkRec();
                err.Error = UnkRec.ErrorCode.MissIdent;
                err.Beg   = err.End = ctx.Begline + ctx.Parent.BegLine;
                err.Tag   = ctx.Tag;
                ctx.Parent.Errors.Add(err);
            }
            else
            {
                link.Xref = xref;
            }

            if (!string.IsNullOrEmpty(extra))
            {
                link.Extra = extra;
            }

            //StructParseContext ctx2 = new StructParseContext(ctx, link);
            StructParseContext ctx2 = PContextFactory.Alloc(ctx, link);

            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);

            if (err != null)
            {
                // Fallout from GedValid: an error in the link should not create an IndiLink
                err.End = ctx.Endline + ctx.Parent.BegLine; // entire structure in error
                return(null);
            }

            return(link);
        }