private void EventProc(ParseContext2 context) { var @event = FamilyEventParse.Parse(context, true); var indi = (context.Parent as IndiRecord); indi.Events.Add(@event as IndiEvent); }
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 }
public static StructParseContext Alloc(ParseContext2 ctx, StructCommon parent) { var spc = _pool.GetObject(); spc.Init(ctx, parent); return(spc); }
private void AttribProc(ParseContext2 context) { var @event = FamilyEventParse.Parse(context, true); var indi = (context.Parent as IndiRecord); indi.Attribs.Add((IndiEvent)@event); }
private void LdsOrdProc(ParseContext2 context) { LDSEvent evt = LDSEventParse.Parse(context); var indi = (context.Parent as IndiRecord); indi.LDSEvents.Add(evt); }
private void typeProc(ParseContext2 context) { // TODO 5.5: needs a warning var file = GetFile(context); file.Type = context.Remain; }
private void AssocProc(ParseContext2 context) { var res = IndiAssoParse.AssoParse(context); var own = (context.Parent as IndiRecord); own.Assocs.Add(res); }
private void GedcProc(ParseContext2 context) { var self = (context.Parent as HeadRecord); string val = seekSubRecord("VERS", context); self.GedVersion = val; }
private void PlacProc(ParseContext2 context) { var self = (context.Parent as HeadRecord); string val = seekSubRecord("FORM", context); self.PlaceFormat = val; }
private void fileProc(ParseContext2 context) { MediaFile file = new MediaFile(); file.FileRefn = context.Remain; (context.Parent as MediaRecord).Files.Add(file); }
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); } }
private void ldsSpouseSeal(ParseContext2 context) { LDSEvent evt = LDSEventParse.Parse(context); var fam = (context.Parent as FamRecord); fam.LDSEvents.Add(evt); }
//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; } } }
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; } }
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); }
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); }
private void dataProc(ParseContext2 context) { var data = SourceDataParse.DataParser(context); (context.Parent as SourceRecord).Data = data; // TODO validate multiple DATA records }
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); }
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 }
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); }
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); } }
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; }
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); }
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); }
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); }
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 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 }
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); }
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); } }