diff -r 000000000000 -r 818e61de6cd1 crashanalysercmd/Libraries/File Formats/Plugins/DExcPlugin/Extractor/DExcExtractorList.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/crashanalysercmd/Libraries/File Formats/Plugins/DExcPlugin/Extractor/DExcExtractorList.cs Thu Feb 11 15:50:58 2010 +0200 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +using System; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections.Generic; + +namespace DExcPlugin.Extractor +{ + internal class DExcExtractorList : IEnumerable + { + #region Constructors + public DExcExtractorList( DExcExtractor.TState aState, DExcExtractorListType aType ) + { + iType = aType; + iState = aState; + } + #endregion + + #region API + public void AddExpression( DExcExtractorEntry aExpression ) + { + iEntries.Add( aExpression ); + } + + public void AddExpressions( params DExcExtractorEntry[] aExpressions ) + { + foreach ( DExcExtractorEntry exp in aExpressions ) + { + AddExpression( exp ); + } + } + + public virtual void Add( string aLine ) + { + iLines.Add( aLine ); + } + + public virtual bool Offer( string aLine, long aLineNumber, DExcExtractor aInterpreter ) + { + bool handled = false; + // + foreach ( DExcExtractorEntry interpreter in iEntries ) + { + handled = interpreter.Offer( aLine, aLineNumber, this, aInterpreter ); + if ( handled ) + { + break; + } + } + // + return handled; + } + #endregion + + #region Properties + public int Count + { + get { return iLines.Count; } + } + + public string[] Lines + { + get { return iLines.ToArray(); } + } + + public DExcExtractorListType Type + { + get { return iType; } + } + + public DExcExtractor.TState State + { + get { return iState; } + } + #endregion + + #region Internal methods + #endregion + + #region From System.Object + public override string ToString() + { + StringBuilder ret = new StringBuilder(); + // + foreach ( string line in iLines ) + { + ret.AppendLine( line ); + } + // + return ret.ToString(); + } + #endregion + + #region From IEnumerable + public IEnumerator GetEnumerator() + { + foreach ( string line in iLines ) + { + yield return line; + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + foreach ( string line in iLines ) + { + yield return line; + } + } + #endregion + + #region Data members + private readonly DExcExtractorListType iType; + private readonly DExcExtractor.TState iState; + private List iLines = new List(); + private List iEntries = new List(); + #endregion + } +}