Exemple #1
0
        private void CopyTo(TiXmlDocument target)
        {
            base.CopyTo(target);

            target.error           = error;
            target.errorId         = errorId;
            target.errorDesc       = errorDesc;
            target.tabsize         = tabsize;
            target.errorLocation   = errorLocation.Clone();
            target.useMicrosoftBOM = useMicrosoftBOM;

            TiXmlNode node = null;

            for (node = firstChild; node != null; node = node.NextSibling())
            {
                target.LinkEndChild(node.Clone());
            }
        }
Exemple #2
0
        /// <summary>
        /// Add a new node related to this. Adds a child past the LastChild.
        /// Returns a pointer to the new object or NULL if an error occurred.
        /// </summary>
        public TiXmlNode InsertEndChild(TiXmlNode addThis)
        {
            if (addThis.Type() == TiXmlNode.NodeType.DOCUMENT)
            {
                if (GetDocument() != null)
                {
                    GetDocument().SetError(ErrorType.TIXML_ERROR_DOCUMENT_TOP_ONLY, null, 0, null, TiXmlEncoding.TIXML_ENCODING_UNKNOWN);
                }
                return(null);
            }
            TiXmlNode node = addThis.Clone();

            if (node == null)
            {
                return(null);
            }
            return(LinkEndChild(node));
        }
Exemple #3
0
        protected void CopyTo(TiXmlElement target)
        {
            // superclass:
            base.CopyTo(target);

            // Element class:
            // Clone the attributes, then clone the children.
            TiXmlAttribute attribute = null;

            for (attribute = attributeSet.First(); attribute != null; attribute = attribute.Next())
            {
                target.SetAttribute(attribute.Name(), attribute.Value());
            }

            TiXmlNode node = null;

            for (node = firstChild; node != null; node = node.NextSibling())
            {
                target.LinkEndChild(node.Clone());
            }
        }
Exemple #4
0
        /// <summary>
        /// Replace a child of this node.
        /// Returns a pointer to the new object or NULL if an error occurred.
        /// </summary>
        public TiXmlNode ReplaceChild(TiXmlNode replaceThis, TiXmlNode withThis)
        {
            if (replaceThis.parent != this)
            {
                return(null);
            }

            TiXmlNode node = withThis.Clone();

            if (node == null)
            {
                return(null);
            }

            node.next = replaceThis.next;
            node.prev = replaceThis.prev;

            if (replaceThis.next != null)
            {
                replaceThis.next.prev = node;
            }
            else
            {
                lastChild = node;
            }

            if (replaceThis.prev != null)
            {
                replaceThis.prev.next = node;
            }
            else
            {
                firstChild = node;
            }

            //delete replaceThis;
            node.parent = this;
            return(node);
        }
Exemple #5
0
        /// <summary>
        /// Add a new node related to this. Adds a child after the specified child.
        /// Returns a pointer to the new object or NULL if an error occurred.
        /// </summary>
        public TiXmlNode InsertAfterChild(TiXmlNode afterThis, TiXmlNode addThis)
        {
            if (afterThis == null || afterThis.parent != this)
            {
                return(null);
            }
            if (addThis.Type() == TiXmlNode.NodeType.DOCUMENT)
            {
                if (GetDocument() != null)
                {
                    GetDocument().SetError(ErrorType.TIXML_ERROR_DOCUMENT_TOP_ONLY, null, 0, null, TiXmlEncoding.TIXML_ENCODING_UNKNOWN);
                }
                return(null);
            }

            TiXmlNode node = addThis.Clone();

            if (node == null)
            {
                return(null);
            }
            node.parent = this;

            node.prev = afterThis;
            node.next = afterThis.next;
            if (afterThis.next != null)
            {
                afterThis.next.prev = node;
            }
            else
            {
                //assert( lastChild == afterThis );
                lastChild = node;
            }
            afterThis.next = node;
            return(node);
        }
Exemple #6
0
        /// <summary>
        /// Add a new node related to this. Adds a child before the specified child.
        /// Returns a pointer to the new object or NULL if an error occurred.
        /// </summary>
        public TiXmlNode InsertBeforeChild(TiXmlNode beforeThis, TiXmlNode addThis)
        {
            if (beforeThis == null || beforeThis.parent != this)
            {
                return(null);
            }
            if (addThis.Type() == TiXmlNode.NodeType.DOCUMENT)
            {
                if (GetDocument() != null)
                {
                    GetDocument().SetError(ErrorType.TIXML_ERROR_DOCUMENT_TOP_ONLY, null, 0, null, TiXmlEncoding.TIXML_ENCODING_UNKNOWN);
                }
                return(null);
            }

            TiXmlNode node = addThis.Clone();

            if (node == null)
            {
                return(null);
            }
            node.parent = this;

            node.next = beforeThis;
            node.prev = beforeThis.prev;
            if (beforeThis.prev != null)
            {
                beforeThis.prev.next = node;
            }
            else
            {
                //assert( firstChild == beforeThis );
                firstChild = node;
            }
            beforeThis.prev = node;
            return(node);
        }