📄 streamops.h
字号:
#pragma once
#include "Typedefs.h"
__forceinline std::ostream& operator<<(std::ostream& rStream, const LVCOLUMN& rColumn)
{
rStream << rColumn.mask << " " << rColumn.fmt << " " << rColumn.cx << " ";
rStream << rColumn.iSubItem << " ";
rStream << rColumn.iImage << " " << rColumn.iOrder << " ";
if (rColumn.pszText)
{
USES_CONVERSION;
rStream << T2CA(rColumn.pszText);
}
return rStream;
}
__forceinline std::istream& operator>>(std::istream& rStream, LVCOLUMN& rColumn)
{
rStream >> rColumn.mask >> rColumn.fmt >> rColumn.cx >> rColumn.iSubItem;
rStream >> rColumn.iImage >> rColumn.iOrder;
(void) rStream.ignore();
std::string strLine;
(void) std::getline(rStream, strLine);
USES_CONVERSION;
::_tcscpy_s(rColumn.pszText, rColumn.cchTextMax, A2CT(strLine.c_str()));
rColumn.cchTextMax = static_cast<int>(strLine.size());
if (0 == rColumn.cchTextMax)
{
rStream.clear(); // reset the stream error if we don't have column text
}
return rStream;
}
__forceinline std::ostream& operator<<(std::ostream& rStream, const LOGFONT& lf)
{
int nPts = lf.lfHeight /* * 72 / ::GetDeviceCaps(::GetDC(NULL), LOGPIXELSY)*/;
rStream << lf.lfFaceName << _T(";") << nPts << _T(";") << lf.lfWeight << _T(";") << (BOOL) lf.lfItalic << _T(";") << (BOOL) lf.lfUnderline << _T(";") << (BOOL) lf.lfStrikeOut;
return rStream;
}
__forceinline std::istream& operator>>(std::istream& rStream, LOGFONT& lf)
{
int bItalic = 0;
int underline = 0;
int strikeOut = 0;
ZeroMemory(&lf, sizeof(lf));
t_String theFaceName;
(void) getline(rStream, theFaceName, _T(';'));
::_tcscpy_s(lf.lfFaceName, 32, theFaceName.c_str());
rStream >> lf.lfHeight;
/* lf.lfHeight = lf.lfHeight * ::GetDeviceCaps(::GetDC(NULL), LOGPIXELSY) / 72*/;
rStream.ignore() >> lf.lfWeight; // ignore the commas
rStream.ignore() >> bItalic;
rStream.ignore() >> underline;
rStream.ignore() >> strikeOut;
lf.lfItalic = static_cast<BYTE>(bItalic); // because lf.lfItalic is a BYTE
lf.lfUnderline = static_cast<BYTE>(underline);
lf.lfStrikeOut = static_cast<BYTE>(strikeOut);
return rStream;
}
__forceinline std::ostream& operator<<(std::ostream& rStream, const CString& rs)
{
rStream << (LPCTSTR)rs;
return rStream;
}
__forceinline std::istream& operator>>(std::istream& rStream, CString& rs)
{
std::string theString;
std::getline(rStream, theString);
USES_CONVERSION;
rs = A2CT(theString.c_str());
return rStream;
}
//*** Modification History ***
// $Log: $
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -