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

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

                return(true);
            }
Esempio 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 BMLString.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 BMLString.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 BMLString.Ref("\r\n", false);
                        }
                    }
                }
            }
Esempio n. 4
0
            public bool Read(BinaryReader br, u32 depth)
            {
                bool valid = true;

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

                valid &= Flags.Read(br);

                // get attributes

                if (Flags.Attributes > 0)
                {
                    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();

                    break;

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

                    break;

                case 2:     // 010 -> last in sequence
                case 6:     // 110 -> continued sequence
                    End = new BMLString.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 BMLString.Ref(br, false);    // inner text or line diff
                    End2  = new BMLString.Ref(br, false);    // line ending

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

                    break;

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

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

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

                if (ele.HasAttributes)
                {
                    if (ele.Attributes.Count > 0xFF)
                    {
                        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 BMLString.Ref(BMLString.DecodeXml(xnode.Value), false);
                            End2  = new BMLString.Ref("\r\n", false);

                            break;

                        case XmlNodeType.Comment:
                            // Could be added as Inner/End2, but not required
                            break;

                        default:
                            break;
                        }
                    }
                }

                bool last_child = !HasElementSibling(ele);

                Fixup(last_child);

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