DumontEXE 0.0.1
Dom references

The following code demonstrates that the Dom system within Qt acts as a common memory pool for xml elements. When an xml reference is pulled from a document, that reference refers to a common memory pool that is referenced from any other part of the system that also pulls the same reference.

 #include <QDomDocument>
 #include <QApplication>
 
 void func1( QDomDocument & doc )
 {
   qDebug( "func1 %s", qPrintable(doc.firstChild().toElement().attribute("xyzzy","func1")) );
 
   doc.firstChild().toElement().setAttribute("xyzzy","abc");
 
 }
 
 void func2( QDomDocument & doc )
 {
   qDebug( "func2 %s", qPrintable(doc.firstChild().toElement().attribute("xyzzy","func2")) );
 }
 
 int main(int argc, char **argv)
 {
   QDomDocument doc;
 
   QDomElement element = doc.createElement( "test" );
 
   doc.appendChild( element );
 
   element.setAttribute( "xyzzy", "123" );
 
   QDomElement ref2 = doc.firstChild().toElement();
 
   func1(doc);
   func2(doc);
 
   qDebug( "ref2 %s", qPrintable(ref2.attribute("xyzzy")) );
 
   element.setAttribute( "xyzzy", "456" );
 
   func1(doc);
   func2(doc);
 
   QApplication app(argc,argv);
 
   qDebug( "test" );
 
   return( 0 );
 
 }
 
 output:
 // func1 123
 // func2 abc
 // ref2 abc
 // func1 456
 // func2 abc
 // test
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties




~ ~ ~ ~ ~ ~
Source Code without Comments is like a Cranberry Garland
without the berries. Comment your Code!
 
Commence Database User Support Group Forum
http://newsgroup.showoff-db.org/
~ ~ ~ ~ ~ ~
Author: Mark Petryk
Lorimark Solutions, LLC
mark@lorimarksolutions.com