private static void subProc(StructParseContext ctx, int linedex, char level) { // TODO punting: grab&store w/o analysis var rec = (ctx.Parent as NameRec); rec.Parts.Add(new Tuple <string, string>(ctx.Tag, ctx.Remain)); }
private static void remainProc(StructParseContext context, int linedex, char level) { var me = (context.Parent as LDSEvent); switch (context.Tag) { case "DATE": me.Date = context.Remain; break; case "PLAC": me.Place = context.Remain; break; case "STAT": me.Status = context.Remain; break; case "TEMP": me.Temple = context.Remain; break; default: throw new NotSupportedException(); // NOTE: this will be thrown if a tag is added to tagDict but no case added here } }
private static void objeProc(StructParseContext context, int linedex, char level) { MediaLink mlink = MediaStructParse.MediaParser(context, linedex, level); SourceCit cit = (context.Parent as SourceCit); cit.Media.Add(mlink); }
private static void remainProc(StructParseContext context, int linedex, char level) { var famE = (context.Parent as EventCommon); switch (context.Tag) // TODO consider using reflection and property name? { case "TYPE": famE.Type = context.Remain; break; case "AGNC": famE.Agency = context.Remain; break; case "RELI": famE.Religion = context.Remain; break; case "CAUS": famE.Cause = context.Remain; break; case "RESN": famE.Restriction = context.Remain; break; } /* * Type type = target.GetType(); * PropertyInfo prop = type.GetProperty("propertyName"); * prop.SetValue(target, propertyValue, null); */ }
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 }
private static void placProc(StructParseContext context, int linedex, char level) { var dad = (context.Parent as SourceData); SourEvent even = GetEvent(dad); even.Place = context.Remain; }
private static void textProc(StructParseContext context, int linedex, char level) { string val = GedRecParse.extendedText(context); SourceCit cit = (context.Parent as SourceCit); cit.Text.Add(val); }
private static void concProc(StructParseContext context, int linedex, char level) { Note note = (context.Parent as Note); note.Builder.Append(context.gs.RemainLS(context.Lines.GetLine(linedex))); //note.Builder.Append(context.Remain); // NOTE: trailing spaces are preserved, may be confusing }
private static void calnProc(StructParseContext context, int linedex, char level) { RepoCit cit = (context.Parent as RepoCit); cit.CallNums.Add(new RepoCit.CallNum()); cit.CallNums[cit.CallNums.Count - 1].Number = context.Remain; }
// Common Note sub-structure parsing protected static void noteProc(StructParseContext ctx, int linedex, char level) { NoteHold dad = (ctx.Parent as NoteHold); var note = NoteStructParse.NoteParser(ctx, linedex, level); dad.Notes.Add(note); }
private static void dateProc(StructParseContext context, int linedex, char level) { // TODO full Date support var famE = (context.Parent as EventCommon); famE.Date = context.Remain.Trim(); // From GedMill: remove leading/trailing spaces famE.GedDate = EventDateParse.DateParser(famE.Date); }
private static void formProc(StructParseContext ctx, int linedex, char level) { // FORM may or may not follow an owning FILE tag MediaLink mlink = (ctx.Parent as MediaLink); MediaFile file = getFile(mlink); file.Form = ctx.Remain; }
private static void mediProc(StructParseContext ctx, int linedex, char level) { // HACK assuming here the MEDI tag follows a FORM tag, using the last FILE object MediaLink mlink = (ctx.Parent as MediaLink); MediaFile file = mlink.Files[mlink.Files.Count - 1]; file.Type = ctx.Remain; }
public static SourceCit SourceCitParser(StructParseContext ctx, int linedex, char level) { List <UnkRec> errs = new List <UnkRec>(); var cit = CommonParser(ctx, linedex, level, errs); ctx.Record.Errors.AddRange(errs); // TODO is record only for errors? return(cit); }
private static void evenProc(StructParseContext context, int linedex, char level) { SourceData data = (context.Parent as SourceData); SourEvent thing = new SourEvent(); thing.Text = context.Remain; data.Events.Add(thing); }
private static void mediProc(StructParseContext context, int linedex, char level) { // HACK apply this to the last CALN entry - error if more than one? RepoCit cit = (context.Parent as RepoCit); var callN = GetCallNum(cit); callN.Media = context.Remain; }
private static void placProc(StructParseContext context, int linedex, char level) { // TODO full PLACE_STRUCTURE support var famE = (context.Parent as EventCommon); //famE.Place = _placeCache.GetFromCache(context.Remain1); famE.Place = context.Remain.Trim(); }
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); }
public static void Free(StructParseContext spc) { spc.Parent = null; spc.Record = null; spc.Lines = null; spc.gs = null; spc.tagCache = null; _pool.PutObject(spc); }
private static void surnProc(StructParseContext ctx, int linedex, char level) { // TODO punting: grab&store w/o analysis var rec = (ctx.Parent as NameRec); if (ctx.Remain != rec.Surname) // only store if different { rec.Parts.Add(new Tuple <string, string>(ctx.Tag, ctx.Remain)); } }
private static void dateProc(StructParseContext ctx, int linedex, char level) { var chan = ctx.Parent as ChangeRec; DateTime res; if (DateTime.TryParse(ctx.Remain, out res)) { chan.Date = res; } // NOTE: could not parse date: will be caught by 'missing data' check }
private static SourceCit CommonParser(ParseContextCommon ctx, int linedex, char level, List <UnkRec> errs) { SourceCit cit = new SourceCit(); StructParseContext ctx2 = new StructParseContext(ctx, linedex, level, cit); // TODO no record for context! string extra; string xref; parseXrefExtra(ctx.Remain, out xref, out extra); cit.Xref = xref; if (xref != null && (xref.Trim().Length == 0 || cit.Xref.Contains("@"))) // No xref is valid but not if empty/illegal { var unk = new UnkRec(); unk.Error = UnkRec.ErrorCode.InvXref; // TODO {Error = "Invalid source citation xref id"}; unk.Beg = ctx.Begline + ctx.Lines.Beg; unk.End = ctx.Endline + ctx.Lines.Beg; errs.Add(unk); } if (!string.IsNullOrEmpty(extra)) { cit.Desc = extra; } StructParse(ctx2, tagDict); ctx.Endline = ctx2.Endline; if (!cit.Data && cit.Xref != null && cit.AnyText) { var unk = new UnkRec(); unk.Error = UnkRec.ErrorCode.RefSourText; // TODO { Error = "TEXT tag used for reference source citation" }; unk.Beg = ctx.Begline + ctx.Lines.Beg; unk.End = ctx2.Endline + ctx.Lines.Beg; errs.Add(unk); } if (cit.Xref == null && cit.Event != null) { var unk = new UnkRec(); unk.Error = UnkRec.ErrorCode.EmbSourEven; // TODO { Error = "EVEN tag used for embedded source citation" }; unk.Beg = ctx.Begline + ctx.Lines.Beg; unk.End = ctx2.Endline + ctx.Lines.Beg; errs.Add(unk); } if (cit.Xref == null && cit.Page != null) { var unk = new UnkRec(); unk.Error = UnkRec.ErrorCode.EmbSourPage; // TODO { Error = "PAGE tag used for embedded source citation" }; unk.Beg = ctx.Begline + ctx.Lines.Beg; unk.End = ctx.Endline + ctx.Lines.Beg; errs.Add(unk); } return(cit); }
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); }
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); }
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); }
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); }
private static void famcProc(StructParseContext context, int linedex, char level) { string xref; string extra; StructParser.parseXrefExtra(context.Remain, out xref, out extra); // No observed hit on this codepath //if (string.IsNullOrWhiteSpace(xref)) //{ // (context.Parent as IndiEvent).Famc = context.Remain; //} //else (context.Parent as IndiEvent).Famc = xref; }
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); }
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); }
// 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); }