71 namespace RTT {
namespace marsh {
86 while( i<(
int)str.length() )
88 unsigned char c = (
unsigned char) str[i];
91 && i < ( (
int)str.length() - 2 )
105 while ( i<(
int)str.length()-1 )
107 outString->append( str.c_str() + i, 1 );
115 outString->append(
entity[0].str,
entity[0].strLength );
120 outString->append(
entity[1].str,
entity[1].strLength );
125 outString->append(
entity[2].str,
entity[2].strLength );
128 else if ( c ==
'\"' )
130 outString->append(
entity[3].str,
entity[3].strLength );
133 else if ( c ==
'\'' )
135 outString->append(
entity[4].str,
entity[4].strLength );
144 #if defined(TIXML_SNPRINTF) 145 TIXML_SNPRINTF( buf,
sizeof(buf),
"&#x%02X;", (
unsigned) ( c & 0xff ) );
147 sprintf( buf,
"&#x%02X;", (
unsigned) ( c & 0xff ) );
152 outString->append( buf, (
int)strlen( buf ) );
159 *outString += (char) c;
169 buffer =
new char[ str.length()+1 ];
172 strcpy( buffer, str.c_str() );
265 if ( !beforeThis || beforeThis->
parent !=
this )
273 node->
next = beforeThis;
275 if ( beforeThis->
prev )
284 beforeThis->
prev = node;
291 if ( !afterThis || afterThis->
parent !=
this )
299 node->
prev = afterThis;
301 if ( afterThis->
next )
310 afterThis->
next = node;
317 if ( replaceThis->
parent !=
this )
327 if ( replaceThis->
next )
332 if ( replaceThis->
prev )
345 if ( removeThis->
parent !=
this )
351 if ( removeThis->
next )
356 if ( removeThis->
prev )
370 if ( strcmp( node->
Value(), _value ) == 0 )
382 if ( strcmp( node->
Value(), _value ) == 0 )
394 if ( strcmp( node->
Value(), _value ) == 0 )
405 if ( strcmp( node->
Value(), _value ) == 0 )
419 assert( previous->
parent ==
this );
432 assert( previous->
parent ==
this );
445 assert( previous->
parent ==
this );
458 assert( previous->
parent ==
this );
466 for ( node =
next; node; node = node->
next )
468 if ( strcmp( node->
Value(), _value ) == 0 )
477 for ( node =
next; node; node = node->
next )
479 if ( strcmp( node->
Value(), _value ) == 0 )
488 for ( node =
prev; node; node = node->
prev )
490 if ( strcmp( node->
Value(), _value ) == 0 )
499 for ( node =
prev; node; node = node->
prev )
501 if ( strcmp( node->
Value(), _value ) == 0 )
513 attributeSet.Remove( node );
635 for( node =
this; node; node = node->
parent )
647 for( node =
this; node; node = node->
parent )
712 return node->
Value();
771 #if defined(TIXML_SNPRINTF) 772 TIXML_SNPRINTF( buf,
sizeof(buf),
"%d", val );
774 sprintf( buf,
"%d", val );
783 std::ostringstream oss;
793 #if defined(TIXML_SNPRINTF) 794 TIXML_SNPRINTF( buf,
sizeof(buf),
"%f", val );
796 sprintf( buf,
"%f", val );
854 for ( i=0; i<depth; i++ )
856 fprintf( cfile,
" " );
859 fprintf( cfile,
"<%s",
value.c_str() );
864 fprintf( cfile,
" " );
865 attrib->Print( cfile, depth );
875 fprintf( cfile,
" />" );
879 fprintf( cfile,
">" );
881 fprintf( cfile,
"</%s>",
value.c_str() );
885 fprintf( cfile,
">" );
891 fprintf( cfile,
"\n" );
893 node->
Print( cfile, depth+1 );
895 fprintf( cfile,
"\n" );
896 for( i=0; i<depth; ++i )
897 fprintf( cfile,
" " );
898 fprintf( cfile,
"</%s>",
value.c_str() );
904 (*stream) <<
"<" <<
value;
924 (*stream) <<
"</" << value <<
">";
943 attribute = attribute->
Next() )
973 return childText->
Value();
991 value = documentName;
1001 value = documentName;
1056 FILE* file = fopen(
value.c_str (),
"rb" );
1060 bool result =
LoadFile( file, encoding );
1085 fseek( file, 0, SEEK_END );
1086 length = ftell( file );
1087 fseek( file, 0, SEEK_SET );
1099 data.reserve( length );
1122 char* buf =
new char[ length+1 ];
1125 if ( fread( buf, length, 1, file ) != 1 ) {
1130 const char* lastPos = buf;
1131 const char* p = buf;
1135 assert( p < (buf+length) );
1139 data.append( lastPos, (p-lastPos+1) );
1142 assert( p <= (buf+length) );
1144 else if ( *p == 0xd ) {
1147 if ( (p-lastPos) > 0 ) {
1148 data.append( lastPos, p-lastPos );
1152 if ( *(p+1) == 0xa ) {
1156 assert( p <= (buf+length) );
1162 assert( p <= (buf+length) );
1171 data.append( lastPos, p-lastPos );
1176 Parse( data.c_str(), 0, encoding );
1188 FILE* fp = fopen( filename,
"w" );
1207 fputc( TIXML_UTF_LEAD_0, fp );
1208 fputc( TIXML_UTF_LEAD_1, fp );
1209 fputc( TIXML_UTF_LEAD_2, fp );
1247 node->
Print( cfile, depth );
1248 fprintf( cfile,
"\n" );
1311 if (
value.find (
'\"') == TIXML_STRING::npos)
1312 fprintf (cfile,
"%s=\"%s\"", n.c_str(), v.c_str() );
1314 fprintf (cfile,
"%s='%s'", n.c_str(), v.c_str() );
1320 if (
value.find(
'\"' ) != TIXML_STRING::npos)
1323 (*stream) <<
"=" <<
"'";
1330 (*stream) <<
"=" <<
"\"";
1338 if ( sscanf(
value.c_str(),
"%d", ival ) == 1 )
1345 if ( sscanf(
value.c_str(),
"%lf", dval ) == 1 )
1353 #if defined(TIXML_SNPRINTF) 1354 TIXML_SNPRINTF(buf,
sizeof(buf),
"%d", _value);
1356 sprintf (buf,
"%d", _value);
1364 #if defined(TIXML_SNPRINTF) 1365 TIXML_SNPRINTF( buf,
sizeof(buf),
"%lf", _value);
1367 sprintf (buf,
"%lf", _value);
1374 return atoi (
value.c_str ());
1379 return atof (
value.c_str ());
1398 for (
int i=0; i<depth; i++ )
1400 fputs(
" ", cfile );
1402 fprintf( cfile,
"<!--%s-->",
value.c_str() );
1407 (*stream) <<
"<!--";
1437 fprintf( cfile,
"\n" );
1438 for ( i=0; i<depth; i++ ) {
1439 fprintf( cfile,
" " );
1441 fprintf( cfile,
"<![CDATA[" );
1442 fprintf( cfile,
"%s",
value.c_str() );
1443 fprintf( cfile,
"]]>\n" );
1449 fprintf( cfile,
"%s", buffer.c_str() );
1458 (*stream) <<
"<![CDATA[" <<
value <<
"]]>";
1470 target->
cdata = cdata;
1488 const char * _encoding,
1489 const char * _standalone )
1498 #ifdef TIXML_USE_STL 1500 const std::string& _encoding,
1501 const std::string& _standalone )
1527 fprintf (cfile,
"<?xml ");
1530 fprintf (cfile,
"version=\"%s\" ",
version.c_str ());
1532 fprintf (cfile,
"encoding=\"%s\" ",
encoding.c_str ());
1534 fprintf (cfile,
"standalone=\"%s\" ",
standalone.c_str ());
1535 fprintf (cfile,
"?>");
1540 (*stream) <<
"<?xml ";
1544 (*stream) <<
"version=\"";
1550 (*stream) <<
"encoding=\"";
1552 (*stream ) <<
"\" ";
1556 (*stream) <<
"standalone=\"";
1588 for (
int i=0; i<depth; i++ )
1589 fprintf( cfile,
" " );
1590 fprintf( cfile,
"<%s>",
value.c_str() );
1596 (*stream) <<
"<" <<
value <<
">";
1620 sentinel.next = &sentinel;
1621 sentinel.prev = &sentinel;
1627 assert( sentinel.next == &sentinel );
1628 assert( sentinel.prev == &sentinel );
1636 addMe->
next = &sentinel;
1640 sentinel.
prev = addMe;
1647 for( node = sentinel.
next; node != &sentinel; node = node->
next )
1649 if ( node == removeMe )
1665 for( node = sentinel.
next; node != &sentinel; node = node->
next )
1667 if ( node->
name == name )
1677 for( node = sentinel.
next; node != &sentinel; node = node->
next )
1679 if ( node->
name == name )
1685 #ifdef TIXML_USE_STL 1689 tag.reserve( 8 * 1000 );
1690 base.StreamIn( &in, &tag );
1705 #ifdef TIXML_USE_STL 1708 std::ostringstream os_stream( std::ostringstream::out );
1711 out.append( os_stream.str() );
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
double DoubleValue() const
Return the value of this attribute, converted to a double.
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
virtual TiXmlNode * Clone() const
const char * Name() const
Return the name of this attribute.
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
friend TIXML_OSTREAM & operator<<(TIXML_OSTREAM &out, const TiXmlNode &base)
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
virtual void StreamOut(TIXML_OSTREAM *out) const
const char * Value() const
Return the value of this attribute.
void Clear()
Delete all the children of this node. Does not affect 'this'.
void SetIntValue(int _value)
Set the value from an integer.
virtual TiXmlNode * Clone() const =0
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
virtual void Print(FILE *cfile, int depth) const
void CopyTo(TiXmlUnknown *target) const
void RemoveAttribute(const char *name)
std::istream & operator>>(std::istream &is, BufferPolicy &bp)
virtual void StreamOut(TIXML_OSTREAM *) const =0
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
static bool condenseWhiteSpace
TiXmlElement(const char *in_value)
Construct an element.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
virtual void StreamOut(TIXML_OSTREAM *out) const
void operator=(const TiXmlDocument ©)
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
static void PutString(const TIXML_STRING &str, TIXML_OSTREAM *out)
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
void operator=(const TiXmlDeclaration ©)
void operator=(const TiXmlElement &base)
TiXmlHandle FirstChild() const
Return a handle to the first child node.
virtual void StreamOut(TIXML_OSTREAM *out) const
void * userData
Field containing a generic user pointer.
void CopyTo(TiXmlNode *target) const
static Entity entity[NUM_ENTITY]
void Add(TiXmlAttribute *attribute)
TiXmlDeclaration()
Construct an empty declaration.
TiXmlHandle ChildElement(const char *value, int index) const
const TiXmlElement * NextSiblingElement() const
int QueryIntAttribute(const char *name, int *_value) const
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
void SetDoubleValue(double _value)
Set the value from a double.
TiXmlNode(NodeType _type)
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
int QueryIntValue(int *_value) const
virtual void StreamOut(TIXML_OSTREAM *out) const
const TiXmlAttribute * Find(const TIXML_STRING &name) const
virtual void Print(FILE *cfile, int depth) const =0
TiXmlAttributeSet attributeSet
virtual void Print(FILE *cfile, int depth) const
Print this Unknown to a FILE stream.
const TiXmlDocument * GetDocument() const
void CopyTo(TiXmlDocument *target) const
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
void SetValue(const char *_value)
const TiXmlAttribute * First() const
virtual void Print(FILE *cfile, int depth) const
Print this declaration to a FILE stream.
TiXmlDocument()
Create an empty document, that has no name.
StringToBuffer(const TIXML_STRING &str)
virtual void StreamOut(TIXML_OSTREAM *out) const
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
void SetDoubleAttribute(const char *name, double value)
TiXmlHandle Child(const char *value, int index) const
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
const TiXmlEncoding TIXML_DEFAULT_ENCODING
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
const unsigned char TIXML_UTF_LEAD_0
virtual void Print(FILE *cfile, int depth) const
Write this text object to a FILE stream.
const unsigned char TIXML_UTF_LEAD_1
int IntValue() const
Return the value of this attribute, converted to an integer.
const TiXmlNode * LastChild() const
void CopyTo(TiXmlElement *target) const
void Remove(TiXmlAttribute *attribute)
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
const unsigned char TIXML_UTF_LEAD_2
void SetValue(const char *_value)
Set the value.
const char * GetText() const
void CopyTo(TiXmlText *target) const
virtual void Print(FILE *cfile, int depth) const
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
const char * Attribute(const char *name) const
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
virtual void StreamOut(TIXML_OSTREAM *out) const
const char * Value() const
void SetAttribute(const char *name, const char *_value)
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
void CopyTo(TiXmlDeclaration *target) const
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)