OBT::TiXmlText Class Reference

XML text. More...

#include <OBTtinyxml.h>

Inheritance diagram for OBT::TiXmlText:

Inheritance graph
[legend]
Collaboration diagram for OBT::TiXmlText:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TiXmlText (const char *initValue)
 Constructor for text element.
virtual ~TiXmlText ()
 TiXmlText (const std::string &initValue)
 Constructor.
 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.
 TiXmlText (const char *initValue)
 Constructor for text element.
virtual ~TiXmlText ()
 TiXmlText (const std::string &initValue)
 Constructor.
 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
virtual void StreamIn (std::istream *in, TIXML_STRING *tag)
virtual TiXmlNodeClone () const
 [internal use] Creates a new Element and returns it.
void CopyTo (TiXmlText *target) const
bool Blank () const
virtual void StreamIn (std::istream *in, TIXML_STRING *tag)

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 1211 of file OBTtinyxml.h.


Constructor & Destructor Documentation

OBT::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 1219 of file OBTtinyxml.h.

Referenced by Clone().

01219                                             : TiXmlNode (TiXmlNode::TEXT)
01220         {
01221                 setValue( initValue );
01222                 cdata = false;
01223         }

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

Definition at line 1224 of file OBTtinyxml.h.

01224 {}

OBT::TiXmlText::TiXmlText ( const std::string &  initValue  )  [inline]

Constructor.

Definition at line 1228 of file OBTtinyxml.h.

01228                                                 : TiXmlNode (TiXmlNode::TEXT)
01229         {
01230                 setValue( initValue );
01231                 cdata = false;
01232         }

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

Definition at line 1235 of file OBTtinyxml.h.

References CopyTo().

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

OBT::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 1218 of file tiny/OBTtinyxml.h.

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

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

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

Definition at line 1223 of file tiny/OBTtinyxml.h.

01223 {}

OBT::TiXmlText::TiXmlText ( const std::string &  initValue  )  [inline]

Constructor.

Definition at line 1227 of file tiny/OBTtinyxml.h.

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

01227                                                 : TiXmlNode (TiXmlNode::TEXT)
01228         {
01229                 SetValue( initValue );
01230                 cdata = false;
01231         }

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

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

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


Member Function Documentation

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

Definition at line 1236 of file OBTtinyxml.h.

References CopyTo().

01236 { base.CopyTo( this ); }

void OBT::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 OBT::TiXmlBase.

Definition at line 1337 of file OBTtinyxml.cpp.

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

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

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

Queries whether this represents text using a CDATA section.

Definition at line 1242 of file OBTtinyxml.h.

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

01242 { return cdata; }

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

Turns on or off a CDATA representation of text.

Definition at line 1244 of file OBTtinyxml.h.

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

01244 { cdata = _cdata; }

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

Implements OBT::TiXmlBase.

Definition at line 1500 of file OBTtinyxmlparser.cpp.

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

Referenced by OBT::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 }

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1248 of file OBTtinyxml.h.

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1249 of file OBTtinyxml.h.

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

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

Implements OBT::TiXmlNode.

Definition at line 1365 of file OBTtinyxml.cpp.

References OBT::TiXmlVisitor::Visit().

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

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

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

Implements OBT::TiXmlNode.

Definition at line 1371 of file OBTtinyxml.cpp.

References CopyTo(), and TiXmlText().

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

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

Definition at line 1358 of file OBTtinyxml.cpp.

References cdata, and OBT::TiXmlNode::CopyTo().

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

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

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

Definition at line 1633 of file OBTtinyxmlparser.cpp.

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

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

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

void OBT::TiXmlText::StreamIn ( std::istream *  in,
TIXML_STRING *  tag 
) [protected, virtual]

Implements OBT::TiXmlNode.

Definition at line 1469 of file OBTtinyxmlparser.cpp.

References cdata, OBT::TiXmlNode::GetDocument(), OBT::TiXmlDocument::SetError(), OBT::TIXML_ENCODING_UNKNOWN, and OBT::TiXmlBase::TIXML_ERROR_EMBEDDED_NULL.

Referenced by OBT::TiXmlElement::StreamIn().

01470 {
01471         while ( in->good() )
01472         {
01473                 int c = in->peek();     
01474                 if ( !cdata && (c == '<' ) ) 
01475                 {
01476                         return;
01477                 }
01478                 if ( c <= 0 )
01479                 {
01480                         TiXmlDocument* document = GetDocument();
01481                         if ( document )
01482                                 document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
01483                         return;
01484                 }
01485 
01486                 (*tag) += (char) c;
01487                 in->get();      // "commits" the peek made above
01488 
01489                 if ( cdata && c == '>' && tag->size() >= 3 ) {
01490                         size_t len = tag->size();
01491                         if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) {
01492                                 // terminator of cdata.
01493                                 return;
01494                         }
01495                 }    
01496         }
01497 }

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

Definition at line 1235 of file tiny/OBTtinyxml.h.

01235 { base.CopyTo( this ); }

virtual void OBT::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 OBT::TiXmlBase.

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

Queries whether this represents text using a CDATA section.

Definition at line 1241 of file tiny/OBTtinyxml.h.

References cdata.

01241 { return cdata; }

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

Turns on or off a CDATA representation of text.

Definition at line 1243 of file tiny/OBTtinyxml.h.

References cdata.

01243 { cdata = _cdata; }

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

Implements OBT::TiXmlBase.

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

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

Reimplemented from OBT::TiXmlNode.

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

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

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

Reimplemented from OBT::TiXmlNode.

Definition at line 1248 of file tiny/OBTtinyxml.h.

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

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

Implements OBT::TiXmlNode.

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

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

Implements OBT::TiXmlNode.

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

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

virtual void OBT::TiXmlText::StreamIn ( std::istream *  in,
TIXML_STRING *  tag 
) [protected, virtual]

Implements OBT::TiXmlNode.


Friends And Related Function Documentation

TiXmlElement [friend]

Reimplemented from OBT::TiXmlNode.

Definition at line 1213 of file OBTtinyxml.h.


Member Data Documentation

bool OBT::TiXmlText::cdata [private]

Definition at line 1267 of file OBTtinyxml.h.

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


Generated on Wed Oct 1 11:34:20 2008 for OBT by  doxygen 1.5.3