Exemplo n.º 1
0
 public override bool Visit(TiXmlComment comment)
 {
     DoIndent();
     buffer.Append("<!--");
     buffer.Append(comment.Value());
     buffer.Append("-.");
     DoLineBreak();
     return(true);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a copy of this Comment.
        /// </summary>
        public override TiXmlNode Clone()
        {
            TiXmlComment clone = new TiXmlComment();

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

            CopyTo(clone);
            return(clone);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Figure out what is at *p, and parse it. Returns null if it is not an xml node.
        /// </summary>
        protected TiXmlNode Identify(string p, int index, int encoding)
        {
            TiXmlNode returnNode = null;

            index = SkipWhiteSpace(p, index, encoding);
            if (p == null || index < 0 || index >= p.Length || p[index] != '<')
            {
                return(null);
            }

            TiXmlDocument doc = GetDocument();

            index = SkipWhiteSpace(p, index, encoding);

            if (index < 0 || index >= p.Length)
            {
                return(null);
            }

            // What is this thing?
            // - Elements start with a letter or underscore, but xml is reserved.
            // - Comments: <!--
            // - Decleration: <?xml
            // - Everthing else is unknown to tinyxml.
            //

            const string xmlHeader     = "<?xml";
            const string commentHeader = "<!--";
            const string dtdHeader     = "<!";
            const string cdataHeader   = "<![CDATA[";

            if (StringEqual(p, index, xmlHeader, true, encoding))
            {
#if UNUSED
                TIXML_LOG("XML parsing Declaration\n");
#endif
                returnNode = new TiXmlDeclaration();
            }
            else if (StringEqual(p, index, commentHeader, false, encoding))
            {
#if UNUSED
                TIXML_LOG("XML parsing Comment\n");
#endif
                returnNode = new TiXmlComment();
            }
            else if (StringEqual(p, index, cdataHeader, false, encoding))
            {
#if UNUSED
                TIXML_LOG("XML parsing CDATA\n");
#endif
                TiXmlText text = new TiXmlText("");
                text.SetCDATA(true);
                returnNode = text;
            }
            else if (StringEqual(p, index, dtdHeader, false, encoding))
            {
#if UNUSED
                TIXML_LOG("XML parsing Unknown(1)\n");
#endif
                returnNode = new TiXmlUnknown();
            }
            else if (IsAlpha(p[index + 1], encoding) || p[index + 1] == '_')
            {
#if UNUSED
                TIXML_LOG("XML parsing Element\n");
#endif
                returnNode = new TiXmlElement("");
            }
            else
            {
#if UNUSED
                TIXML_LOG("XML parsing Unknown(2)\n");
#endif
                returnNode = new TiXmlUnknown();
            }

            if (returnNode != null)
            {
                // Set the parent, so it can report errors
                returnNode.parent = this;
            }
            else
            {
                if (doc != null)
                {
                    doc.SetError(ErrorType.TIXML_ERROR_OUT_OF_MEMORY, null, 0, null, TiXmlEncoding.TIXML_ENCODING_UNKNOWN);
                }
            }
            return(returnNode);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Visit a comment node
 /// </summary>
 public virtual bool Visit(TiXmlComment comment)
 {
     return(true);
 }
Exemplo n.º 5
0
 public TiXmlComment(TiXmlComment copy) : base(TiXmlNode.NodeType.COMMENT)
 {
     copy.CopyTo(this);
 }
Exemplo n.º 6
0
 protected void CopyTo(TiXmlComment target)
 {
     base.CopyTo(target);
 }