crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianParserLib/Elements/ParserElementField.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 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 using System;
       
    18 using System.Collections.Generic;
       
    19 using System.Text;
       
    20 using System.Text.RegularExpressions;
       
    21 using System.Reflection;
       
    22 using SymbianParserLib.Enums;
       
    23 using SymbianParserLib.BaseStructures;
       
    24 using SymbianParserLib.Elements.SubFields;
       
    25 using SymbianParserLib.ValueStores;
       
    26 
       
    27 namespace SymbianParserLib.Elements
       
    28 {
       
    29     public class ParserField : ParserElementBaseWithValueStore
       
    30     {
       
    31         #region Constructors
       
    32         public ParserField()
       
    33             : this( string.Empty )
       
    34         {
       
    35         }
       
    36 
       
    37         public ParserField( string aName )
       
    38             : base( aName )
       
    39         {
       
    40             iFormatSpecifier = new ParserFieldFormatSpecifier( this );
       
    41             iFormatValue = new ParserFieldFormatValue( this );
       
    42         }
       
    43 
       
    44         internal ParserField( ParserField aField )
       
    45             : this( aField.Name )
       
    46         {
       
    47             iFormatSpecifier = new ParserFieldFormatSpecifier( this, aField.FormatSpecifier );
       
    48             iFormatValue = new ParserFieldFormatValue( this, aField.FormatValue );
       
    49         }
       
    50         #endregion
       
    51 
       
    52         #region API
       
    53         internal void ExtractValue( Group aGroup )
       
    54         {
       
    55             string fieldValue = aGroup.Value;
       
    56             TParserValueType fieldValueType = FormatSpecifier.ExpectedType;
       
    57             //
       
    58             switch ( fieldValueType )
       
    59             {
       
    60             case TParserValueType.EValueTypeString:
       
    61                 {
       
    62                     iFormatValue.SetValueString( fieldValue );
       
    63                     break;
       
    64                 }
       
    65             case TParserValueType.EValueTypeInt32:
       
    66                 {
       
    67                     int valInt32 = System.Convert.ToInt32( fieldValue );
       
    68                     iFormatValue.SetValueInt( valInt32 );
       
    69                     break;
       
    70                 }
       
    71             case TParserValueType.EValueTypeUint32:
       
    72                 {
       
    73                     int numberBase = FormatSpecifier.NumberBase;
       
    74                     uint valUint32 = System.Convert.ToUInt32( fieldValue, numberBase );
       
    75                     iFormatValue.SetValueUint( valUint32 );
       
    76                 }
       
    77                 break;
       
    78             case TParserValueType.EValueTypeUint64:
       
    79                 {
       
    80                     int numberBase = FormatSpecifier.NumberBase;
       
    81                     ulong valUint64 = System.Convert.ToUInt32( fieldValue, numberBase );
       
    82                     iFormatValue.SetValueUint64( valUint64 );
       
    83                 }
       
    84                 break;
       
    85             }
       
    86             //
       
    87             SetValue( iFormatSpecifier, iFormatValue );
       
    88             IsComplete = true;
       
    89         }
       
    90         #endregion
       
    91 
       
    92         #region Properties
       
    93         public ParserLine Line
       
    94         {
       
    95             get
       
    96             {
       
    97                 ParserLine ret = null;
       
    98                 //
       
    99                 if ( Parent != null && Parent is ParserLine )
       
   100                 {
       
   101                     ret = Parent as ParserLine;
       
   102                 }
       
   103                 //
       
   104                 return ret;
       
   105             }
       
   106         }
       
   107 
       
   108         internal ParserFieldFormatSpecifier FormatSpecifier
       
   109         {
       
   110             get { return iFormatSpecifier; }
       
   111         }
       
   112 
       
   113         internal ParserFieldFormatValue FormatValue
       
   114         {
       
   115             get { return iFormatValue; }
       
   116         }
       
   117         #endregion
       
   118 
       
   119         #region From ParserElementBase
       
   120         internal override ParserResponse Offer( ref string aLine )
       
   121         {
       
   122             throw new NotSupportedException();
       
   123         }
       
   124         #endregion
       
   125 
       
   126         #region From ParserElementBaseWithValueStore
       
   127         internal override void SetTargetProperty( object aPropertyObject, string aPropertyName, int aIndex )
       
   128         {
       
   129             iValueStore = new ValueStore();
       
   130             iValueStore.SetTargetProperty( aPropertyObject, aPropertyName );
       
   131         }
       
   132         #endregion
       
   133 
       
   134         #region Internal methods
       
   135         #endregion
       
   136 
       
   137         #region Internal constants
       
   138         #endregion
       
   139 
       
   140         #region From System.Object
       
   141         public override string ToString()
       
   142         {
       
   143             return base.ToString();
       
   144         }
       
   145         #endregion
       
   146 
       
   147         #region Data members
       
   148         private readonly ParserFieldFormatSpecifier iFormatSpecifier;
       
   149         private readonly ParserFieldFormatValue iFormatValue;
       
   150         #endregion
       
   151     }
       
   152 }