Example #1
0
 private static void  finish(System.String theEventName, System.Text.StringBuilder theSpec, System.Collections.IDictionary theMap)
 {
     if (theEventName != null)
     {
         RootRef root = parseGuide(theSpec.ToString());
         theMap[theEventName] = root;
     }
 }
Example #2
0
        private static RootRef parseGuide(System.String theSpec)
        {
            SupportClass.Tokenizer lines = new SupportClass.Tokenizer(theSpec, "\r", false);
            RootRef result = new RootRef();

            System.Collections.ArrayList ancestry = new System.Collections.ArrayList();
            ancestry.Add(result);
            System.Collections.IDictionary successors = new System.Collections.Hashtable();

            StructRef previous = result;

            while (lines.HasMoreTokens())
            {
                System.String          line    = lines.NextToken();
                SupportClass.Tokenizer parts   = new SupportClass.Tokenizer(line, "\t ", false);
                System.String          segName = parts.NextToken();
                System.String          path    = parts.HasMoreTokens()?parts.NextToken():"";
                parts = new SupportClass.Tokenizer(path, ":", false);
                path  = parts.HasMoreTokens()?parts.NextToken():null;

                int[] fields = getFieldList(parts.HasMoreTokens()?parts.NextToken():"");

                if (segName.Equals("}"))
                {
                    StructRef parent = (StructRef)SupportClass.StackSupport.Pop(ancestry);
                    if (parent.ChildName != null && parent.RelativePath.IndexOf('*') >= 0)
                    {
                        //repeating group
                        previous.setSuccessor(parent.ChildName, parent);
                    }
                }
                else
                {
                    bool      isSegment   = !(segName.Equals("{"));
                    StructRef ref_Renamed = new StructRef((StructRef)ancestry[ancestry.Count - 1], path, isSegment, fields);
                    if (isSegment)
                    {
                        previous.setSuccessor(segName, ref_Renamed);
                        if (path.IndexOf('*') >= 0)
                        {
                            ref_Renamed.setSuccessor(segName, ref_Renamed);
                        }
                        setGroupSuccessors(successors, segName);
                    }
                    else
                    {
                        successors[previous] = ref_Renamed;
                    }
                    if (!isSegment)
                    {
                        ancestry.Add(ref_Renamed);
                    }
                    previous = ref_Renamed;
                }
            }

            return(result);
        }
Example #3
0
        private BaseItem CreateItem(NodeItem item, byte[] buffer, int offset)
        {
            var      data = EndianUtilities.ToByteArray(buffer, (int)(offset + item.DataOffset), (int)item.DataSize);
            BaseItem result;

            switch (item.Key.ItemType)
            {
            case ItemType.ChunkItem:
                result = new ChunkItem(item.Key);
                break;

            case ItemType.DevItem:
                result = new DevItem(item.Key);
                break;

            case ItemType.RootItem:
                result = new RootItem(item.Key);
                break;

            case ItemType.InodeRef:
                result = new InodeRef(item.Key);
                break;

            case ItemType.InodeItem:
                result = new InodeItem(item.Key);
                break;

            case ItemType.DirItem:
                result = new DirItem(item.Key);
                break;

            case ItemType.DirIndex:
                result = new DirIndex(item.Key);
                break;

            case ItemType.ExtentData:
                result = new ExtentData(item.Key);
                break;

            case ItemType.RootRef:
                result = new RootRef(item.Key);
                break;

            case ItemType.RootBackref:
                result = new RootBackref(item.Key);
                break;

            case ItemType.XattrItem:
                result = new XattrItem(item.Key);
                break;

            case ItemType.OrphanItem:
                result = new OrphanItem(item.Key);
                break;

            default:
                throw new IOException($"Unsupported item type {item.Key.ItemType}");
            }
            result.ReadFrom(data, 0);
            return(result);
        }
		private static RootRef parseGuide(System.String theSpec)
		{
			SupportClass.Tokenizer lines = new SupportClass.Tokenizer(theSpec, "\r", false);
			RootRef result = new RootRef();
			System.Collections.ArrayList ancestry = new System.Collections.ArrayList();
			ancestry.Add(result);
			System.Collections.IDictionary successors = new System.Collections.Hashtable();
			
			StructRef previous = result;
			while (lines.HasMoreTokens())
			{
				System.String line = lines.NextToken();
				SupportClass.Tokenizer parts = new SupportClass.Tokenizer(line, "\t ", false);
				System.String segName = parts.NextToken();
				System.String path = parts.HasMoreTokens()?parts.NextToken():"";
				parts = new SupportClass.Tokenizer(path, ":", false);
				path = parts.HasMoreTokens()?parts.NextToken():null;
				
				int[] fields = getFieldList(parts.HasMoreTokens()?parts.NextToken():"");
				
				if (segName.Equals("}"))
				{
					StructRef parent = (StructRef) SupportClass.StackSupport.Pop(ancestry);
					if (parent.ChildName != null && parent.RelativePath.IndexOf('*') >= 0)
					{
						//repeating group
						previous.setSuccessor(parent.ChildName, parent);
					}
				}
				else
				{
					bool isSegment = !(segName.Equals("{"));
					StructRef ref_Renamed = new StructRef((StructRef) ancestry[ancestry.Count - 1], path, isSegment, fields);
					if (isSegment)
					{
						previous.setSuccessor(segName, ref_Renamed);
						if (path.IndexOf('*') >= 0)
							ref_Renamed.setSuccessor(segName, ref_Renamed);
						setGroupSuccessors(successors, segName);
					}
					else
					{
						successors[previous] = ref_Renamed;
					}
					if (!isSegment)
						ancestry.Add(ref_Renamed);
					previous = ref_Renamed;
				}
			}
			
			return result;
		}