xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bovy, Stephen J" <STEPHEN.B...@ca.com>
Subject RE: DOMInputSource and BinInputStream ???
Date Thu, 22 Apr 2004 17:20:50 GMT
You are right, here is the correct approach:

Thanks for the feedback,  I realized though that I was doing the wrong
thing:

Here is the correct approach:

MemBufInputSource* memBufIS = NULL;      
Wrapper4InputSource* domBufIS = NULL;    

memBufIS = new MemBufInputSource                    
(                                                   
    (const XMLByte*) sfile.ipc->pbuff               
    , sfile.ipc->leng                               
    , gMemBufId                                     
    , false                                         
);                                                  
 

domBufIS = new Wrapper4InputSource ( memBufIS );     

if ( sfile.ipc ) {                                        
  doc = sstate->doc = sstate->parser->parse(*domBufIS);   
} else {                                                  
  doc = sstate->doc = sstate->parser->parseURI(xmlFile);  
} // endif in memory parse                                


delete domBufIS; <+++++++++????
delete memBufIS; <++++++++++????? 

My only question is it save to delete the two objects after the parse
and before
I use the dom document ?????
 

-----Original Message-----
From: david_n_bertoni@us.ibm.com [mailto:david_n_bertoni@us.ibm.com] 
Sent: Thursday, April 22, 2004 8:41 AM
To: xerces-c-dev@xml.apache.org
Subject: Re: DOMInputSource and BinInputStream ???

> Can I do the following:
>
> class myinput : DOMInputSource, BinMemInputStream {
>
> public:
>
>   myinput ( ) { };
>
>  ~myinput ( ) { };
>
>  BinInputStream* makestream ( ) { return this };
>
> }

You shouldn't do this, because the parser will want to delete the
BinMemInputStream instance, and I don't think there's any guarantee the
parser won't try to access to DOMInputSource instance after it has
deleted the stream.

As an side, perhaps you meant to derive from DOMInputSource using public
inheritence, rather than private?

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Mime
View raw message