extended to take std::auto_ptr<iostream> as well as std::auto_ptr<std::istream>

This commit is contained in:
jez 2007-08-07 21:27:55 +00:00
parent 0dd9e4f728
commit f900c435e6
2 changed files with 34 additions and 0 deletions

View file

@ -169,6 +169,7 @@ public:
*
*/
explicit IStreamHandle(std::auto_ptr<std::istream> is);
explicit IStreamHandle(std::auto_ptr<std::iostream> is);
/** Construct an IStreamHandle sharing a std::istream with <em>rhs</em>.
*
@ -224,6 +225,7 @@ public:
*
*/
IStreamHandle& operator=(std::auto_ptr<std::istream> rhs);
IStreamHandle& operator=(std::auto_ptr<std::iostream> rhs);
/** Assign a new std::istream to <code>this</code>. This destroys the
* std::istream held by <code>this</code> if <code>this</code> <i>owns</i>
@ -303,6 +305,17 @@ IStreamHandle::IStreamHandle(std::auto_ptr<std::istream> is)
ISTREAMHANDLE_POSTCONDITION(is.get() == 0);
}
inline
IStreamHandle::IStreamHandle(std::auto_ptr<std::iostream> is)
: is_(is.release()),
counter_(new int(0)),
owner_(true)
{
addRef();
ISTREAMHANDLE_POSTCONDITION(*counter_ == 1);
ISTREAMHANDLE_POSTCONDITION(is.get() == 0);
}
inline
IStreamHandle::IStreamHandle(const IStreamHandle& rhs)
: is_(rhs.is_),
@ -350,6 +363,19 @@ IStreamHandle& IStreamHandle::operator=(std::auto_ptr<std::istream> rhs)
return *this;
}
inline
IStreamHandle& IStreamHandle::operator=(std::auto_ptr<std::iostream> rhs)
{
removeRef();
set(rhs.release(), true);
ISTREAMHANDLE_POSTCONDITION(*counter_ == 1);
ISTREAMHANDLE_POSTCONDITION(owner_ == true);
ISTREAMHANDLE_POSTCONDITION(rhs.get() == 0);
return *this;
}
inline
IStreamHandle& IStreamHandle::operator=(std::istream& rhs)
{

View file

@ -141,6 +141,14 @@ public:
systemId_(),
encoding_()
{ }
basic_InputSource(std::auto_ptr<std::iostream> byteStream) :
byteStream_(byteStream),
publicId_(),
systemId_(),
encoding_()
{ }
virtual ~basic_InputSource() { }