/* * ======================================================== * * HCore * Copyright Mahrouss Logic, all rights reserved. * * ======================================================== */ #pragma once #include #include namespace HCore { template class Stream final { public: explicit Stream(Ref ref) : m_Stream(ref) {} ~Stream() = default; Stream &operator=(const Stream &) = default; Stream(const Stream &) = default; template friend Stream &operator>>(Stream &Ks, Ref& Buf) { Ks.m_Kind = Ks.m_Stream->In(Buf); return *Ks; } template friend Stream &operator<<(Stream &Ks, Ref& Buf) { Ks.m_Kind = Buf; Ks.m_Stream->Out(Buf.Leak()); return *Ks; } Ref &AsStreamTraits() { return m_Stream; } Ref& AsType() { return m_Kind; } private: Ref m_Stream; Ref m_Kind; }; } // namespace HCore