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 "Boris Kolpackov (JIRA)" <xe...@xml.apache.org> on 2009/11/04 10:03:32 UTC

[jira] Closed: (XERCESC-415) InputSource needs copy constructor and assignment operator

     [ https://issues.apache.org/jira/browse/XERCESC-415?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Boris Kolpackov closed XERCESC-415.
-----------------------------------

    Resolution: Won't Fix
      Assignee:     (was: Xerces-C Developers Mailing List)

I don't think it generally makes sense to allow copying of an input source. If you still believe this is a useful functionality, please reopen and describe a use case.

> InputSource needs copy constructor and assignment operator
> ----------------------------------------------------------
>
>                 Key: XERCESC-415
>                 URL: https://issues.apache.org/jira/browse/XERCESC-415
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: SAX/SAX2
>    Affects Versions: 1.7.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: David Bertoni
>
> InputSource does not have a copy constructor or an assignment operator.  Both 
> would be really handy for deriving classes.  Current derived classes can either 
> get the behavior by default, or avoid it by explicitly calling the default 
> constructor or not chaining up to the assignment operator.
> Here's a diff with the implementations:
> cvs diff InputSource.hpp (in directory V:\xml-xerces\c\src\xercesc\sax\)
> Index: InputSource.hpp
> ===================================================================
> RCS file: /home/cvs/xml-xerces/c/src/xercesc/sax/InputSource.hpp,v
> retrieving revision 1.2
> diff -r1.2 InputSource.hpp
> 324a325,334
> >     /** Copy constructor
> >       * @param src The instance to copy.
> >       */
> >     InputSource(const InputSource& src);
> >  
> >     /** Assignment operator
> >       * @param src The instance that is the source of the assigment.
> >       */
> >     InputSource& operator=(const InputSource& src);
> > 
> 332,337d341
> <     // -----------------------------------------------------------------------
> <     //  Unimplemented constructors and operators
> <     // -----------------------------------------------------------------------
> <     InputSource(const InputSource&);
> <     void operator=(const InputSource&);
> < 
> cvs diff InputSource.cpp (in directory V:\xml-xerces\c\src\xercesc\sax\)
> Index: InputSource.cpp
> ===================================================================
> RCS file: /home/cvs/xml-xerces/c/src/xercesc/sax/InputSource.cpp,v
> retrieving revision 1.1.1.1
> diff -r1.1.1.1 InputSource.cpp
> 88a89
> > #include    <xercesc/util/Janitor.hpp>
> 177a179,219
> > }
> > 
> > 
> > 
> > InputSource::InputSource(const InputSource& src) :
> > 
> >     fEncoding(src.fEncoding == 0 ? 0 : XMLString::replicate(src.fEncoding))
> >     , fPublicId(src.fPublicId == 0 ? 0 : XMLString::replicate(src.fPublicId))
> >     , fSystemId(src.fSystemId == 0 ? 0 : XMLString::replicate(src.fSystemId))
> >     , fFatalErrorIfNotFound(src.fFatalErrorIfNotFound)
> > {
> > }
> > 
> > InputSource&
> > InputSource::operator=(const InputSource& src)
> > {
> >     if (this != &src)
> >     {
> >         // For exception safety, make copies.  This only slightly
> >         // less efficient than copying directly into our data members...
> >         ArrayJanitor<XMLCh> tempEncoding(XMLString::replicate(src.fEncoding));
> >         ArrayJanitor<XMLCh> tempPublicId(XMLString::replicate(src.fPublicId));
> >         ArrayJanitor<XMLCh> tempSystemId(XMLString::replicate(src.fSystemId));
> > 
> >         // Swap the pointers...
> >         XMLCh* tempPtr = fEncoding;
> >         fEncoding = tempEncoding.release();
> >         tempEncoding.reset(tempPtr);
> > 
> >         tempPtr = fPublicId;
> >         fPublicId = tempPublicId.release();
> >         tempPublicId.reset(tempPtr);
> > 
> >         tempPtr = fSystemId;
> >         fSystemId = tempSystemId.release();
> >         tempSystemId.reset(tempPtr);
> > 
> >         fFatalErrorIfNotFound = src.fFatalErrorIfNotFound;
> >     }
> > 
> >     return *this;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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