コード例 #1
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
        }
コード例 #2
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);
        }
コード例 #3
0
        public static Note NoteParser(ParseContextCommon ctx, int linedex, char level)
        {
            Note note = new Note();

            note.Builder = new StringBuilder(512);
            var ctx2 = PContextFactory.Alloc(ctx, note, linedex); // TODO no record for context!

            ctx2.Level = level;

            if (ctx as ParseContext2 != null)
            {
                ctx2.Record = (ctx as ParseContext2).Parent;
            }
            // FAM.NOTE.SOUR crapped out 'cause Record was null
            if (ctx as StructParseContext != null)
            {
                ctx2.Record = (ctx as StructParseContext).Record;
            }

            if (!string.IsNullOrEmpty(ctx.Remain) && ctx.Remain[0] == '@')
            {
                note.Xref = ctx.Remain.Trim(trim);
            }
            else
            {
                note.Builder.Append(ctx.gs.RemainLS(ctx.Lines.GetLine(linedex)));
                //note.Builder.Append(ctx.Remain); // NOTE: trailing spaces are preserved, may be confusing
            }

            StructParse(ctx2, tagDict);

            if (note.Builder.Length > 0)
            {
                // Store an in-line note to the database
                string text = note.Builder.ToString().Replace("@@", "@");
#if SQLITE
                note.Key = SQLite.Instance.StoreNote(text);
#elif LITEDB
                note.Key = LiteDB.Instance.StoreNote(text);
#elif NOTESTREAM
                note.Key = NoteStream.Instance.StoreNote(text);
#else
                note.Text = text;
#endif
            }
            else
            {
                note.Text = "";
            }

            //note.Text = note.Builder.ToString().Replace("@@", "@"); // TODO faster replace;
            note.Builder = null;
            ctx.Endline  = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(note);
        }
コード例 #4
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);
        }
コード例 #5
0
        public static Address AddrParse(StructParseContext ctx, int linedex, char level)
        {
            Address addr = new Address();
            var     ctx2 = PContextFactory.Alloc(ctx, addr, linedex);

            ctx2.Record = ctx.Record;
            ctx2.Level  = level;
            addr.Adr   += ctx.Remain;
            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(addr);
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
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);
        }
コード例 #9
0
        public static AgeDetail AgeParser(StructParseContext ctx, int linedex, char level)
        {
            AgeDetail det  = new AgeDetail();
            var       ctx2 = PContextFactory.Alloc(ctx, det, linedex);

            ctx2.Level  = level;
            ctx2.Record = ctx.Record;
            if (!string.IsNullOrWhiteSpace(ctx.Remain))
            {
                det.Detail = ctx.Remain;
            }
            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(det);
        }
コード例 #10
0
        public static SourceData DataParser(ParseContext2 ctx)
        {
            SourceData data = new SourceData();
            //StructParseContext ctx2 = new StructParseContext(ctx, data);
            var ctx2 = PContextFactory.Alloc(ctx, data);

            if (!string.IsNullOrWhiteSpace(ctx.Remain))
            {
                addNote(data, ctx.Remain);
            }

            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(data);
        }
コード例 #11
0
// TODO copy-pasta

        public static MediaLink MediaParser(ParseContext2 ctx)
        {
            MediaLink mlink = new MediaLink();
            //StructParseContext ctx2 = new StructParseContext(ctx, mlink);
            StructParseContext ctx2 = PContextFactory.Alloc(ctx, mlink);

// TODO parse xref using standard xref parser
// TODO preserve non-xref remain as note
            if (!string.IsNullOrEmpty(ctx.Remain) && ctx.Remain[0] == '@')
            {
                mlink.Xref = ctx.Remain.Trim(trim);
            }

            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(mlink);
        }
コード例 #12
0
        public static MediaLink MediaParser(StructParseContext ctx, int linedex, char level)
        {
            MediaLink mlink = new MediaLink();
            var       ctx2  = PContextFactory.Alloc(ctx, mlink, linedex);

            ctx2.Level  = level;
            ctx2.Record = ctx.Record;
// TODO parse xref using standard xref parser
// TODO preserve non-xref remain as note
            if (!string.IsNullOrEmpty(ctx.Remain) && ctx.Remain[0] == '@')
            {
                mlink.Xref = ctx.Remain.Trim(trim);
            }

            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(mlink);
        }
コード例 #13
0
        public static NameRec Parse(ParseContext2 ctx)
        {
            // TODO can this be shortcut when context length is only 1 line?
            var name = new NameRec();

            if (!parseName(name, ctx.Remain1, ctx.Begline, ctx.Parent.Errors))
            {
                UnkRec err = new UnkRec();
                err.Error = UnkRec.ErrorCode.EmptyName;
                err.Beg   = err.End = ctx.Begline;
                ctx.Parent.Errors.Add(err);
            }
            //StructParseContext ctx2 = new StructParseContext(ctx, name);
            var ctx2 = PContextFactory.Alloc(ctx, name);

            StructParse(ctx2, tagDict);
            ctx.Endline = ctx2.Endline;
            PContextFactory.Free(ctx2);
            return(name);
        }
コード例 #14
0
ファイル: RepoCitParse.cs プロジェクト: zhifu10001/YAGP
        public static RepoCit CitParser(ParseContext2 ctx)
        {
            RepoCit cit = new RepoCit();
            //StructParseContext ctx2 = new StructParseContext(ctx, cit);
            var ctx2 = PContextFactory.Alloc(ctx, cit);

            string extra;
            string xref;

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

            if (string.IsNullOrEmpty(xref))
            {
                cit.Xref = null;
            }
            else
            {
                cit.Xref = xref;
            }

            if (xref != null && (xref.Trim().Length == 0 || cit.Xref.Contains("@"))) // NOTE: missing xref is valid, but NOT empty one!
            {
                UnkRec unk = new UnkRec();
                unk.Error = UnkRec.ErrorCode.InvXref;
                ctx.Parent.Errors.Add(unk);
                // TODO ctx.Parent.Errors.Add(new UnkRec { Error = "Invalid repository citation xref id" }); // TODO not yet reproduced in the field
                // TODO error line #s
            }
            if (!string.IsNullOrEmpty(extra))
            {
                addNote(cit, extra);
            }

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