Ejemplo n.º 1
0
            public bool ReadXML(string str_name, string str_value)
            {
                Name  = new AlienString.Ref(str_name, true);
                Value = new AlienString.Ref(AlienString.DecodeXml(str_value), true);

                return(true);
            }
Ejemplo n.º 2
0
            public bool Read(BinaryReader br)
            {
                Name  = new AlienString.Ref(br, true);
                Value = new AlienString.Ref(br, true);

                return(true);
            }
Ejemplo n.º 3
0
            public void Fixup(bool last_child)
            {
                Flags.RawInfo    = 0;
                Flags.Attributes = Convert.ToByte(Attributes.Count & 0xFF);
                Flags.Children   = Convert.ToUInt16(Nodes.Count & 0xFFFF);

                if (Text.value == "?xml")
                {
                    if (Flags.Attributes == 0)
                    {
                        // just offsets to child

                        Flags.unknown_1        = false;
                        Flags.unknown_2        = false;
                        Flags.ContinueSequence = false;

                        // raw flags are now 000
                    }
                    else
                    {
                        if (End == null)
                        {
                            End = new AlienString.Ref("\r\n", false);
                        }

                        // declaration kept - child mandatory
                        Flags.unknown_1        = true;
                        Flags.unknown_2        = false;
                        Flags.ContinueSequence = false;

                        // raw flags are now 001
                    }
                }
                else
                {
                    if (Inner != null)
                    {
                        // has inner kept; child optional
                        Flags.unknown_1        = true;
                        Flags.unknown_2        = true;
                        Flags.ContinueSequence = !last_child;

                        // raw flags are now either 011 or 111

                        if (End2 == null)
                        {
                            End2 = new AlienString.Ref("\r\n", false);
                        }
                    }
                    else
                    {
                        // end spacing, child optional
                        Flags.unknown_1        = false;
                        Flags.unknown_2        = true;
                        Flags.ContinueSequence = !last_child;

                        // raw flags are now either 010 or 110

                        if (End == null)
                        {
                            End = new AlienString.Ref("\r\n", false);
                        }
                    }
                }
            }
Ejemplo n.º 4
0
            public bool Read(BinaryReader br, u32 depth)
            {
                bool valid = true;

                Depth = depth;
                Text  = new AlienString.Ref(br, true);

                valid &= Flags.Read(br);

                // get attributes

                if (Flags.Attributes > 0)
                {
#if DEBUG
                    if (Flags.Attributes > 100)
                    {
                        //Console.WriteLine("Possible large number of attributes -> {0} (node={1})", Flags.Attributes, Text);
                    }
#endif
                    for (u32 attribs = 0; attribs < (u32)Flags.Attributes; attribs++)
                    {
                        Attribute a = new Attribute();
                        valid &= a.Read(br);

                        if (!valid)
                        {
                            return(false);
                        }

                        Attributes.Add(a);
                    }
                }

                switch (Flags.RawInfo)
                {
                case 0:     // 000

                    Offset = br.ReadUInt32();

#if DEBUG
                    if (Offset != 28)
                    {
                        // Console.WriteLine("Interesting offset {0}", Offset);
                    }
#endif

                    break;

                case 1:     // 001
                    End    = new AlienString.Ref(br, false);
                    Offset = br.ReadUInt32();

                    break;

                case 2:     // 010 -> last in sequence
                case 6:     // 110 -> continued sequence
                    End = new AlienString.Ref(br, false);

                    if (Flags.Children > 0)
                    {
                        Offset = br.ReadUInt32();
                    }

                    break;

                case 3:     // 011 -> last in sequence
                case 7:     // 111 -> continued sequence

                    // note: inner text is stored in the second pool

                    Inner = new AlienString.Ref(br, false);    // inner text or line diff
                    End2  = new AlienString.Ref(br, false);    // line ending

                    if (Flags.Children > 0)
                    {
                        Offset = br.ReadUInt32();
                    }

                    break;

                default:
                    // flags may need sorting out
                    break;
                }

                return(valid);
            }
Ejemplo n.º 5
0
            public bool ReadXML(XmlElement ele, u32 depth)
            {
                bool valid = true;

                Depth = depth;
                Text  = new AlienString.Ref(ele.Name, true);

                if (ele.HasAttributes)
                {
                    if (ele.Attributes.Count > 0xFF)
                    {
                        //Console.WriteLine("Too many attributes for {0}", Text.value);
                        valid = false;
                        return(valid);
                    }

                    foreach (XmlAttribute attr in ele.Attributes)
                    {
                        Attribute a = new Attribute();
                        a.ReadXML(attr.Name, attr.Value);
                        Attributes.Add(a);
                    }
                }

                if (ele.HasChildNodes)
                {
                    // inner text is treated as a special text node, so it has children.. (YIKES)

                    foreach (XmlNode xnode in ele.ChildNodes)
                    {
                        // special parser requirements

                        switch (xnode.NodeType)
                        {
                        case XmlNodeType.Element:

                            XmlElement child = (xnode as XmlElement);

                            Node nchild = new Node();

                            valid &= nchild.ReadXML(child, depth + 1);

                            if (valid)
                            {
                                Nodes.Add(nchild);
                            }

                            break;

                        case XmlNodeType.Text:

                            Inner = new AlienString.Ref(AlienString.DecodeXml(xnode.Value), false);
                            End2  = new AlienString.Ref("\r\n", false);

                            break;

                        case XmlNodeType.Comment:

                            // Could be added as Inner/End2, but not required
                            //Console.WriteLine("Found XML comment - skipping it");

                            break;

                        default:
                            // Console.WriteLine("XmlNodeType not handled - skipping it");
                            break;
                        }
                    }
                }

                bool last_child = !HasElementSibling(ele);

                Fixup(last_child);

                return(valid);
            }
Ejemplo n.º 6
0
 public void SetDeclaration()
 {
     Text           = new AlienString.Ref("?xml", true);
     Flags.Children = 0;
 }