Example #1
0
        public IEnumerable <Stack <EbmlStackItem> > GetNodeTraces(string elementName)
        {
            System.Diagnostics.Debug.Assert(this.Element.Type == EbmlType.Master);

            var stack = new Stack <EbmlStackItem>();

            for (EbmlNode current = this;;)
            {
                var top = new EbmlStackItem((EbmlNodeMaster)current);
                stack.Push(top);

                for (;;)
                {
                    if (top.Index >= top.Node.nodes.Count)
                    {
                        if (stack.Count == 1)
                        {
                            yield break;
                        }
                        else
                        {
                            stack.Pop();
                            top = stack.Peek();
                            continue;
                        }
                    }

                    current = top.Node.nodes[top.Index];
                    if (current.Element.Name == elementName)
                    {
                        yield return(stack);
                    }

                    ++top.Index;
                    if (current.Element.Type == EbmlType.Master)
                    {
                        break;
                    }
                }
            }
        }
Example #2
0
        public EbmlNode Seek(ulong sig32)
        {
            System.Diagnostics.Debug.Assert(this.Element.Type == EbmlType.Master);

            var stack = new Stack <EbmlStackItem>();

            for (EbmlNode current = this;;)
            {
                var top = new EbmlStackItem((EbmlNodeMaster)current);

                for (;;)
                {
                    if (top.Index >= top.Node.nodes.Count)
                    {
                        if (stack.Count == 0)
                        {
                            return(null);
                        }
                        else
                        {
                            top = stack.Pop();
                            continue;
                        }
                    }

                    current = top.Node.nodes[top.Index];
                    if (current.Element.Sig32 == sig32)
                    {
                        return(current);
                    }

                    ++top.Index;
                    if (current.Element.Type == EbmlType.Master)
                    {
                        stack.Push(top);
                        break;
                    }
                }
            }
        }
Example #3
0
 public void AddNode(EbmlNode node)
 {
     nodes.Add(node);
 }