// Parser public static CChangeDate Parse( CGedcom gedcom, int nLevel ) { CGedcomLine gedcomLine; // Temporary holders for class members. Saves constructing a class early. string sChangeDate = ""; string sTimeValue = ""; ArrayList alNoteStructures = new ArrayList(); CNoteStructure noteStructure = null; // There must be one of these, it defines the object. if ((gedcomLine = gedcom.GetLine(nLevel, "CHAN")) == null) { // Not one of us return null; } gedcom.IncrementLineIndex(1); bool bGotMandatoryItem = false; bool bParsingFinished; do { bParsingFinished = true; // There must be one of these, standard specifies {1:1} if( (gedcomLine = gedcom.GetLine(nLevel+1, "DATE")) != null ) { sChangeDate = gedcomLine.LineItem; gedcom.IncrementLineIndex(1); // There may be one of these, standard specifies {0:1} if( (gedcomLine = gedcom.GetLine(nLevel+2, "TIME")) != null ) { sTimeValue = gedcomLine.LineItem; gedcom.IncrementLineIndex(1); } bParsingFinished = false; bGotMandatoryItem = true; } else if( (noteStructure = CNoteStructure.Parse( gedcom, nLevel+1 )) != null ) { alNoteStructures.Add( noteStructure ); bParsingFinished = false; } else if( ( gedcomLine = gedcom.GetLine()).Level > nLevel ) { LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Warning, "Unknown tag :" ); LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Warning, gedcomLine.ToString() ); gedcom.IncrementLineIndex(1); bParsingFinished = false; } } while( !bParsingFinished ); if( !bGotMandatoryItem ) { LogFile.TheLogFile.WriteLine( LogFile.DT_GEDCOM, LogFile.EDebugLevel.Warning, "Change Date is missing mandatory field." ); return null; } // Parsing went ok. Construct a new object and return it. CChangeDate cd = new CChangeDate( gedcom ); cd.m_sChangeDate = sChangeDate; cd.m_sTimeValue = sTimeValue; cd.m_alNoteStructures = alNoteStructures; return cd; }
// Parser public bool ParseRecord( CGedcom gedcom, int level ) { CGedcomLine line; CUserReferenceNumber urn; CChangeDate cd; bool bParsingFinished; bool bGotSomething = false; do { bParsingFinished = true; if( (line = gedcom.GetLine( level+1, "RIN" )) != null ) { m_sAutomatedRecordId = line.LineItem; gedcom.IncrementLineIndex(1); bParsingFinished = false; bGotSomething = true; } else if( (urn = CUserReferenceNumber.Parse( gedcom, level+1 )) != null ) { m_alUserReferenceNumbers.Add( urn ); bParsingFinished = false; bGotSomething = true; } else if( (cd = CChangeDate.Parse( gedcom, level+1 )) != null ) { m_changeDate = cd; bParsingFinished = false; bGotSomething = true; } } while( !bParsingFinished ); return bGotSomething; }