⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 istream.cpp

📁 一个图像复合文档高级编程的程序
💻 CPP
字号:
// IStream.cpp: implementation of the CIStream class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "IStream.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CIStream::CIStream(LPSTREAM lpStream):
	m_hr(S_OK)
{
	ATLASSERT(lpStream != NULL);
	m_lpStream = lpStream;
}

CIStream::~CIStream()
{

}

CIStream& CIStream::operator<<(CComVariant& from)
{
	if(IsOk())
		m_hr = from.WriteToStream(m_lpStream);
	return *this;
}

CIStream& CIStream::operator<<(long from)
{
	CComVariant value(from);
	return *this << value;
}

CIStream& CIStream::operator<<(CString& from)
{
	CComVariant value(from);
	return *this << value;
}
CIStream& CIStream::operator<<(BYTE from)
{
	CComVariant value(from);
	return *this << value;
}
CIStream& CIStream::operator<<(short from)
{
	CComVariant value(from);
	return *this << value;
}
CIStream& CIStream::operator<<(float from)
{
	CComVariant value(from);
	return *this << value;
}
CIStream& CIStream::operator<<(double from)
{
	CComVariant value(from);
	return *this << value;
}
CIStream& CIStream::operator<<(int from)
{
	CComVariant value(from);
	return *this << value;
}
CIStream& CIStream::operator<<(bool from)
{
	CComVariant value(from);
	return *this << value;
}

CIStream& CIStream::operator<<(CRect from)
{
	return *this << from.left << from.top << from.right << from.bottom;
}

//////////////////////////////////////////////////////////////////////////
//

CIStream& CIStream::operator>>(CComVariant& to)
{
	if(IsOk())
		m_hr = to.ReadFromStream(m_lpStream);
	return *this;
}

CIStream& CIStream::operator>>(CString& to)
{
	CComVariant var;
	*this >> var; to = var.bstrVal;
	return *this;
}
CIStream& CIStream::operator>>(long& to)
{
	CComVariant var;
	*this >> var; to = var.lVal;
	return *this;
}
CIStream& CIStream::operator>>(BYTE& to)
{
	CComVariant var;
	*this >> var; to = var.bVal;
	return *this;
}
CIStream& CIStream::operator>>(short& to)
{
	CComVariant var;
	*this >> var; 	to = var.iVal;
	return *this;
}
CIStream& CIStream::operator>>(int& to)
{
	CComVariant var;
	*this >> var; to = var.lVal;
	return *this;
}
CIStream& CIStream::operator>>(float& to)
{
	CComVariant var;
	*this >> var; to = var.fltVal;
	return *this;
}
CIStream& CIStream::operator>>(double& to)
{
	CComVariant var;
	*this >> var; to = var.dblVal;
	return *this;
}
CIStream& CIStream::operator>>(bool& to)
{
	CComVariant var;
	*this >> var; 
	to = var.boolVal == VARIANT_TRUE ? true : false;
	return *this;
}

CIStream& CIStream::operator>>(CRect& to)
{
	return *this >> to.left >> to.top >> to.right >> to.bottom;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -