// Parser public static new CNoteStructureInLine Parse( CGedcom gedcom, int nLevel ) { CGedcomLine gedcomLine; // Temporary holders for class members. Saves constructing a class early. string sSubmitterText; string sAsid = ""; string sArea = ""; CSourceCitation sourceCitation = null; // There must be one of these, it defines the object. if ((gedcomLine = gedcom.GetLine(nLevel, "NOTE")) == null) { // Not one of us return null; } sSubmitterText = gedcomLine.LineItem; // Parsing is going well enough to say that we definitely have one of these, // so we can adjust the gedcom now. gedcom.IncrementLineIndex(1); ArrayList sourceCitations = new ArrayList(); bool bParsingFinished; do { bParsingFinished = true; // Test for underscore items first so that parser doesn't skip them later if( (gedcomLine = gedcom.GetLine(nLevel+1, "_ASID")) != null ) { sAsid = gedcomLine.LineItem; gedcom.IncrementLineIndex(1); bParsingFinished = false; } else if( (gedcomLine = gedcom.GetLine(nLevel+1, "_AREA")) != null ) { sArea = gedcomLine.LineItem; gedcom.IncrementLineIndex(1); bParsingFinished = false; } else if( (gedcomLine = gedcom.GetLine(nLevel+1, "CONC")) != null ) { sSubmitterText += gedcomLine.LineItem; gedcom.IncrementLineIndex(1); bParsingFinished = false; } // There may be one of these, standard specifies {0:M} else if( (gedcomLine = gedcom.GetLine(nLevel+1, "CONT")) != null ) { sSubmitterText += "\n" + gedcomLine.LineItem; gedcom.IncrementLineIndex(1); bParsingFinished = false; } else if( (sourceCitation = CSourceCitation.Parse( gedcom, nLevel+1 )) != null ) { sourceCitations.Add( sourceCitation ); 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 ); // Parsing went ok. Construct a new object and return it. CNoteStructureInLine ns = new CNoteStructureInLine( gedcom ); ns.m_sSubmitterText = sSubmitterText; ns.m_sAsid = sAsid; ns.m_sArea = sArea; ns.m_alSourceCitations = sourceCitations; return ns; }
// Copy constructor public override CNoteStructure CopyConstructor() { CNoteStructureInLine ns = new CNoteStructureInLine( Gedcom ); ns.m_sSubmitterText = m_sSubmitterText; ns.m_sAsid = m_sAsid; ns.m_sArea = m_sArea; return ns; }