xmlTiny::TiXmlText Class Reference

XML text. More...

#include <OBTtinyxml.h>

Inheritance diagram for xmlTiny::TiXmlText:
[legend]
Collaboration diagram for xmlTiny::TiXmlText:
[legend]

List of all members.

Public Member Functions

 TiXmlText (const char *initValue)
 Constructor for text element.
virtual ~TiXmlText ()
 TiXmlText (const TiXmlText &copy)
void operator= (const TiXmlText &base)
virtual void Print (FILE *cfile, int depth) const
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
bool CDATA () const
 Queries whether this represents text using a CDATA section.
void SetCDATA (bool _cdata)
 Turns on or off a CDATA representation of text.
virtual const char * Parse (const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual const TiXmlTextToText () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlTextToText ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *content) const
 Walk the XML tree visiting this node and all of its children.

Protected Member Functions

virtual TiXmlNodeClone () const
 [internal use] Creates a new Element and returns it.
void CopyTo (TiXmlText *target) const
bool Blank () const

Private Attributes

bool cdata

Friends

class TiXmlElement

Detailed Description

XML text.

A text node can have 2 ways to output the next. "normal" output and CDATA. It will default to the mode it was parsed from the XML file and you generally want to leave it alone, but you can change the output mode with SetCDATA() and query it with CDATA().

Definition at line 1209 of file tiny/tmp/OBTtinyxml.h.


Constructor & Destructor Documentation

xmlTiny::TiXmlText::TiXmlText ( const char *  initValue  )  [inline]

Constructor for text element.

By default, it is treated as normal, encoded text. If you want it be output as a CDATA text element, set the parameter _cdata to 'true'

Definition at line 1217 of file tiny/tmp/OBTtinyxml.h.

References cdata, and xmlTiny::TiXmlNode::SetValue().

Referenced by Clone().

01217                                             : TiXmlNode (TiXmlNode::TEXT)
01218         {
01219                 SetValue( initValue );
01220                 cdata = false;
01221         }

virtual xmlTiny::TiXmlText::~TiXmlText (  )  [inline, virtual]

Definition at line 1222 of file tiny/tmp/OBTtinyxml.h.

01222 {}

xmlTiny::TiXmlText::TiXmlText ( const TiXmlText copy  )  [inline]

Definition at line 1233 of file tiny/tmp/OBTtinyxml.h.

References CopyTo().

01233 : TiXmlNode( TiXmlNode::TEXT )  { copy.CopyTo( this ); }


Member Function Documentation

bool xmlTiny::TiXmlText::Accept ( TiXmlVisitor content  )  const [virtual]

Walk the XML tree visiting this node and all of its children.

Implements xmlTiny::TiXmlNode.

Definition at line 1366 of file tiny/tmp/OBTtinyxml.cpp.

References xmlTiny::TiXmlVisitor::Visit().

01367 {
01368         return visitor->Visit( *this );
01369 }

bool xmlTiny::TiXmlText::Blank (  )  const [protected]

Definition at line 1633 of file tiny/tmp/OBTtinyxmlparser.cpp.

References xmlTiny::TiXmlBase::IsWhiteSpace(), and xmlTiny::TiXmlNode::value.

Referenced by xmlTiny::TiXmlElement::ReadValue().

01634 {
01635         for ( unsigned i=0; i<value.length(); i++ )
01636                 if ( !IsWhiteSpace( value[i] ) )
01637                         return false;
01638         return true;
01639 }

bool xmlTiny::TiXmlText::CDATA (  )  const [inline]

Queries whether this represents text using a CDATA section.

Definition at line 1240 of file tiny/tmp/OBTtinyxml.h.

References cdata.

Referenced by xmlTiny::TiXmlPrinter::Visit(), and xmlTiny::TiXmlPrinter::VisitEnter().

01240 { return cdata; }

TiXmlNode * xmlTiny::TiXmlText::Clone (  )  const [protected, virtual]

[internal use] Creates a new Element and returns it.

Implements xmlTiny::TiXmlNode.

Definition at line 1372 of file tiny/tmp/OBTtinyxml.cpp.

References CopyTo(), and TiXmlText().

01373 {       
01374         TiXmlText* clone = 0;
01375         clone = new TiXmlText( "" );
01376 
01377         if ( !clone )
01378                 return 0;
01379 
01380         CopyTo( clone );
01381         return clone;
01382 }

void xmlTiny::TiXmlText::CopyTo ( TiXmlText target  )  const [protected]

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1359 of file tiny/tmp/OBTtinyxml.cpp.

References cdata.

Referenced by Clone(), operator=(), and TiXmlText().

01360 {
01361         TiXmlNode::CopyTo( target );
01362         target->cdata = cdata;
01363 }

void xmlTiny::TiXmlText::operator= ( const TiXmlText base  )  [inline]

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1234 of file tiny/tmp/OBTtinyxml.h.

References CopyTo().

01234 { base.CopyTo( this ); }

const char * xmlTiny::TiXmlText::Parse ( const char *  p,
TiXmlParsingData data,
TiXmlEncoding  encoding 
) [virtual]

Implements xmlTiny::TiXmlBase.

Definition at line 1500 of file tiny/tmp/OBTtinyxmlparser.cpp.

References cdata, xmlTiny::TiXmlParsingData::Cursor(), xmlTiny::TiXmlNode::GetDocument(), xmlTiny::TiXmlBase::location, xmlTiny::TiXmlBase::ReadText(), xmlTiny::TiXmlDocument::SetError(), xmlTiny::TiXmlParsingData::Stamp(), xmlTiny::TiXmlBase::StringEqual(), xmlTiny::TiXmlBase::TIXML_ERROR_PARSING_CDATA, TIXML_STRING, and xmlTiny::TiXmlNode::value.

Referenced by xmlTiny::TiXmlElement::ReadValue().

01501 {
01502         value = "";
01503         TiXmlDocument* document = GetDocument();
01504 
01505         if ( data )
01506         {
01507                 data->Stamp( p, encoding );
01508                 location = data->Cursor();
01509         }
01510 
01511         const char* const startTag = "<![CDATA[";
01512         const char* const endTag   = "]]>";
01513 
01514         if ( cdata || StringEqual( p, startTag, false, encoding ) )
01515         {
01516                 cdata = true;
01517 
01518                 if ( !StringEqual( p, startTag, false, encoding ) )
01519                 {
01520                         document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding );
01521                         return 0;
01522                 }
01523                 p += strlen( startTag );
01524 
01525                 // Keep all the white space, ignore the encoding, etc.
01526                 while (    p && *p
01527                                 && !StringEqual( p, endTag, false, encoding )
01528                           )
01529                 {
01530                         value += *p;
01531                         ++p;
01532                 }
01533 
01534                 TIXML_STRING dummy; 
01535                 p = ReadText( p, &dummy, false, endTag, false, encoding );
01536                 return p;
01537         }
01538         else
01539         {
01540                 bool ignoreWhite = true;
01541 
01542                 const char* end = "<";
01543                 p = ReadText( p, &value, ignoreWhite, end, false, encoding );
01544                 if ( p )
01545                         return p-1;     // don't truncate the '<'
01546                 return 0;
01547         }
01548 }

void xmlTiny::TiXmlText::Print ( FILE *  cfile,
int  depth 
) const [virtual]

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implements xmlTiny::TiXmlBase.

Definition at line 1338 of file tiny/tmp/OBTtinyxml.cpp.

References cdata, xmlTiny::TiXmlBase::EncodeString(), TIXML_STRING, and xmlTiny::TiXmlNode::value.

01339 {
01340         assert( cfile );
01341         if ( cdata )
01342         {
01343                 int i;
01344                 fprintf( cfile, "\n" );
01345                 for ( i=0; i<depth; i++ ) {
01346                         fprintf( cfile, "    " );
01347                 }
01348                 fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() );    // unformatted output
01349         }
01350         else
01351         {
01352                 TIXML_STRING buffer;
01353                 EncodeString( value, &buffer );
01354                 fprintf( cfile, "%s", buffer.c_str() );
01355         }
01356 }

void xmlTiny::TiXmlText::SetCDATA ( bool  _cdata  )  [inline]

Turns on or off a CDATA representation of text.

Definition at line 1242 of file tiny/tmp/OBTtinyxml.h.

References cdata.

Referenced by xmlTiny::TiXmlNode::Identify().

01242 { cdata = _cdata; }

virtual TiXmlText* xmlTiny::TiXmlText::ToText (  )  [inline, virtual]

Cast to a more defined type. Will return null not of the requested type.

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1247 of file tiny/tmp/OBTtinyxml.h.

virtual const TiXmlText* xmlTiny::TiXmlText::ToText (  )  const [inline, virtual]

Cast to a more defined type. Will return null not of the requested type.

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1246 of file tiny/tmp/OBTtinyxml.h.


Friends And Related Function Documentation

friend class TiXmlElement [friend]

Reimplemented from xmlTiny::TiXmlNode.

Definition at line 1211 of file tiny/tmp/OBTtinyxml.h.


Member Data Documentation

bool xmlTiny::TiXmlText::cdata [private]

Definition at line 1265 of file tiny/tmp/OBTtinyxml.h.

Referenced by CDATA(), CopyTo(), Parse(), Print(), SetCDATA(), and TiXmlText().


Generated on 1 Jan 2010 for OBT by  doxygen 1.6.1