C++ Objects and Resource Lists....

From: Date: Mon, 21 Aug 2000 20:42:34 +0000
Subject: C++ Objects and Resource Lists....
Groups: php.dev 
Request: Send a blank email to php-dev+get-30138@lists.php.net to get a copy of this message
I have a strange question and I'm not exactly sure how to ask it so here goes. I'm writing a PHP extension as a DSO which will provide wrapper objects for the Xerces XML parser (from xml.apache.org). The Xerces parser is a DSO that is written in C++. Now, I have most of this done already. I can call the Xerces stuff from the PHP extension parse the XML files and I've written wrappers for most of the common classes and "get" methods. But I had to hack it a little and I'm afraid that the hack is going to prevent me from writting wrappers for the "set" methods. When I parse a file I get back a reference to a "DOM_Document" object. I can get the address of that object and store that in a resource list. I have a PHP Object with a "hidden" attribute that keeps track of the resource number. When any of the wrapper methods are called, I look up the resource and get the reference to the DOM_Document and I can call the appropriate method. Now, here's where I'm having a problem. There are a number of methods that return references to other objects (references, not pointer). For instance, getFirstChild(). This returns the first child node (DOM_Node object) under the current node. If I call this on the DOM_Document object, I cannot store the address of the DOM_Node (I get segfaults when I try to reference them after pulling them back from a resource) I get back, I have to clone this node locally by passing it through the copy constructor for DOM_Node. I really don't want to do this. I would like to be able to store a reference to each node so that they can be changed and then a new Document could be exported. Or, a document could be built from scratch. Anyway, if you have ideas, or if you want to just ask me what the heck I'm talking about... please let me know. Thanks, Bob

« previous php.dev (#30138) next »