You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Troels Rossing <tr...@qualiware.com> on 2002/11/12 08:15:11 UTC
newbie - Downcasting problem
Hi
I'am trying to correct my code to follow the new C++ binding
architechture.
I have a DOMElement node that represents a pointer to where I am in the
DOM tree (nessesary since this is part of an interface for a
script-language).
This is how I did it in the old version :
DOMElement m_LoadActiveNode;//(defined as a class member variable)
DOMNode tmpNode;
tmpNode = m_LoadActiveNode.getPreviousSibling();
if(tmpNode!=NULL)
{
m_LoadActiveNode = (DOMElement &)tmpNode;
}
In the new 2.0.1, the m_LoadActiveNode is a pointer and not an
instantiated object, thus the downcast does not work. How do I solve
this problem???
I need something to hold a pointer to a node in the tree, since the DOM
interface is to be accessible from a scriptlanguage.
e.g.
scriptXMLsetFirstChild();
str = scriptXMLgetNodeName();
Any ideas of how to do the downcast or any other way to maintain a
DOMtree pointer as a class member variable would be very welcome.
Regards
Troels Rossing
www.Qualiware.com
Re: newbie - Downcasting problem
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
> DOMElement *m_LoadActiveNode;//(defined as a class member variable)
>
>
>
> DOMNode *tmpNode;
>
> tmpNode = m_LoadActiveNode->getPreviousSibling();
>
> if(tmpNode!=NULL)
>
> {
> m_LoadActiveNode = static_cast<DOMElement *>(tmpNode);
>
//or safer if you use rtti
m_LoadActiveNode = dynamic_cast<DOMELement *>(tmpNode)
>
> }
Gareth
--
Gareth Reakes, Head of Product Development
DecisionSoft Ltd. http://www.decisionsoft.com
Office: +44 (0) 1865 203192
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org