stream.cpp

来自「一套linux下的C++开发库」· C++ 代码 · 共 60 行

CPP
60
字号
/***************************************************************************                          stream.cpp  -  description                             -------------------    begin                : Fri Jul 20 2001    copyright            : (C) 2001 by Mark    email                : alben@yeah.net ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#include "stream.h"#include "exception.h"void CStream::AllocateBuffer(){	m_pchGetBuf = new char[m_iBufSize];	if (!m_pchGetBuf)		throw CMemException("out of memory.", __FILE__, __LINE__);			m_pchPutBuf = new char[m_iBufSize];	if(!m_pchPutBuf)	{		delete [] m_pchGetBuf, m_pchGetBuf = 0;		throw CMemException("out of memory.", __FILE__, __LINE__);	}	clear();	setb(m_pchGetBuf, m_pchGetBuf + m_iBufSize, 0);	setg(m_pchGetBuf, m_pchGetBuf + m_iBufSize, m_pchGetBuf + m_iBufSize);	setp(m_pchPutBuf, m_pchPutBuf + m_iBufSize);}void CStream::FreeBuffer(){	//flush will be done in the inherited class.	if (m_pchGetBuf)		delete m_pchGetBuf, m_pchGetBuf = 0;			if (m_pchPutBuf)		delete m_pchPutBuf, m_pchPutBuf = 0;}int CStream::sync(){	overflow(EOF);	return 0;}

⌨️ 快捷键说明

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