X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Fhandle.cpp;fp=source%2Fio%2Fhandle.cpp;h=d5183e5b4a349d286f9858e85c3c28234ac5970f;hp=0000000000000000000000000000000000000000;hb=3b8384a993aed55b348bf51bb02900b3aa010ef8;hpb=e46de55d3c8f65d3b0eeaee76247476695e9eb7c diff --git a/source/io/handle.cpp b/source/io/handle.cpp new file mode 100644 index 0000000..d5183e5 --- /dev/null +++ b/source/io/handle.cpp @@ -0,0 +1,53 @@ +#include "handle.h" +#include "handle_private.h" + +namespace Msp { +namespace IO { + +Handle::Handle(): + priv(new Private) +{ } + +Handle::Handle(const Handle &other): + priv(new Private) +{ + priv->handle = other.priv->handle; +} + +Handle &Handle::operator=(const Handle &other) +{ + priv->handle = other.priv->handle; + return *this; +} + +Handle::~Handle() +{ + delete priv; +} + +Handle::operator const void *() const +{ +#ifdef WIN32 + return priv->handle!=INVALID_HANDLE_VALUE ? this : 0; +#else + return priv->handle!=-1 ? this : 0; +#endif +} + + +Handle::Private::Private(): +#ifdef WIN32 + handle(INVALID_HANDLE_VALUE) +#else + handle(-1) +#endif +{ } + +Handle::Private &Handle::Private::operator=(H h) +{ + handle = h; + return *this; +} + +} // namespace IO +} // namespace Msp