• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/xml/XmlText.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _xmltext_h
00018 #define _xmltext_h
00019 
00020 #include <spl/Debug.h>
00021 #include <spl/text/StringBuffer.h>
00022 #include <spl/xml/XmlNode.h>
00023 
00032 class XmlText : public XmlNode
00033 {
00034 protected:
00035         friend class XmlDocument;
00036         friend class XmlElement;
00037         friend class TinyXmlParser;
00038         friend class XmlNode;
00039         friend void _TestTinyXml();
00040 
00041         bool m_cdata;
00042         
00044         virtual XmlNodePtr Clone() const;
00045         void CopyTo( XmlText& target ) const;
00046 
00047         virtual const char* _Parse( const char* p, XmlParsingData* data, XmlEncoding encoding );
00048 
00053         XmlText (const String& initValue );
00054 
00055 public:
00056         XmlText( const XmlText& copy );
00057         virtual ~XmlText();
00058         
00059         inline void operator =( const XmlText& base )
00060         { 
00061                 base.CopyTo( *this ); 
00062         }
00063 
00064         virtual String Name() const;
00065                         
00067         inline bool CDATA() const                               
00068         { 
00069                 return m_cdata; 
00070         }
00071         
00073         inline void SetCDATA( bool _cdata )
00074         { 
00075                 m_cdata = _cdata; 
00076         }
00077 
00078         virtual XmlTextPtr ToText() const ; 
00079         
00080         bool IsBlank() const;   // returns true if all white space and new lines
00081         
00082         virtual StringPtr ToString() const;
00083         virtual void WriteTo(TextWriter& writer) const;
00084 
00085         static XmlTextPtr CreateText(const String& val);
00086 
00087         inline static void XmlEncode(const String& str, StringBuffer& outString)
00088         {
00089                 extern void _XmlEncodeString( const String& str, StringBuffer& outString );
00090                 _XmlEncodeString(str, outString);
00091         }
00092 };
00093 
00094 REGISTER_TYPEOF( 544, XmlText );
00095 
00098 #endif