No it is not safe. That is the old style of casting. With that style I could
do something like this:
int x = 1;
DOM_Node n = (DOM_Node)x; // which you know is not right.

I suggest you use the following:
DOM_Entity domen = dynamic_cast<DOM_Entity>(node);
If it doesn't compile, it may be that the compiler is trying to tell you
that 'node' may NOT be a DOM_Entity type and you are doing an illegal cast.

Regarding the blank screen, in your example, if 'node' is not a DOM_Entity
type, you could be corrupting your screen memory.

> -----Original Message-----
> From: Awasthi, Anand [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, June 08, 2001 3:33 PM
> To:   '[EMAIL PROTECTED]'
> Subject:      RE: sample for down casting DOM_Node to DOM_Entity ??
> 
> thanks guys...
> 
> i tried 
> 
> DOM_Node node;
> DOM_Entity domen = (DOM_Entity &)(node);
> 
> its compiles...but is this safe ?? 
> 
> later on i want to print PublicId and SystemId associated with this Entity
> node and
> i coded following: 
> 
> cout << "public id "  << ((DOM_Entity &)node).getPublicId().transcode() <<
> endl;
> cout << "system id "  << ((DOM_Entity &)node).getSystemId().transcode() <<
> endl;
> 
> but I am getting blank screen . is the above code correct or is there any
> better 
> implementation for obtaining PublicId and System Id value ?? pls suggest
> that. 
> 
> as a matter of fact when I use above DOMStrng.transcode() method to obtain
> 
> NOde Name ...i get Node Name. But when I try to obtain Node Value thru
> getNodeValue().transcode(),
> I get blank screen..whats wrong ?? 
> 
> 
> 
> pls enlighten me
> 
> 
> thanks
> anand
> 
> 
>                       
> 
> 
> 
> -----Original Message-----
> From: Adams, David [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 08, 2001 3:24 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: sample for down casting DOM_Node to DOM_Entity ??
> 
> 
> Curt is correct, in that I am assuming you know that the Node is an
> DOM_Entity type node and was passed around your code as a DOM_Node and you
> simply want to get its derived type back. If you do not know what type it
> really is, you do have to check it. The VC++ macro "DYNAMIC_DOWNCAST" is
> another way to check if that works for you.
> 
> > -----Original Message-----
> > From:       Adams, David [SMTP:[EMAIL PROTECTED]]
> > Sent:       Friday, June 08, 2001 3:16 PM
> > To: '[EMAIL PROTECTED]'
> > Subject:    RE: sample for down casting DOM_Node to DOM_Entity ??
> > 
> > DOM_Node n = // some node;
> > DOM_Entity e = dynamic_cast<DOM_Entity>(n);
> > 
> > I do not know what compiler you are using, but you will need to set the
> > /GR
> > switch on VC++ compilers. This is done by going to Project->settings,
> > select
> > the C/C++ tab, select the C++ Language category, and click on "Enable
> > Run-Time Type Information (RTTI)" to enable it.
> > 
> > > -----Original Message-----
> > > From:     Awasthi, Anand [SMTP:[EMAIL PROTECTED]]
> > > Sent:     Friday, June 08, 2001 2:58 PM
> > > To:       '[EMAIL PROTECTED]'
> > > Subject:  sample for down casting DOM_Node to DOM_Entity ??
> > > 
> > > Hi,
> > > 
> > > could someone pls provide sample code for down casting DOM_Node to
> > > DOM_Entity ??
> > > 
> > > thanks
> > > Anand
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to