crashanalysercmd/PerfToolsSharedLibraries/Engine/SymBuildParsingLib/Parser/Framework/Document/SymParserDocument.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 using System;
       
    19 using System.Collections;
       
    20 using SymbianTree;
       
    21 
       
    22 namespace SymBuildParsingLib.Parser.Framework.Document
       
    23 {
       
    24 	public abstract class SymParserDocument : SymDocument
       
    25 	{
       
    26 		#region Constructors & destructor
       
    27 		public SymParserDocument( SymParserDocumentContext aContext )
       
    28 		{
       
    29 			aContext.Document = this;
       
    30 			iContextStack.Push( aContext );
       
    31 		}
       
    32 		#endregion
       
    33 
       
    34 		#region API
       
    35 		public void PushContext( SymParserDocumentContext aContext )
       
    36 		{
       
    37 			iContextStack.Push( aContext );
       
    38 		}
       
    39 
       
    40 		public SymParserDocumentContext PopContext()
       
    41 		{
       
    42 			SymParserDocumentContext top = (SymParserDocumentContext) iContextStack.Peek();
       
    43 			return PopContext( top );
       
    44 		}
       
    45 
       
    46 		public SymParserDocumentContext PopContext( SymParserDocumentContext aExpected )
       
    47 		{
       
    48 			// Can't pop off the last context
       
    49 			System.Diagnostics.Debug.Assert( iContextStack.Count > 1 );
       
    50 			SymParserDocumentContext top = (SymParserDocumentContext) iContextStack.Peek();
       
    51 			//
       
    52 			if	( aExpected.Equals( aExpected ) == false )
       
    53 			{
       
    54 				throw new ArgumentException( "Cannot pop context - expectations not met during pop operation" );
       
    55 			}
       
    56 			//
       
    57 			iContextStack.Pop();
       
    58 			return top;
       
    59 		}
       
    60 		#endregion
       
    61 
       
    62 		#region Properties
       
    63 		public SymParserDocumentContext Context
       
    64 		{
       
    65 			get
       
    66 			{
       
    67 				System.Diagnostics.Debug.Assert( iContextStack.Count > 0 );
       
    68 				SymParserDocumentContext ret = (SymParserDocumentContext) iContextStack.Peek();
       
    69 				return ret;
       
    70 			}
       
    71 		}
       
    72 		#endregion
       
    73 
       
    74 		#region Data members
       
    75 		private Stack iContextStack = new Stack();
       
    76 		#endregion
       
    77 	}
       
    78 }