コード例 #1
0
ファイル: IndiParse.cs プロジェクト: zhifu10001/YAGP
        private void EventProc(ParseContext2 context)
        {
            var @event = FamilyEventParse.Parse(context, true);
            var indi   = (context.Parent as IndiRecord);

            indi.Events.Add(@event as IndiEvent);
        }
コード例 #2
0
ファイル: IndiAssoParse.cs プロジェクト: zhifu10001/YAGP
        public static AssoRec AssoParse(ParseContext2 ctx)
        {
            var asso = new AssoRec();

            string xref;
            string extra;

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

            if (string.IsNullOrEmpty(xref))
            {
                UnkRec err = new UnkRec();
                err.Error = UnkRec.ErrorCode.UntermIdent;
                // TODO err.Error = "Missing/unterminated identifier: " + ctx.Tag;
                err.Beg = err.End = ctx.Begline + ctx.Parent.BegLine;
                err.Tag = ctx.Tag;
                ctx.Parent.Errors.Add(err); // TODO parent level or structure level?
            }
            else
            {
                asso.Ident = xref;
            }
            //StructParseContext ctx2 = new StructParseContext(ctx, asso);
            StructParseContext ctx2 = PContextFactory.Alloc(ctx, asso);

            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(asso);
            // TODO validate relation specified
            // TODO validate ident existance
        }
コード例 #3
0
ファイル: ParseContext.cs プロジェクト: zhifu10001/YAGP
        public static StructParseContext Alloc(ParseContext2 ctx, StructCommon parent)
        {
            var spc = _pool.GetObject();

            spc.Init(ctx, parent);
            return(spc);
        }
コード例 #4
0
ファイル: IndiParse.cs プロジェクト: zhifu10001/YAGP
        private void AttribProc(ParseContext2 context)
        {
            var @event = FamilyEventParse.Parse(context, true);
            var indi   = (context.Parent as IndiRecord);

            indi.Attribs.Add((IndiEvent)@event);
        }
コード例 #5
0
ファイル: IndiParse.cs プロジェクト: zhifu10001/YAGP
        private void LdsOrdProc(ParseContext2 context)
        {
            LDSEvent evt  = LDSEventParse.Parse(context);
            var      indi = (context.Parent as IndiRecord);

            indi.LDSEvents.Add(evt);
        }
コード例 #6
0
ファイル: MediaParse.cs プロジェクト: zhifu10001/YAGP
        private void typeProc(ParseContext2 context)
        {
            // TODO 5.5: needs a warning
            var file = GetFile(context);

            file.Type = context.Remain;
        }
コード例 #7
0
ファイル: IndiParse.cs プロジェクト: zhifu10001/YAGP
        private void AssocProc(ParseContext2 context)
        {
            var res = IndiAssoParse.AssoParse(context);
            var own = (context.Parent as IndiRecord);

            own.Assocs.Add(res);
        }
コード例 #8
0
        private void GedcProc(ParseContext2 context)
        {
            var    self = (context.Parent as HeadRecord);
            string val  = seekSubRecord("VERS", context);

            self.GedVersion = val;
        }
コード例 #9
0
        private void PlacProc(ParseContext2 context)
        {
            var    self = (context.Parent as HeadRecord);
            string val  = seekSubRecord("FORM", context);

            self.PlaceFormat = val;
        }
コード例 #10
0
ファイル: MediaParse.cs プロジェクト: zhifu10001/YAGP
        private void fileProc(ParseContext2 context)
        {
            MediaFile file = new MediaFile();

            file.FileRefn = context.Remain;
            (context.Parent as MediaRecord).Files.Add(file);
        }
コード例 #11
0
ファイル: ChanStructParse.cs プロジェクト: zhifu10001/YAGP
        public static void ChanProc(ParseContext2 ctx)
        {
            ChangeRec chan = ctx.Parent.CHAN;

            if (chan.Date != null)
            {
                UnkRec err = new UnkRec();
                err.Error = UnkRec.ErrorCode.MultChan;
                GedRecParse.LookAhead(ctx);
                err.Beg = ctx.Begline + ctx.Parent.BegLine;
                err.End = ctx.Endline + ctx.Parent.BegLine;
                ctx.Parent.Errors.Add(err);
                return;
            }

            ChanParse(ctx, chan);
            if (chan.Date == null)
            {
                UnkRec err = new UnkRec();
                err.Error = UnkRec.ErrorCode.ChanDate;
                err.Beg   = ctx.Begline + ctx.Parent.BegLine;
                err.End   = ctx.Endline + ctx.Parent.BegLine;
                ctx.Parent.Errors.Add(err);
            }
        }
コード例 #12
0
        private void ldsSpouseSeal(ParseContext2 context)
        {
            LDSEvent evt = LDSEventParse.Parse(context);
            var      fam = (context.Parent as FamRecord);

            fam.LDSEvents.Add(evt);
        }
コード例 #13
0
ファイル: IndiParse.cs プロジェクト: zhifu10001/YAGP
        //private static StringCache2 _sexCache = new StringCache2();

        private void SexProc(ParseContext2 context)
        {
            var own  = (context.Parent as IndiRecord);
            var rem0 = context.Remain1;

            own.FullSex = null;

            // Hopefully the 99% case: single 'M' or 'F' w/ no trailing space
            if (rem0.Length == 1)
            {
                own.Sex = rem0[0];
                if (own.Sex != 'M' && own.Sex != 'F')
                {
                    own.FullSex = context.Remain;
                }
                return;
            }

            string rem = context.Remain.Trim();

            if (string.IsNullOrEmpty(rem))
            {
                own.Sex = 'U';
            }
            else
            {
                own.Sex = rem[0];
                if (rem != "M" && rem != "F")
                {
                    own.FullSex = rem;
                }
            }
        }
コード例 #14
0
        private void nchiProc(ParseContext2 context)
        {
            // TODO Data loss: The Master Genealogist (TMG) treats NCHI as a text field.
            // NCHI in TMG can have CONC, CONT, and other sub-tags. Here, these sub-tags
            // are not correctly connected to the NCHI tag, nor am I preserving the NCHI
            // data as entered.

            var fam = (context.Parent as FamRecord);

            int childCount;

            if (!int.TryParse(context.Remain, out childCount))
            {
                UnkRec err = new UnkRec();
                err.Error = UnkRec.ErrorCode.InvNCHI; //"Invalid child count";
                err.Beg   = err.End = context.Begline + context.Parent.BegLine;
                fam.Errors.Add(err);
            }
            else if (fam.ChildCount != -1) // has been specified once already
            {
                UnkRec err = new UnkRec();
                err.Error = UnkRec.ErrorCode.MultNCHI;
                //err.Error = "Child count specified more than once";
                err.Beg = err.End = context.Begline + context.Parent.BegLine;
                fam.Errors.Add(err);
            }
            else
            {
                fam.ChildCount = childCount;
            }
        }
コード例 #15
0
        public static SourceCit SourceCitParser(ParseContext2 ctx)
        {
            List <UnkRec> errs = new List <UnkRec>();
            var           cit  = CommonParser(ctx, ctx.Begline, ctx.Level, errs);

            ctx.Parent.Errors.AddRange(errs);
            return(cit);
        }
コード例 #16
0
        private void concProc(ParseContext2 ctx)
        {
            //(ctx.Parent as NoteRecord).Text += ctx.Remain;
            var dad = ctx.Parent as NoteRecord;

            dad.Builder.Append(ctx.gs.RemainLS(ctx.Lines.GetLine(ctx.Begline)));
            //dad.Builder.Append(ctx.Remain);
        }
コード例 #17
0
        private void dataProc(ParseContext2 context)
        {
            var data = SourceDataParse.DataParser(context);

            (context.Parent as SourceRecord).Data = data;

            // TODO validate multiple DATA records
        }
コード例 #18
0
ファイル: ChanStructParse.cs プロジェクト: zhifu10001/YAGP
        public static void ChanParse(ParseContext2 ctx, ChangeRec chan)
        {
            //StructParseContext ctx2 = new StructParseContext(ctx, chan);
            StructParseContext ctx2 = PContextFactory.Alloc(ctx, chan);

            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
        }
コード例 #19
0
ファイル: IndiParse.cs プロジェクト: zhifu10001/YAGP
        private void NameProc(ParseContext2 ctx)
        {
            var rec  = NameParse.Parse(ctx);
            var indi = (ctx.Parent as IndiRecord);

            indi.Names.Add(rec);
            // TODO parsing details
            // TODO parsing sub-records
        }
コード例 #20
0
        private void eventProc(ParseContext2 context)
        {
            // 5.5.1 : MARR allows 'Y'
            // 5.5 : most events allow 'Y'
            // Syntax changed between 5.5 and 5.5.1 for HUSB.AGE / WIFE.AGE
            var famEvent = FamilyEventParse.Parse(context, false);
            var fam      = (context.Parent as FamRecord);

            fam.FamEvents.Add((FamilyEvent)famEvent);
        }
コード例 #21
0
        private void SubmProc(ParseContext2 context)
        {
            string xref = parseForXref(context);

            if (!string.IsNullOrEmpty(xref))
            {
                var self = (context.Parent as HeadRecord);
                self.AddSubmitter(Submitter.SubmitType.SUBM, xref);
            }
        }
コード例 #22
0
        private void SourProc(ParseContext2 context)
        {
            var self = (context.Parent as HeadRecord);

            self.Source = context.Remain;
            string val = seekSubRecord("VERS", context);

            self.ProductVersion = val;
            val          = seekSubRecord("NAME", context);
            self.Product = val;
        }
コード例 #23
0
        public static Address AddrParse(ParseContext2 ctx)
        {
            Address            addr = new Address();
            StructParseContext ctx2 = PContextFactory.Alloc(ctx, addr);

            //StructParseContext ctx2 = new StructParseContext(ctx, addr);
            addr.Adr += ctx.Remain;
            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(addr);
        }
コード例 #24
0
ファイル: IndiParse.cs プロジェクト: zhifu10001/YAGP
        private static void famLink(ParseContext2 context)
        {
            var res = IndiLinkParse.LinkParse(context);

            if (res == null)
            {
                return; // Fallout from GedValid: on error don't record the link
            }
            var own = (context.Parent as IndiRecord);

            own.Links.Add(res);
        }
コード例 #25
0
ファイル: MediaParse.cs プロジェクト: zhifu10001/YAGP
        private MediaFile GetFile(ParseContext2 context)
        {
            // 5.5: no FILE tag, make sure there is a MediaFile created
            var files = (context.Parent as MediaRecord).Files;

            if (files.Count == 0)
            {
                files.Add(new MediaFile());
            }
            MediaFile file = files[files.Count - 1];

            return(file);
        }
コード例 #26
0
ファイル: LDSEventParse.cs プロジェクト: zhifu10001/YAGP
        public static LDSEvent Parse(ParseContext2 ctx)
        {
            LDSEvent evt = new LDSEvent();

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

            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(evt);
        }
コード例 #27
0
ファイル: FamilyEventParse.cs プロジェクト: zhifu10001/YAGP
        public static EventCommon Parse(ParseContext2 ctx, bool indi)
        {
            EventCommon gedEvent = indi ? new IndiEvent() as EventCommon : new FamilyEvent() as EventCommon;

            StructParseContext ctx2 = PContextFactory.Alloc(ctx, gedEvent);

            //StructParseContext ctx2 = new StructParseContext(ctx, gedEvent);
            gedEvent.Tag        = ctx.Tag;
            gedEvent.Descriptor = string.IsNullOrEmpty(ctx.Remain) ? null : ctx.Remain;
            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(gedEvent);
        }
コード例 #28
0
        private void DateProc(ParseContext2 context)
        {
            var      self = (context.Parent as HeadRecord);
            DateTime outDate;

            if (DateTime.TryParse(context.Remain.Trim(), out outDate))
            {
                self.GedDate = outDate;
            }
            else
            {
                self.GedDate = DateTime.MinValue;        // TODO attempt to derive from other information in postcheck
            }
            string val = seekSubRecord("TIME", context); // NOTE: ignoring
        }
コード例 #29
0
ファイル: IndiLinkParse.cs プロジェクト: zhifu10001/YAGP
        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);
        }
コード例 #30
0
        private void resnProc(ParseContext2 context)
        {
            var fam = (context.Parent as FamRecord);

            if (string.IsNullOrEmpty(fam.Restriction))
            {
                fam.Restriction = context.Remain.Trim();
            }
            else
            {
                UnkRec err = new UnkRec();
                err.Error = UnkRec.ErrorCode.MultRESN; // TODO "RESN specified more than once";
                err.Beg   = err.End = context.Begline + context.Parent.BegLine;
                fam.Errors.Add(err);
            }
        }